Skip to content

Commit

Permalink
fix: admin app
Browse files Browse the repository at this point in the history
  • Loading branch information
YUCLing committed Dec 7, 2024
1 parent e03d4e5 commit 65b66e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
17 changes: 7 additions & 10 deletions framework/core/js/src/admin/AdminApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,13 @@ export default class AdminApplication extends Application {
// we need to go to https://example.com/admin#/ explicitly.
if (!document.location.hash) document.location.hash = '#/';

m.route.prefix = '#';
super.mount();

m.mount(document.getElementById('app-navigation')!, {
view: () => <Navigation className="App-backControl" drawer />,
});
m.mount(document.getElementById('header-navigation')!, Navigation);
m.mount(document.getElementById('header-primary')!, HeaderPrimary);
m.mount(document.getElementById('header-secondary')!, HeaderSecondary);
m.mount(document.getElementById('admin-navigation')!, AdminNav);
super.mount('#');

m.mount(document.getElementById('app-navigation')!, () => <Navigation className="App-backControl" drawer />);
m.mount(document.getElementById('header-navigation')!, () => <Navigation />);
m.mount(document.getElementById('header-primary')!, () => <HeaderPrimary />);
m.mount(document.getElementById('header-secondary')!, () => <HeaderSecondary />);
m.mount(document.getElementById('admin-navigation')!, () => <AdminNav />);
}

getRequiredPermissions(permission: string) {
Expand Down
4 changes: 2 additions & 2 deletions framework/core/js/src/common/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export default class Application {
});
}

protected mount(basePath: string = '') {
protected mount(routePrefix = '/', basePath: string = '') {
// An object with a callable view property is used in order to pass arguments to the component; see https://mithril.js.org/mount.html
this.redraw.modal = m.mount(document.getElementById('modal')!, () => <ModalManager state={this.modal} />);
this.redraw.alert = m.mount(document.getElementById('alerts')!, () => <AlertManager state={this.alerts} />);
Expand All @@ -357,7 +357,7 @@ export default class Application {
let lastRoute: string;
let comp: Component | null = null;
function RoutedApp() {
return () => m.route('/', ({route}) => {
return () => m.route(routePrefix, ({route}) => {
for (const k in routes) {
let match;
if (match = route.match(k)) {
Expand Down
4 changes: 2 additions & 2 deletions framework/core/js/src/common/utils/patchMithril.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ export default function patchMithril(global) {
}

modifiedMithril.route.param = function (k) {
console.warn('m.route.param is not available in v3');
console.warn('m.route.param is not available in v3, falling back to managed routing');
return app.routing.params[k];
}

modifiedMithril.route.get = function () {
console.warn('m.route.get is not available in v3');
console.warn('m.route.get is not available in v3, falling back to managed routing');
return app.routing.current;
}

Expand Down

0 comments on commit 65b66e2

Please sign in to comment.