mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Hide settings/apps unless apps:true is in config.js
fixes #3031 - Adds an initializer for passing config to the frontend, it's not pretty but it works - Forwards the apps route and hides the apps menu item if apps:true is not present in config.js
This commit is contained in:
parent
f4c6309880
commit
bb490e4bbd
5
core/client/controllers/settings.js
Normal file
5
core/client/controllers/settings.js
Normal file
@ -0,0 +1,5 @@
|
||||
var SettingsController = Ember.Controller.extend({
|
||||
showApps: Ember.computed.bool('config.apps')
|
||||
});
|
||||
|
||||
export default SettingsController;
|
12
core/client/initializers/ghost-config.js
Normal file
12
core/client/initializers/ghost-config.js
Normal file
@ -0,0 +1,12 @@
|
||||
var ConfigInitializer = {
|
||||
name: 'config',
|
||||
|
||||
initialize: function (container, application) {
|
||||
application.register('ghost:config', application.get('config'), {instantiate: false});
|
||||
|
||||
application.inject('route', 'config', 'ghost:config');
|
||||
application.inject('controller', 'config', 'ghost:config');
|
||||
}
|
||||
};
|
||||
|
||||
export default ConfigInitializer;
|
@ -1,6 +1,11 @@
|
||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||
|
||||
var AppsRoute = AuthenticatedRoute.extend({
|
||||
beforeModel: function () {
|
||||
if (!this.get('config.apps')) {
|
||||
this.transitionTo('settings.general');
|
||||
}
|
||||
},
|
||||
model: function () {
|
||||
return this.store.find('app');
|
||||
}
|
||||
|
@ -8,14 +8,16 @@
|
||||
{{#view "item-view" tagName="li" class="general"}}
|
||||
{{#link-to "settings.general"}}General{{/link-to}}
|
||||
{{/view}}
|
||||
|
||||
|
||||
{{#view "item-view" tagName="li" class="users"}}
|
||||
{{#link-to "settings.user"}}User{{/link-to}}
|
||||
{{/view}}
|
||||
|
||||
{{#view "item-view" tagName="li" class="apps"}}
|
||||
{{#link-to "settings.apps"}}Apps{{/link-to}}
|
||||
{{/view}}
|
||||
|
||||
{{#if showApps}}
|
||||
{{#view "item-view" tagName="li" class="apps"}}
|
||||
{{#link-to "settings.apps"}}Apps{{/link-to}}
|
||||
{{/view}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
@ -42,15 +42,21 @@ function setSelected(list, name) {
|
||||
|
||||
adminControllers = {
|
||||
'index': function (req, res) {
|
||||
|
||||
/*jslint unparam:true*/
|
||||
var userData;
|
||||
var userData,
|
||||
// config we need on the frontend
|
||||
frontConfig = {
|
||||
apps: config().apps
|
||||
};
|
||||
|
||||
if (req.session && req.session.userData) {
|
||||
userData = JSON.stringify(req.session.userData);
|
||||
}
|
||||
|
||||
res.render('default-ember', {
|
||||
user: userData
|
||||
user: userData,
|
||||
config: JSON.stringify(frontConfig)
|
||||
});
|
||||
},
|
||||
// Route: index
|
||||
|
@ -41,9 +41,8 @@
|
||||
|
||||
<script>
|
||||
window.ENV = {
|
||||
{{#user}}
|
||||
user: {{{this}}}
|
||||
{{/user}}
|
||||
{{#user}}user: {{{this}}},{{/user}}
|
||||
config: {{{config}}}
|
||||
};
|
||||
window.App = require('ghost/app')['default'].create(window.ENV);
|
||||
</script>
|
||||
|
@ -20,7 +20,7 @@ CasperTest.emberBegin('Settings screen is correct', 17, function suite(test) {
|
||||
test.assertExists('.settings-menu', 'Settings menu is present');
|
||||
test.assertExists('.settings-menu .general', 'General tab is present');
|
||||
test.assertExists('.settings-menu .users', 'Users tab is present');
|
||||
test.assertExists('.settings-menu .apps', 'Apps is present');
|
||||
test.assertNotExists('.settings-menu .apps', 'Apps is present');
|
||||
test.assertExists('.wrapper', 'Settings main view is present');
|
||||
test.assertExists('.settings-content', 'Settings content view is present');
|
||||
test.assertExists('.settings-menu .general.active', 'General tab is marked active');
|
||||
|
Loading…
Reference in New Issue
Block a user