Skip to content
Snippets Groups Projects
Commit d350b66a authored by Matthieu Fesselier's avatar Matthieu Fesselier Committed by Matthieu Fesselier
Browse files

update: add attributes on menu entry

parent a4605153
No related branches found
No related tags found
1 merge request!331feature: experimental menu
...@@ -139,6 +139,52 @@ for component of components ...@@ -139,6 +139,52 @@ for component of components
component.attributes.route = component.route; component.attributes.route = component.route;
component.attributes.uniq = component.uniq; component.attributes.uniq = component.uniq;
} }
if(component.menuAttributes) {
let federation = new Set();
if(client.server) {
federation.add(client.server);
}
if(client.servers) {
for(server of client.servers) {
federation.add(server);
}
}
if(component.federation) {
for(target of component.federation) {
federation.add(target);
}
}
component.federation = [...federation];
for(const [attribute, path] of Object.entries(component.menuAttributes)) {
if(typeof path === 'string') {
if(path.startsWith('federation://')) {
let contains = generateUrl(federation, path);
if(contains.length > 1) {
federations[`store://local.${component.uniq}/${attribute}/`] = {
"@cache": "false",
"@context": "https://cdn.happy-dev.fr/owl/hdcontext.jsonld",
"@type": "ldp:Container",
"@id": `store://local.${component.uniq}/${attribute}/`,
"ldp:contains": contains,
"permissions": [{"mode": {"@type": "view"}}]
};
component.menuAttributes[attribute] = `store://local.${component.uniq}/${attribute}/`;
} else {
component.menuAttributes[attribute] = federation.values().next().value + path.replace(/federation:\//, '');
}
}
if(path.startsWith('server://')) {
component.menuAttributes[attribute] = client.server + path.replace(/server:\//, '');
}
}
}
/* Rewrite every parameters to kebab-case */
let rewriteParameters = {};
for(const [attribute, value] of Object.entries(component.menuAttributes)) {
rewriteParameters[attribute.replace(/((?<=[a-z\d])[A-Z]|(?<=[A-Z\d])[A-Z](?=[a-z]))/g, '-$1').toLowerCase()] = value;
}
component.menuAttributes = rewriteParameters;
}
if(component.extensions) { if(component.extensions) {
for(extension of component.extensions) { for(extension of component.extensions) {
if(extension.parameters) { if(extension.parameters) {
......
...@@ -183,7 +183,7 @@ solid-router#navbar-router(default-route=defaultRoute) ...@@ -183,7 +183,7 @@ solid-router#navbar-router(default-route=defaultRoute)
if component.experimental if component.experimental
if component.experimental.includes('menu') if component.experimental.includes('menu')
div.jsMenuTab div.jsMenuTab
#{"solid-"+component.type+"-menu"} #{"solid-"+component.type+"-menu"}&attributes(component.menuAttributes)
div.divider div.divider
if componentSet.has('registering') if componentSet.has('registering')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment