2018-06-20 11:50:31 +08:00
|
|
|
import HeaderPrimary from './components/HeaderPrimary';
|
|
|
|
import HeaderSecondary from './components/HeaderSecondary';
|
|
|
|
import routes from './routes';
|
|
|
|
import Application from '../common/Application';
|
|
|
|
import Navigation from '../common/components/Navigation';
|
|
|
|
import AdminNav from './components/AdminNav';
|
|
|
|
|
|
|
|
export default class AdminApplication extends Application {
|
|
|
|
extensionSettings = {};
|
|
|
|
|
|
|
|
history = {
|
|
|
|
canGoBack: () => true,
|
|
|
|
getPrevious: () => {},
|
|
|
|
backUrl: () => this.forum.attribute('baseUrl'),
|
2020-04-17 17:57:55 +08:00
|
|
|
back: function () {
|
2018-06-20 11:50:31 +08:00
|
|
|
window.location = this.backUrl();
|
2020-04-17 17:57:55 +08:00
|
|
|
},
|
2018-06-20 11:50:31 +08:00
|
|
|
};
|
|
|
|
|
2018-06-22 09:19:46 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
2018-06-20 11:50:31 +08:00
|
|
|
|
2018-06-22 09:19:46 +08:00
|
|
|
routes(this);
|
2018-06-20 11:50:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
mount() {
|
2020-04-17 17:57:55 +08:00
|
|
|
m.mount(document.getElementById('app-navigation'), Navigation.component({ className: 'App-backControl', drawer: true }));
|
2018-06-20 11:50:31 +08:00
|
|
|
m.mount(document.getElementById('header-navigation'), Navigation.component());
|
|
|
|
m.mount(document.getElementById('header-primary'), HeaderPrimary.component());
|
|
|
|
m.mount(document.getElementById('header-secondary'), HeaderSecondary.component());
|
|
|
|
m.mount(document.getElementById('admin-navigation'), AdminNav.component());
|
|
|
|
|
|
|
|
m.route.mode = 'hash';
|
|
|
|
super.mount();
|
|
|
|
|
|
|
|
// If an extension has just been enabled, then we will run its settings
|
|
|
|
// callback.
|
|
|
|
const enabled = localStorage.getItem('enabledExtension');
|
|
|
|
if (enabled && this.extensionSettings[enabled]) {
|
|
|
|
this.extensionSettings[enabled]();
|
|
|
|
localStorage.removeItem('enabledExtension');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getRequiredPermissions(permission) {
|
|
|
|
const required = [];
|
|
|
|
|
|
|
|
if (permission === 'startDiscussion' || permission.indexOf('discussion.') === 0) {
|
|
|
|
required.push('viewDiscussions');
|
|
|
|
}
|
|
|
|
if (permission === 'discussion.delete') {
|
|
|
|
required.push('discussion.hide');
|
|
|
|
}
|
|
|
|
if (permission === 'discussion.deletePosts') {
|
2018-07-15 04:15:40 +08:00
|
|
|
required.push('discussion.hidePosts');
|
2018-06-20 11:50:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return required;
|
2020-04-17 17:57:55 +08:00
|
|
|
}
|
2018-06-20 11:50:31 +08:00
|
|
|
}
|