Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// Generated, do not edit. sha256:4950de4d7773457ba3e059bdd6064ec381481cef089a6220acf9873b2bbee2e1
|
||||
import { ROUTE_KEYS, SYSTEM_PAGE } from '../shared/config.js';
|
||||
import { createRegistry } from '../shared/registry.js';
|
||||
import { locked } from './license.js';
|
||||
import { systemTabs } from './pages/system-tabs.js';
|
||||
|
||||
const routes = createRegistry('route', {
|
||||
validate: (e) => { if (!Object.values(ROUTE_KEYS).includes(e.id)) throw new Error(`Unknown route '${e.id}'.`); },
|
||||
});
|
||||
|
||||
export function registerRoute(key, page, { feature = null } = {}) {
|
||||
routes.register({ id: key, page, feature });
|
||||
}
|
||||
|
||||
export function routePage(key) {
|
||||
const r = routes.get(key);
|
||||
return r && !(r.feature && locked(r.feature)) ? r.page : null;
|
||||
}
|
||||
|
||||
export function placeAvailable(target) {
|
||||
if (!target?.route) return false;
|
||||
if (!routePage(target.route) && !routePage(target.route.split('/')[0])) return false;
|
||||
if (target.route !== SYSTEM_PAGE.ROUTE || !target.tab) return true;
|
||||
const tab = systemTabs().find(t => t.id === target.tab);
|
||||
return !!tab && (!target.sub || !tab.subs || tab.subs.includes(target.sub));
|
||||
}
|
||||
Reference in new issue
Block a user