Skip to content

Commit

Permalink
refactor!: Remove permissions manager from dev plugin settings in Adm…
Browse files Browse the repository at this point in the history
…inCP
  • Loading branch information
aXenDeveloper committed Dec 31, 2024
1 parent 451ebf4 commit d3c9a87
Show file tree
Hide file tree
Showing 41 changed files with 50 additions and 1,077 deletions.
13 changes: 0 additions & 13 deletions apps/backend/src/plugins/welcome/config.json

This file was deleted.

31 changes: 31 additions & 0 deletions apps/backend/src/plugins/welcome/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "Welcome",
"description": "Basic plugin with default page.",
"version": "1.0.0",
"version_code": 1,
"code": "welcome",
"author": "VitNode",
"author_url": "https://vitnode.com/",
"support_url": "https://github.com/VitNode/vitnode/issues",
"allow_default": true,
"nav": [
{
"code": "test123",
"icon": "air-vent",
"keywords": ["test"],
"children": [
{
"code": "saougfj",
"icon": "😍",
"keywords": []
}
]
}
],
"permissions_admin": [
{
"id": "test",
"permissions": ["test123"]
}
]
}
26 changes: 0 additions & 26 deletions apps/frontend/src/plugins/admin/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,32 +357,6 @@
"success": "Navigation has been deleted."
}
},
"permissions-admin": {
"title": "Admin Permissions",
"page_permission": "Page: <page></page>",
"lang_key": "Lang Key: <key></key>",
"create_edit": {
"id": {
"label": "ID",
"desc": "Unique ID for this permission.",
"exists": "Permission with this ID already exists."
},
"parent": {
"label": "Group",
"null": "No group permission"
},
"create_success": "Permission has been created."
},
"delete": {
"desc": "This action will delete the permission <id></id>. Remember to delete all conditions associated with this permission.",
"submit": "Yes, delete permission",
"success": "Permission has been deleted.",
"children_warn": {
"title": "This permission has children",
"desc": "If you delete this permission, all children will be deleted too."
}
}
},
"export": {
"title": "Export Plugin",
"desc": "Choose version to export.",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/scripts/update-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export const updatePlugins = async ({
await Promise.all(
plugins.map(async (code, index) => {
const pluginPath = join(pluginsPath, code);
const configPath = join(pluginPath, 'config.json');
const configPath = join(pluginPath, 'metadata.json');
if (!existsSync(configPath)) {
return;
}

const config = JSON.parse(
await readFile(join(pluginPath, 'config.json'), 'utf8'),
await readFile(join(pluginPath, 'metadata.json'), 'utf8'),
);

if (config.allow_default) {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ABSOLUTE_PATHS = {
plugin: ({ code }: { code: string }) => ({
root: join(internalPaths.plugins, code),
admin: join(internalPaths.plugins, code, 'admin'),
config: join(internalPaths.plugins, code, 'config.json'),
metadata: join(internalPaths.plugins, code, 'metadata.json'),
database: join(internalPaths.plugins, code, 'admin', 'database'),
shared: join(internalPaths.shared, code),
frontend: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class NavAuthAdminService {

const navFromPlugins = await Promise.all(
adminNavPlugins.map(async ({ code }) => {
const pathConfig = ABSOLUTE_PATHS.plugin({ code }).config;
const pathConfig = ABSOLUTE_PATHS.plugin({ code }).metadata;
if (!existsSync(pathConfig)) {
return {
code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ export class TranslateAiLanguagesAdminService {
Task: Translate the content below from en to ${code}.
Translation Requirements:
- If the content is already translated and it is correct, do not change it,
- Do not translate the code,
- Maintain exact file structure, indentation, and formatting,
- Preserve all object/property keys, syntax characters, and punctuation marks exactly,
- Keep consistent capitalization, spacing, and line breaks,
- Match source file's JSON/object structure precisely,
- Wrap return JSON in \`\`\`json code block.
Important: Skip translation if is already translated (and not identical to source).
Source content (en):
${JSON.stringify(textLang, null, 2)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ShowAdminStaffMembersAdminService {
plugin => {
const pathConfig = ABSOLUTE_PATHS.plugin({
code: plugin.code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
return {
plugin_code: plugin.code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ChangePositionNavPluginsAdminService extends HelpersAdminNavPlugins
}): Promise<void> {
const pathConfig = ABSOLUTE_PATHS.plugin({
code: plugin_code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
throw new NotFoundException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CreateNavPluginsAdminService extends HelpersAdminNavPluginsService
}): Promise<ParentNavAuthAdminObj> {
const pathConfig = ABSOLUTE_PATHS.plugin({
code: plugin_code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
throw new NotFoundException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DeleteNavPluginsAdminService {
}): Promise<void> {
const pathConfig = ABSOLUTE_PATHS.plugin({
code: plugin_code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
throw new NotFoundException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class EditNavPluginsAdminService {
}): Promise<ParentNavAuthAdminObj> {
const pathConfig = ABSOLUTE_PATHS.plugin({
code: plugin_code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
throw new NotFoundException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ShowNavPluginsAdminService {
async show(code: string): Promise<ParentNavAuthAdminObj[]> {
const pathConfig = ABSOLUTE_PATHS.plugin({
code,
}).config;
}).metadata;
if (!existsSync(pathConfig)) {
throw new NotFoundException();
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d3c9a87

Please sign in to comment.