1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Clean up Ember router map

No Issue
- Switch resources to routes.
- No longer nest "settings" routes so the router reflects
  the way the templates are rendered.
- Remove renderTemplate override from settings routes.
- Remove unneeded routes, controllers, and views.
- Adjust users page so that infinite scroll loading of users works
  and markup remains the same for Zelda styling.
This commit is contained in:
Jason Williams 2015-05-25 13:17:10 -05:00
parent a64b4d43fc
commit 1d38904636
23 changed files with 118 additions and 280 deletions

View file

@ -1,32 +0,0 @@
import Ember from 'ember';
var SettingsController = Ember.Controller.extend({
needs: ['feature'],
showGeneral: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showUsers: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showTags: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showNavigation: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showCodeInjection: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showLabs: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showAbout: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showPassProtection: Ember.computed('session.user.name', 'controllers.feature.passProtectUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('controllers.feature.passProtectUI') ? false : true;
})
});
export default SettingsController;

View file

@ -22,32 +22,23 @@ Router.map(function () {
this.route('reset', {path: '/reset/:token'});
this.route('about', {path: '/about'});
this.resource('posts', {path: '/'}, function () {
this.route('posts', {path: '/'}, function () {
this.route('post', {path: ':post_id'});
});
this.resource('editor', function () {
this.route('editor', function () {
this.route('new', {path: ''});
this.route('edit', {path: ':post_id'});
});
this.resource('settings', function () {
this.route('general');
this.resource('settings.users', {path: '/users'}, function () {
this.route('user', {path: '/:slug'});
});
// Redirect about page
this.route('about');
this.route('tags');
this.route('labs');
this.route('code-injection');
this.route('navigation');
this.route('settings.general', {path: '/settings/general'});
this.route('settings.users', {path: '/settings/users'}, function () {
this.route('user', {path: ':slug'});
});
// Redirect debug to settings labs
this.route('debug');
this.route('settings.tags', {path: '/settings/tags'});
this.route('settings.labs', {path: '/settings/labs'});
this.route('settings.code-injection', {path: '/settings/code-injection'});
this.route('settings.navigation', {path: '/settings/navigation'});
// Redirect legacy content to posts
this.route('content');

View file

@ -1,15 +1,17 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
var AboutRoute = AuthenticatedRoute.extend(styleBody, {
export default AuthenticatedRoute.extend(styleBody, {
titleToken: 'About',
classNames: ['view-about'],
cachedConfig: false,
model: function () {
var cachedConfig = this.get('cachedConfig'),
self = this;
if (cachedConfig) {
return cachedConfig;
}
@ -17,18 +19,14 @@ var AboutRoute = AuthenticatedRoute.extend(styleBody, {
return ic.ajax.request(this.get('ghostPaths.url').api('configuration'))
.then(function (configurationResponse) {
var configKeyValues = configurationResponse.configuration;
cachedConfig = {};
configKeyValues.forEach(function (configKeyValue) {
cachedConfig[configKeyValue.key] = configKeyValue.value;
});
self.set('cachedConfig', cachedConfig);
return cachedConfig;
});
},
renderTemplate: function () {
this.render('about', {into: 'application'});
}
});
export default AboutRoute;

View file

@ -1,10 +0,0 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
var SettingsRoute = AuthenticatedRoute.extend(styleBody, {
titleToken: 'Settings',
classNames: ['settings']
});
export default SettingsRoute;

View file

@ -1,10 +0,0 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
var SettingsAboutRoute = AuthenticatedRoute.extend(styleBody, {
beforeModel: function () {
this.transitionTo('about');
}
});
export default SettingsAboutRoute;

View file

@ -19,10 +19,6 @@ var AppsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
model: function () {
return this.store.find('app');
},
renderTemplate: function () {
this.render('settings/apps', {into: 'application'});
}
});

View file

@ -2,7 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - Code Injection',
classNames: ['settings-view-code'],
beforeModel: function () {
@ -17,15 +18,9 @@ var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, CurrentUse
});
},
renderTemplate: function () {
this.render('settings/code-injection', {into: 'application'});
},
actions: {
save: function () {
this.get('controller').send('save');
}
}
});
export default SettingsCodeInjectionRoute;

View file

@ -2,8 +2,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'General',
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - General',
classNames: ['settings-view-general'],
@ -19,15 +19,9 @@ var SettingsGeneralRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSetti
});
},
renderTemplate: function () {
this.render('settings/general', {into: 'application'});
},
actions: {
save: function () {
this.get('controller').send('save');
}
}
});
export default SettingsGeneralRoute;

View file

@ -1,29 +0,0 @@
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
import MobileIndexRoute from 'ghost/routes/mobile-index-route';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import mobileQuery from 'ghost/utils/mobile';
var SettingsIndexRoute = MobileIndexRoute.extend(AuthenticatedRouteMixin, CurrentUserSettings, {
titleToken: 'Settings',
// Redirect users without permission to view settings,
// and show the settings.general route unless the user
// is mobile
beforeModel: function () {
var self = this;
return this.get('session.user')
.then(this.transitionAuthor())
.then(this.transitionEditor())
.then(function () {
if (!mobileQuery.matches) {
self.transitionTo('settings.general');
}
});
},
desktopTransition: function () {
this.transitionTo('settings.general');
}
});
export default SettingsIndexRoute;

View file

@ -2,10 +2,11 @@ import AuthenticatedRoute from 'ghost/routes/authenticated';
import styleBody from 'ghost/mixins/style-body';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
var LabsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Labs',
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Settings - Labs',
classNames: ['settings'],
beforeModel: function () {
return this.get('session.user')
.then(this.transitionAuthor())
@ -16,11 +17,5 @@ var LabsRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
return this.store.find('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
},
renderTemplate: function () {
this.render('settings/labs', {into: 'application'});
}
});
export default LabsRoute;

View file

@ -3,8 +3,7 @@ import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
var NavigationRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Navigation',
titleToken: 'Settings - Navigation',
classNames: ['settings-view-navigation'],
@ -19,10 +18,6 @@ var NavigationRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings,
});
},
renderTemplate: function () {
this.render('settings/navigation', {into: 'application'});
},
actions: {
save: function () {
// since shortcuts are run on the route, we have to signal to the components

View file

@ -12,13 +12,7 @@ paginationSettings = {
};
TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin, {
actions: {
willTransition: function () {
this.send('closeSettingsMenu');
}
},
titleToken: 'Tags',
titleToken: 'Settings - Tags',
beforeModel: function () {
return this.get('session.user')
@ -40,7 +34,6 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin,
renderTemplate: function (controller, model) {
this._super(controller, model);
this.render('settings/tags', {into: 'application'});
this.render('settings/tags/settings-menu', {
into: 'application',
outlet: 'settings-menu',
@ -50,6 +43,12 @@ TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin,
deactivate: function () {
this.controller.send('resetPagination');
},
actions: {
willTransition: function () {
this.send('closeSettingsMenu');
}
}
});

View file

@ -13,7 +13,7 @@ paginationSettings = {
};
UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, PaginationRouteMixin, {
titleToken: 'Users',
titleToken: 'Team',
classNames: ['settings-view-users'],
@ -47,10 +47,6 @@ UsersIndexRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, Pagi
});
},
renderTemplate: function () {
this.render('settings/users/index', {into: 'application'});
},
actions: {
reload: function () {
this.refresh();

View file

@ -3,7 +3,7 @@ import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'User',
titleToken: 'Team - User',
classNames: ['settings-view-user'],
@ -49,10 +49,6 @@ var SettingsUserRoute = AuthenticatedRoute.extend(styleBody, CurrentUserSettings
this._super();
},
renderTemplate: function () {
this.render('settings/users/user', {into: 'application'});
},
actions: {
save: function () {
this.get('controller').send('save');

View file

@ -1,41 +1,41 @@
<section class="view-content">
<section class="gh-view js-settings-content">
<section class="view-content">
<header class="gh-about-header">
<img class="gh-logo" src="{{gh-path 'admin' '/img/ghost-logo.png'}}" alt="Ghost" />
<!-- TODO: fix about notifications -->
{{gh-notifications location="about-upgrade" notify="updateNotificationChange"}}
</header>
<header class="gh-about-header">
<img class="gh-logo" src="{{gh-path 'admin' '/img/ghost-logo.png'}}" alt="Ghost" />
<!-- TODO: fix about notifications -->
{{gh-notifications location="about-upgrade" notify="updateNotificationChange"}}
</header>
<section class="gh-env-details">
<ul class="gh-env-list">
<li class="gh-env-list-version"><strong>Version</strong> {{model.version}}</li>
<li><strong>Environment</strong> {{model.environment}}</li>
<li class="gh-env-list-database-type"><strong>Database</strong> {{model.database}}</li>
<li><strong>Mail</strong> {{#if model.mail}}{{model.mail}}{{else}}Native{{/if}}</li>
</ul>
<div class="gh-env-help">
<a href="http://support.ghost.org" class="btn btn-minor" target="_blank">User Documentation</a>
<a href="https://ghost.org/slack/" class="btn btn-minor" target="_blank">Get Help With Ghost</a>
</div>
</section>
<section class="gh-credits">
<h2>The People Who Made it Possible</h2>
<section class="gh-contributors">
{{partial "contributors"}}
<section class="gh-env-details">
<ul class="gh-env-list">
<li class="gh-env-list-version"><strong>Version</strong> {{model.version}}</li>
<li><strong>Environment</strong> {{model.environment}}</li>
<li class="gh-env-list-database-type"><strong>Database</strong> {{model.database}}</li>
<li><strong>Mail</strong> {{#if model.mail}}{{model.mail}}{{else}}Native{{/if}}</li>
</ul>
<div class="gh-env-help">
<a href="http://support.ghost.org" class="btn btn-minor" target="_blank">User Documentation</a>
<a href="https://ghost.org/slack/" class="btn btn-minor" target="_blank">Get Help With Ghost</a>
</div>
</section>
<p>Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version youre using right now.</p>
<section class="gh-credits">
<h2>The People Who Made it Possible</h2>
<a href="https://ghost.org/about/contribute/" class="btn btn-blue btn-lg">Find out how you can get involved</a>
<section class="gh-contributors">
{{partial "contributors"}}
</section>
<p>Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version youre using right now.</p>
<a href="https://ghost.org/about/contribute/" class="btn btn-blue btn-lg">Find out how you can get involved</a>
</section>
<footer class="gh-copyright-info">
Copyright 2013 - 2015 Ghost Foundation, released under the <a href="https://github.com/TryGhost/Ghost/blob/master/LICENSE">MIT license</a>.
<br>
<a href="https://ghost.org/">Ghost</a> is a trademark of the <a href="https://ghost.org/about/">Ghost Foundation</a>.
</footer>
</section>
<footer class="gh-copyright-info">
Copyright 2013 - 2015 Ghost Foundation, released under the <a href="https://github.com/TryGhost/Ghost/blob/master/LICENSE">MIT license</a>.
<br>
<a href="https://ghost.org/">Ghost</a> is a trademark of the <a href="https://ghost.org/about/">Ghost Foundation</a>.
</footer>
</section>

View file

@ -8,7 +8,7 @@
{{/gh-dropdown-button}}
{{#gh-dropdown tagName="div" classNames="dropdown" name="user-menu" closeOnClick="true"}}
<ul class="dropdown-menu dropdown-triangle-top js-user-menu-dropdown-menu" role="menu" style="right:-50%;left:auto;margin-right:40px">
<li role="presentation">{{#link-to "settings.about" classNames="gh-nav-menu-about dropdown-item js-nav-item" role="menuitem" tabindex="-1"}}<i class="icon-gh"></i> About Ghost{{/link-to}}</li>
<li role="presentation">{{#link-to "about" classNames="gh-nav-menu-about dropdown-item js-nav-item" role="menuitem" tabindex="-1"}}<i class="icon-gh"></i> About Ghost{{/link-to}}</li>
<li class="divider"></li>
<li role="presentation">{{#link-to "settings.users.user" session.user.slug classNames="dropdown-item user-menu-profile js-nav-item" role="menuitem" tabindex="-1"}}<i class="icon-user"></i> Your Profile{{/link-to}}</li>
<li class="divider"></li>

View file

@ -5,64 +5,60 @@
</section>
</header>
<section class="view-content settings-users">
{{#view "users-list"}}
{{#if invitedUsers}}
<section class="user-list invited-users">
{{#if invitedUsers}}
<h4 class="user-list-title">Invited users</h4>
<section class="user-list invited-users">
{{#each user in invitedUsers itemController="settings/users/user"}}
<div class="user-list-item">
<span class="user-list-item-icon icon-mail">ic</span>
<h4 class="user-list-title">Invited users</h4>
<div class="user-list-item-body">
<span class="name">{{user.email}}</span><br>
{{#if user.model.pending}}
<span class="red">Invitation not sent - please try again</span>
{{else}}
<span class="description">Invitation sent: {{user.model.created_at}}</span>
{{/if}}
</div>
<aside class="user-list-item-aside">
<a class="user-list-action" href="#" {{action "revoke"}}>Revoke</a>
<a class="user-list-action" href="#" {{action "resend"}}>Resend</a>
</aside>
</div>
{{/each}}
{{#each user in invitedUsers itemController="settings/users/user"}}
<div class="user-list-item">
<span class="user-list-item-icon icon-mail">ic</span>
</section>
{{/if}}
<section class="user-list active-users">
<h4 class="user-list-title">Active users</h4>
{{#each user in activeUsers itemController="settings/users/user"}}
{{#link-to 'settings.users.user' user.model class="user-list-item" }}
<span class="user-list-item-figure" style={{user.userImageBackground}}>
<span class="hidden">Photo of {{user.model.name}}</span>
</span>
<div class="user-list-item-body">
<span class="name">{{user.email}}</span><br>
{{#if user.model.pending}}
<span class="red">Invitation not sent - please try again</span>
{{else}}
<span class="description">Invitation sent: {{user.model.created_at}}</span>
{{/if}}
<span class="name">
{{user.model.name}}
</span>
<br>
<span class="description">Last seen: {{user.last_login}}</span>
</div>
<aside class="user-list-item-aside">
<a class="user-list-action" href="#" {{action "revoke"}}>Revoke</a>
<a class="user-list-action" href="#" {{action "resend"}}>Resend</a>
{{#unless user.model.isAuthor}}
{{#each role in user.model.roles}}
<span class="role-label {{role.lowerCaseName}}">{{role.name}}</span>
{{/each}}
{{/unless}}
</aside>
</div>
{{/link-to}}
{{/each}}
</section>
{{/if}}
<section class="user-list active-users">
<h4 class="user-list-title">Active users</h4>
{{#each user in activeUsers itemController="settings/users/user"}}
{{#link-to 'settings.users.user' user.model class="user-list-item" }}
<span class="user-list-item-figure" style={{user.userImageBackground}}>
<span class="hidden">Photo of {{user.model.name}}</span>
</span>
<div class="user-list-item-body">
<span class="name">
{{user.model.name}}
</span>
<br>
<span class="description">Last seen: {{user.last_login}}</span>
</div>
<aside class="user-list-item-aside">
{{#unless user.model.isAuthor}}
{{#each role in user.model.roles}}
<span class="role-label {{role.lowerCaseName}}">{{role.name}}</span>
{{/each}}
{{/unless}}
</aside>
{{/link-to}}
{{/each}}
</section>
</section>{{! .content settings-users }}
{{/view}}

View file

@ -1,5 +0,0 @@
import BaseView from 'ghost/views/settings/content-base';
var AboutView = BaseView.extend();
export default AboutView;

View file

@ -1,20 +0,0 @@
import MobileParentView from 'ghost/views/mobile/parent-view';
var SettingsView = MobileParentView.extend({
// MobileParentView callbacks
showMenu: function () {
$('.js-settings-header-inner').css('display', 'none');
$('.js-settings-menu').css({right: '0', left: '0', 'margin-right': '0'});
$('.js-settings-content').css({right: '-100%', left: '100%', 'margin-left': '15'});
},
showContent: function () {
$('.js-settings-menu').css({right: '100%', left: '-110%', 'margin-right': '15px'});
$('.js-settings-content').css({right: '0', left: '0', 'margin-left': '0'});
$('.js-settings-header-inner').css('display', 'block');
},
showAll: function () {
$('.js-settings-menu, .js-settings-content').removeAttr('style');
}
});
export default SettingsView;

View file

@ -1,5 +0,0 @@
import MobileIndexView from 'ghost/views/mobile/index-view';
var SettingsIndexView = MobileIndexView.extend();
export default SettingsIndexView;

View file

@ -1,8 +0,0 @@
import Ember from 'ember';
import PaginationViewMixin from 'ghost/mixins/pagination-view-infinite-scroll';
var UsersListView = Ember.View.extend(PaginationViewMixin, {
classNames: ['js-users-list-view']
});
export default UsersListView;

7
app/views/users-list.js Normal file
View file

@ -0,0 +1,7 @@
import Ember from 'ember';
import PaginationViewMixin from 'ghost/mixins/pagination-view-infinite-scroll';
export default Ember.View.extend(PaginationViewMixin, {
tagName: 'section',
classNames: ['js-users-list-view', 'view-content', 'settings-users']
});

View file

@ -20,7 +20,6 @@
"loader.js": "3.2.1",
"moment": "2.10.2",
"normalize.css": "3.0.3",
"nprogress": "0.1.6",
"password-generator": "git://github.com/bermi/password-generator#49accd7",
"rangyinputs": "1.2.0",
"showdown-ghost": "0.3.6",