mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Fix admin_category not showing problem
This commit is contained in:
parent
16c0b7374d
commit
2b25ae027a
@ -170,62 +170,16 @@ define([
|
||||
|
||||
Extensions.getExtensions('HOMEPAGE_POPUP').forEach(_ext => {
|
||||
_ext.then(ext => {
|
||||
ext.getContent(utils, content => {
|
||||
$(popup).append(h('div.cp-extensions-popup', content));
|
||||
resolve();
|
||||
});
|
||||
if (ext) {
|
||||
ext.getContent(utils, content => {
|
||||
$(popup).append(h('div.cp-extensions-popup', content));
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
|
||||
common.getExtensions('ADMIN_CATEGORY').forEach(_ext => {
|
||||
console.log("category")
|
||||
_ext.then(ext => {
|
||||
console.log(ext);
|
||||
if (!ext || !ext.id || !ext.name || !ext.content) {
|
||||
return console.error('Invalid extension point', 'ADMIN_CATEGORY', ext);
|
||||
}
|
||||
if (categories[ext.id]) {
|
||||
return console.error('Extension point ID already used', ext);
|
||||
}
|
||||
console.log("inside category")
|
||||
categories[ext.id] = {
|
||||
icon: ext.icon,
|
||||
name: ext.name,
|
||||
content: ext.content
|
||||
};
|
||||
}).catch(error => console.error("Error loading ADMIN_CATEGORY extension:", error));
|
||||
});
|
||||
|
||||
common.getExtensions('ADMIN_ITEM').forEach(_ext => {
|
||||
console.log("item")
|
||||
_ext.then(ext => {
|
||||
console.log("Loading ADMIN_ITEM extension:", ext); // Added log for debugging
|
||||
if (!ext || !ext.id || typeof(ext.getContent) !== "function") {
|
||||
return console.error('Invalid extension point', 'ADMIN_ITEM', ext);
|
||||
}
|
||||
if (sidebar.hasItem(ext.id)) {
|
||||
return console.error('Extension point ID already used', ext);
|
||||
}
|
||||
|
||||
sidebar.addItem(ext.id, cb => {
|
||||
console.log("inside sidebar")
|
||||
ext.getContent(common, blocks, utils, content => {
|
||||
if (!content) {
|
||||
console.warn("Content is undefined for extension:", ext.id); // Added war
|
||||
}
|
||||
console.log("inside getContent: ", content);
|
||||
cb(content);
|
||||
});
|
||||
}, {
|
||||
noTitle: !ext.title,
|
||||
noHint: !ext.description,
|
||||
title: ext.title,
|
||||
hint: ext.description
|
||||
});
|
||||
}).catch(error => console.error("Error loading ADMIN_ITEM extension:", error));
|
||||
});
|
||||
|
||||
|
||||
|
||||
return [
|
||||
h('div#cp-main', [
|
||||
|
||||
@ -172,23 +172,25 @@ define([
|
||||
const blocks = sidebar.blocks;
|
||||
|
||||
// EXTENSION_POINT:ADMIN_CATEGORY
|
||||
common.getExtensions('ADMIN_CATEGORY').forEach(_ext => {
|
||||
_ext.then(ext => {
|
||||
console.log(ext)
|
||||
if (!ext || !ext.id || !ext.name || !ext.content) {
|
||||
return console.error('Invalid extension point', 'ADMIN_CATEGORY', ext);
|
||||
}
|
||||
if (categories[ext.id]) {
|
||||
return console.error('Extension point ID already used', ext);
|
||||
}
|
||||
//console.error(ext);
|
||||
categories[ext.id] = {
|
||||
icon: ext.icon,
|
||||
name: ext.name,
|
||||
content: ext.content
|
||||
};
|
||||
}).catch(error => console.error("Error loading ADMIN_CATEGORY extension:", error));
|
||||
});
|
||||
async function processExtensions(id) {
|
||||
const extensions = await common.getExtensions(id);
|
||||
extensions.forEach(_ext => {
|
||||
_ext.then(ext => {
|
||||
if (!ext || !ext.id || !ext.name || !ext.content) {
|
||||
return console.error('Invalid extension point', 'ADMIN_CATEGORY', ext);
|
||||
}
|
||||
if (categories[ext.id]) {
|
||||
return console.error('Extension point ID already used', ext);
|
||||
}
|
||||
categories[ext.id] = {
|
||||
icon: ext.icon,
|
||||
name: ext.name,
|
||||
content: ext.content
|
||||
};
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const flushCache = (cb) => {
|
||||
cb = cb || function () {};
|
||||
@ -3930,15 +3932,14 @@ define([
|
||||
h, Util, Hash
|
||||
};
|
||||
common.getExtensions('ADMIN_ITEM').forEach(_ext => {
|
||||
// console.log("item")
|
||||
_ext.then(ext => {
|
||||
console.log(ext);
|
||||
if (!ext || !ext.id || typeof(ext.getContent) !== "function") {
|
||||
return console.error('Invalid extension point', 'ADMIN_CATEGORY', ext);
|
||||
}
|
||||
if (sidebar.hasItem(ext.id)) {
|
||||
return console.error('Extension point ID already used', ext);
|
||||
}
|
||||
|
||||
sidebar.addItem(ext.id, cb => {
|
||||
ext.getContent(common, blocks, utils, content => {
|
||||
console.log("Generated content for", ext.id, ":", content);
|
||||
@ -3953,9 +3954,10 @@ define([
|
||||
}).catch(error => console.error("Error loading ADMIN_CATEGORY extension:", error));
|
||||
});
|
||||
|
||||
|
||||
|
||||
sidebar.makeLeftside(categories);
|
||||
(async () => {
|
||||
await processExtensions('ADMIN_CATEGORY');
|
||||
sidebar.makeLeftside(categories);
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -11,22 +11,26 @@ define([
|
||||
let e = ext[id];
|
||||
if (!Array.isArray(e)) { e = []; }
|
||||
return e.map(_ext => {
|
||||
return new Promise((resolve) => {
|
||||
if (typeof _ext.check === "function") {
|
||||
const checkResult = _ext.check();
|
||||
if (checkResult && typeof checkResult.then === "function") {
|
||||
checkResult.then(() => {
|
||||
resolve(_ext);
|
||||
}).catch(() => {
|
||||
console.error("Check failed for extension:", _ext);
|
||||
resolve(null);
|
||||
});
|
||||
} else {
|
||||
resolve(_ext);
|
||||
}
|
||||
} else {
|
||||
resolve(_ext);
|
||||
return new Promise((resolve, reject) => {
|
||||
// If there's no check function, resolve immediately
|
||||
if (typeof _ext.check !== "function") {
|
||||
return resolve(_ext);
|
||||
}
|
||||
const checkResult = _ext.check();
|
||||
|
||||
checkResult
|
||||
.then((extPassed) => {
|
||||
if (!extPassed) {
|
||||
// Reject if the check didn't pass
|
||||
resolve(null);
|
||||
} else {
|
||||
// Extension passed the check
|
||||
resolve(_ext);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user