From 51ed2868f7a19af811b4d718e6c969ca57b67ec4 Mon Sep 17 00:00:00 2001 From: Maurice Williams Date: Tue, 1 Jul 2014 23:44:39 -0400 Subject: [PATCH] Removing old "user settings" screen and putting in new MU "users settings" screen and updating functional test cases. Fixes #3078 - new "users" resource, with matching controller and template - fetching real data from /ghost/api/v0.1/users/ - updated "user" route to accept a :slug as a URL parameter - updated labels everywhere (from "user" to "users") - updated "profile" link to header to point to proper "users/:slug" route - updated core/client/.jshintrc to recognize moment as a valid global function - adjusted DOM selector used in Casper to properly identify the new screen - adding "slug" as a new property of the user data used during the Casper functional tests --- ghost/admin/.jshintrc | 3 +- .../admin/controllers/settings/users/index.js | 18 ++++++ .../controllers/settings/{ => users}/user.js | 26 +++++++- ghost/admin/router.js | 4 +- ghost/admin/routes/settings/users.js | 3 + ghost/admin/routes/settings/users/index.js | 8 +++ .../admin/routes/settings/{ => users}/user.js | 0 ghost/admin/templates/-navbar.hbs | 2 +- ghost/admin/templates/settings.hbs | 2 +- .../admin/templates/settings/users/index.hbs | 63 +++++++++++++++++++ .../templates/settings/{ => users}/user.hbs | 0 11 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 ghost/admin/controllers/settings/users/index.js rename ghost/admin/controllers/settings/{ => users}/user.js (73%) create mode 100644 ghost/admin/routes/settings/users.js create mode 100644 ghost/admin/routes/settings/users/index.js rename ghost/admin/routes/settings/{ => users}/user.js (100%) create mode 100644 ghost/admin/templates/settings/users/index.hbs rename ghost/admin/templates/settings/{ => users}/user.hbs (100%) diff --git a/ghost/admin/.jshintrc b/ghost/admin/.jshintrc index 18c4e9e734..5574b02288 100644 --- a/ghost/admin/.jshintrc +++ b/ghost/admin/.jshintrc @@ -30,6 +30,7 @@ "validator": true, "ic": true, "_": true, - "NProgress": true + "NProgress": true, + "moment": true } } diff --git a/ghost/admin/controllers/settings/users/index.js b/ghost/admin/controllers/settings/users/index.js new file mode 100644 index 0000000000..f731e21c06 --- /dev/null +++ b/ghost/admin/controllers/settings/users/index.js @@ -0,0 +1,18 @@ +/*global alert */ +var UsersIndexController = Ember.ArrayController.extend({ + activeUsers: function () { + return this.content.filterBy('status', 'active'); + }.property('model'), + + invitedUsers: function () { + return this.content.filterBy('status', 'invited'); + }.property('model'), + + actions: { + addUser: function () { + alert('@TODO: needs to show the "add user" modal - see issue #3079 on GitHub'); + } + } +}); + +export default UsersIndexController; diff --git a/ghost/admin/controllers/settings/user.js b/ghost/admin/controllers/settings/users/user.js similarity index 73% rename from ghost/admin/controllers/settings/user.js rename to ghost/admin/controllers/settings/users/user.js index 825e07da3a..4fd9c24f6c 100644 --- a/ghost/admin/controllers/settings/user.js +++ b/ghost/admin/controllers/settings/users/user.js @@ -3,7 +3,10 @@ var SettingsUserController = Ember.ObjectController.extend({ user: Ember.computed.alias('model'), + email: Ember.computed.readOnly('user.email'), + coverDefault: '/shared/img/user-cover.png', + cover: function () { // @TODO: add {{asset}} subdir path var cover = this.get('user.cover'); @@ -19,10 +22,31 @@ var SettingsUserController = Ember.ObjectController.extend({ image: function () { // @TODO: add {{asset}} subdir path - return 'background-image: url(' + this.getWithDefault('user.image', '/shared/img/user-image.png') + ')'; + return 'background-image: url(' + this.getWithDefault('user.image', '/shared/img/user-image.png') + ')'; }.property('user.image'), + imageUrl: function () { + // @TODO: add {{asset}} subdir path + return this.getWithDefault('user.image', '/shared/img/user-image.png'); + }.property('user.image'), + + last_login: function () { + return moment(this.get('user.last_login')).fromNow(); + }.property('user.last_login'), + + created_at: function () { + return moment(this.get('user.created_at')).fromNow(); + }.property('user.created_at'), + actions: { + revoke: function () { + alert('@TODO: revoke users invitation'); + }, + + resend: function () { + alert('@TODO: resend users invitation'); + }, + save: function () { var user = this.get('user'), self = this; diff --git a/ghost/admin/router.js b/ghost/admin/router.js index 7486b578cf..8861e2838c 100644 --- a/ghost/admin/router.js +++ b/ghost/admin/router.js @@ -30,7 +30,9 @@ Router.map(function () { }); this.resource('settings', function () { this.route('general'); - this.route('user'); + this.resource('settings.users', { path: '/users' }, function () { + this.route('user', { path: '/:slug' }); + }); this.route('apps'); }); this.route('debug'); diff --git a/ghost/admin/routes/settings/users.js b/ghost/admin/routes/settings/users.js new file mode 100644 index 0000000000..02bfbc91cd --- /dev/null +++ b/ghost/admin/routes/settings/users.js @@ -0,0 +1,3 @@ +var UsersRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin); + +export default UsersRoute; diff --git a/ghost/admin/routes/settings/users/index.js b/ghost/admin/routes/settings/users/index.js new file mode 100644 index 0000000000..445375e51b --- /dev/null +++ b/ghost/admin/routes/settings/users/index.js @@ -0,0 +1,8 @@ +var UsersIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, { + + model: function () { + return this.store.find('user'); + } +}); + +export default UsersIndexRoute; diff --git a/ghost/admin/routes/settings/user.js b/ghost/admin/routes/settings/users/user.js similarity index 100% rename from ghost/admin/routes/settings/user.js rename to ghost/admin/routes/settings/users/user.js diff --git a/ghost/admin/templates/-navbar.hbs b/ghost/admin/templates/-navbar.hbs index 9e1aa75dc2..73451979ec 100644 --- a/ghost/admin/templates/-navbar.hbs +++ b/ghost/admin/templates/-navbar.hbs @@ -18,7 +18,7 @@ {{session.user.name}} {{/gh-popover-button}} {{#gh-popover tagName="ul" classNames="overlay" name="user-menu" closeOnClick="true"}} -
  • {{#link-to "settings.user"}}Your Profile{{/link-to}}
  • +
  • {{#link-to "settings.users.user" session.user.slug}}Your Profile{{/link-to}}
  • Help / Support
  • diff --git a/ghost/admin/templates/settings.hbs b/ghost/admin/templates/settings.hbs index 1b5c12bde5..2821b2f580 100644 --- a/ghost/admin/templates/settings.hbs +++ b/ghost/admin/templates/settings.hbs @@ -9,7 +9,7 @@ {{/view}} {{#view "item-view" tagName="li" class="users"}} - {{#link-to "settings.user"}}User{{/link-to}} + {{#link-to "settings.users"}}Users{{/link-to}} {{/view}} {{#if showApps}} diff --git a/ghost/admin/templates/settings/users/index.hbs b/ghost/admin/templates/settings/users/index.hbs new file mode 100644 index 0000000000..c5c33345ec --- /dev/null +++ b/ghost/admin/templates/settings/users/index.hbs @@ -0,0 +1,63 @@ +
    + +

    Users

    +
    + New User +
    +
    + +
    +
    + +

    Invited users

    + + {{#each invitedUsers itemController="settings/users/user"}} +
    + ic + +
    + {{email}}
    + Invitation sent: {{created_at}} +
    + +
    + {{else}} +
    + No invited users. +
    + {{/each}} + + +
    + +
    + +

    Active users

    + + + {{#each activeUsers itemController="settings/users/user"}} +
    + Photo of {{unbound name}} + +
    + {{#link-to 'settings.users.user' slug class="ember-view name" }} + {{user.name}} + {{/link-to}} +
    + Last seen: {{unbound last_login}} +
    + + +
    + {{/each}} + +
    +
    diff --git a/ghost/admin/templates/settings/user.hbs b/ghost/admin/templates/settings/users/user.hbs similarity index 100% rename from ghost/admin/templates/settings/user.hbs rename to ghost/admin/templates/settings/users/user.hbs