Refactor components
Implement context mechanism to pass default attributes to descendant components.
This commit is contained in:
1 parent
d46d133878
commit
ee8c43747e
35 files changed
+1903
-1831
No files matched your search
+51
-46
@@ -2,57 +2,62 @@
|
||||
|
||||
import m from "mithril";
|
||||
|
||||
const menu = {
|
||||
view: vnode => {
|
||||
const active = { [vnode.attrs.page]: "active" };
|
||||
export default function menu() {
|
||||
return {
|
||||
view: vnode => {
|
||||
const active = { [vnode.attrs.page]: "active" };
|
||||
|
||||
const tabs = [];
|
||||
if (window.authorizer.hasAccess("devices", 1)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["overview"] },
|
||||
m("a", { href: "#!/overview" }, "Overview")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (window.authorizer.hasAccess("devices", 2)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["devices"] },
|
||||
m("a", { href: "#!/devices" }, "Devices")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (window.authorizer.hasAccess("faults", 2)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["faults"] },
|
||||
m("a", { href: "#!/faults" }, "Faults")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const adminPages = ["presets", "provisions", "virtualParameters", "files"];
|
||||
for (const page of adminPages) {
|
||||
if (window.authorizer.hasAccess(page, 2)) {
|
||||
const tabs = [];
|
||||
if (window.authorizer.hasAccess("devices", 1)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["admin"] },
|
||||
m("a", { href: "#!/admin" }, "Admin")
|
||||
{ class: active["overview"] },
|
||||
m("a", { href: "#!/overview" }, "Overview")
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (window.authorizer.hasAccess("devices", 2)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["devices"] },
|
||||
m("a", { href: "#!/devices" }, "Devices")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (window.authorizer.hasAccess("faults", 2)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["faults"] },
|
||||
m("a", { href: "#!/faults" }, "Faults")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const adminPages = [
|
||||
"presets",
|
||||
"provisions",
|
||||
"virtualParameters",
|
||||
"files"
|
||||
];
|
||||
for (const page of adminPages) {
|
||||
if (window.authorizer.hasAccess(page, 2)) {
|
||||
tabs.push(
|
||||
m(
|
||||
"li",
|
||||
{ class: active["admin"] },
|
||||
m("a", { href: "#!/admin" }, "Admin")
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m("nav", m("ul", tabs));
|
||||
}
|
||||
|
||||
return m("nav", m("ul", tabs));
|
||||
}
|
||||
};
|
||||
|
||||
export default menu;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user