diff --git a/js/src/admin/components/Page.tsx b/js/src/admin/components/Page.tsx index a35499851..648049fe8 100644 --- a/js/src/admin/components/Page.tsx +++ b/js/src/admin/components/Page.tsx @@ -1,34 +1,3 @@ -import Component from '../../common/Component'; +import Page from '../../common/components/Page'; -/** - * The `Page` component - */ -export default abstract class Page extends Component { - /** - * A class name to apply to the body while the route is active. - */ - bodyClass: string = ''; - - oninit(vnode) { - super.oninit(vnode); - - if (this.bodyClass) { - $('#app').addClass(this.bodyClass); - } - } - - oncreate(vnode) { - super.oncreate(vnode); - - app.previous = app.current; - app.current = this; - - app.modal.close(); - } - - onremove(vnode) { - super.onremove(vnode); - - $('#app').removeClass(this.bodyClass); - } -} +export default Page; diff --git a/js/src/common/Application.ts b/js/src/common/Application.ts index 7b335f60a..8286749e3 100644 --- a/js/src/common/Application.ts +++ b/js/src/common/Application.ts @@ -20,12 +20,13 @@ import Group from './models/Group'; import Notification from './models/Notification'; import Alert from './components/Alert'; +import AlertManager from './components/AlertManager'; import Button from './components/Button'; import ModalManager from './components/ModalManager'; +import Page from './components/Page'; import RequestErrorModal from './components/RequestErrorModal'; import flattenDeep from 'lodash/flattenDeep'; -import AlertManager from './components/AlertManager'; export type ApplicationData = { apiDocument: any; @@ -107,6 +108,9 @@ export default abstract class Application { modal!: ModalManager; alerts!: AlertManager; + current?: Page; + previous?: Page; + load(payload) { this.data = payload; this.translator.locale = payload.locale; diff --git a/js/src/common/components/Page.tsx b/js/src/common/components/Page.tsx new file mode 100644 index 000000000..39da0cda9 --- /dev/null +++ b/js/src/common/components/Page.tsx @@ -0,0 +1,34 @@ +import Component from '../../common/Component'; + +/** + * The `Page` component + */ +export default abstract class Page extends Component { + /** + * A class name to apply to the body while the route is active. + */ + bodyClass: string = ''; + + oninit(vnode) { + super.oninit(vnode); + + app.previous = app.current; + app.current = this; + + if (this.bodyClass) { + $('#app').addClass(this.bodyClass); + } + } + + oncreate(vnode) { + super.oncreate(vnode); + + app.modal.close(); + } + + onremove(vnode) { + super.onremove(vnode); + + $('#app').removeClass(this.bodyClass); + } +} diff --git a/js/src/forum/components/Page.tsx b/js/src/forum/components/Page.tsx index 5e93c10fa..2582ddc87 100644 --- a/js/src/forum/components/Page.tsx +++ b/js/src/forum/components/Page.tsx @@ -1,35 +1,9 @@ -import Component from '../../common/Component'; - -/** - * The `Page` component - */ -export default abstract class Page extends Component { - /** - * A class name to apply to the body while the route is active. - */ - bodyClass: string = ''; - - oninit(vnode) { - super.oninit(vnode); - - if (this.bodyClass) { - $('#app').addClass(this.bodyClass); - } - } +import CommonPage from '../../common/components/Page'; +export default abstract class Page extends CommonPage { oncreate(vnode) { super.oncreate(vnode); - app.previous = app.current; - app.current = this; - app.drawer.hide(); - app.modal.close(); - } - - onremove(vnode) { - super.onremove(vnode); - - $('#app').removeClass(this.bodyClass); } }