From 6a054017127d9217a158a56de2f1d5bf5f8dcec6 Mon Sep 17 00:00:00 2001 From: aXenDeveloper Date: Mon, 9 Dec 2024 10:59:13 +0100 Subject: [PATCH] feat: Add export plugin button in dev mode in AdminCP --- apps/frontend/src/plugins/admin/langs/en.json | 30 ++-- .../core/admin/plugins/nav/nav.controller.ts | 1 + .../permissions-admin.controller.ts | 1 + .../core/admin/plugins/plugins.controller.ts | 7 +- .../admin/plugins/services/export.service.ts | 44 +++--- .../src/helpers/controller.decorator.ts | 7 + packages/backend/src/main.ts | 1 + packages/frontend/src/api/fetcher-client.ts | 4 + .../data-table/toolbar/filter/filter.tsx | 4 +- .../frontend/src/components/editor/editor.tsx | 4 +- .../src/components/ui/alert-dialog.tsx | 4 +- .../frontend/src/components/ui/carousel.tsx | 4 +- packages/frontend/src/components/ui/chart.tsx | 4 +- .../frontend/src/components/ui/dialog.tsx | 4 +- packages/frontend/src/components/ui/form.tsx | 8 +- packages/frontend/src/components/ui/sheet.tsx | 4 +- .../frontend/src/components/ui/sidebar.tsx | 4 +- .../src/components/ui/toggle-group.tsx | 4 +- .../src/views/admin/layout/wrapper.tsx | 4 +- .../core/plugins/actions/create/create.tsx | 2 +- .../core/plugins/dev/hooks/use-dev-plugin.ts | 16 +- .../plugins/dev/layout/export/content.tsx | 143 ++++++++++++++++++ .../core/plugins/dev/layout/export/export.tsx | 47 ++++++ .../views/core/plugins/dev/layout/layout.tsx | 12 +- .../views/core/plugins/dev/layout/wrapper.tsx | 11 +- .../views/core/plugins/dev/nav/content.tsx | 4 +- .../hooks/use-create-nav-plugin-admin.ts | 8 +- .../hooks/use-delete-nav-plugin-admin.ts | 2 +- .../views/core/plugins/dev/nav/item/item.tsx | 6 +- ...eate-edit-permission-admin-plugin-admin.ts | 6 +- ...se-delete-permission-admin-plugin-admin.ts | 4 +- .../dev/permissions-admin/item/item.tsx | 6 +- .../admin/views/core/plugins/dev/tabs.tsx | 14 +- .../core/styles/theme-editor/wrapper.tsx | 6 +- .../src/views/layout/auth/wrapper.tsx | 4 +- .../frontend/src/views/layout/providers.tsx | 4 +- .../theme/views/auth/sign/up/wrapper.tsx | 4 +- packages/shared/src/admin/plugins.dto.ts | 2 +- 38 files changed, 340 insertions(+), 104 deletions(-) create mode 100644 packages/frontend/src/views/admin/views/core/plugins/dev/layout/export/content.tsx create mode 100644 packages/frontend/src/views/admin/views/core/plugins/dev/layout/export/export.tsx diff --git a/apps/frontend/src/plugins/admin/langs/en.json b/apps/frontend/src/plugins/admin/langs/en.json index 46ddc1b77..7dc29fa0f 100644 --- a/apps/frontend/src/plugins/admin/langs/en.json +++ b/apps/frontend/src/plugins/admin/langs/en.json @@ -299,9 +299,7 @@ "desc": "We're detected changes in the plugin system. To apply these changes, you need to restart the server." }, "dev": { - "overview": { - "title": "Overview" - }, + "overview": "Overview", "nav": { "title": "Navigation in AdminCP", "lang_key": "Lang Key: ", @@ -363,6 +361,18 @@ "desc": "If you delete this permission, all children will be deleted too." } } + }, + "export": { + "title": "Export Plugin", + "desc": "Choose version to export.", + "type": { + "rebuild": "Rebuild current version - {version}", + "new_version": "Create new version" + }, + "version": "Version", + "version_code": "Version Code", + "success": "Plugin has been exported.", + "submit": "Export" } }, "create": { @@ -411,20 +421,6 @@ "submit": "Yes, delete plugin", "desc": "This action will delete plugin created by and all data associated with it.", "info": "After the process is complete, you need to restart the server to apply the changes." - }, - "download": { - "title": "Download Plugin", - "type": { - "rebuild": "Rebuild current version - {version}", - "new_version": "Create new version" - }, - "version": { - "label": "Version" - }, - "version_code": { - "label": "Version Code" - }, - "submit": "Download" } }, "styles": { diff --git a/packages/backend/src/core/admin/plugins/nav/nav.controller.ts b/packages/backend/src/core/admin/plugins/nav/nav.controller.ts index f31822ae5..8f2eb159f 100644 --- a/packages/backend/src/core/admin/plugins/nav/nav.controller.ts +++ b/packages/backend/src/core/admin/plugins/nav/nav.controller.ts @@ -19,6 +19,7 @@ import { ShowNavPluginsAdminService } from './services/show.service'; plugin_code: 'plugins', isAdmin: true, route: 'nav', + isDev: true, }) export class NavPluginsAdminController { constructor( diff --git a/packages/backend/src/core/admin/plugins/permissions-admin/permissions-admin.controller.ts b/packages/backend/src/core/admin/plugins/permissions-admin/permissions-admin.controller.ts index 98ff14a21..ae0d4338f 100644 --- a/packages/backend/src/core/admin/plugins/permissions-admin/permissions-admin.controller.ts +++ b/packages/backend/src/core/admin/plugins/permissions-admin/permissions-admin.controller.ts @@ -17,6 +17,7 @@ import { ShowPermissionsAdminPluginsAdminService } from './services/show.service plugin_code: 'plugins', isAdmin: true, route: 'permissions-admin', + isDev: true, }) export class PermissionsAdminPluginsAdminController { constructor( diff --git a/packages/backend/src/core/admin/plugins/plugins.controller.ts b/packages/backend/src/core/admin/plugins/plugins.controller.ts index 540999560..bed52506e 100644 --- a/packages/backend/src/core/admin/plugins/plugins.controller.ts +++ b/packages/backend/src/core/admin/plugins/plugins.controller.ts @@ -1,5 +1,6 @@ import type { Response } from 'express'; +import { OnlyForDevelopment } from '@/guards/dev.guard'; import { Controllers } from '@/helpers/controller.decorator'; import { Body, @@ -10,6 +11,7 @@ import { Put, Query, Res, + UseGuards, } from '@nestjs/common'; import { ApiCreatedResponse, ApiOkResponse } from '@nestjs/swagger'; import { EditPluginsAdminBody } from 'vitnode-shared/admin/plugin.dto'; @@ -41,6 +43,7 @@ export class PluginsAdminController { @ApiCreatedResponse({ description: 'Plugin created', type: ShowPluginAdmin }) @Post() + @UseGuards(OnlyForDevelopment) async createPlugin( @Body() body: CreatePluginsAdminBody, ): Promise { @@ -49,6 +52,7 @@ export class PluginsAdminController { @ApiOkResponse({ description: 'Plugin deleted' }) @Delete(':id') + @UseGuards(OnlyForDevelopment) async deletePlugin(@Param('id') id: string): Promise { await this.deleteService.delete(+id); } @@ -66,7 +70,8 @@ export class PluginsAdminController { } @ApiOkResponse({ description: 'Plugin exported' }) - @Post('export/:code') + @Post(':code/export') + @UseGuards(OnlyForDevelopment) async exportPlugin( @Param('code') code: string, @Body() body: ExportPluginsAdminBody, diff --git a/packages/backend/src/core/admin/plugins/services/export.service.ts b/packages/backend/src/core/admin/plugins/services/export.service.ts index 65e403c60..8ac2e2dcd 100644 --- a/packages/backend/src/core/admin/plugins/services/export.service.ts +++ b/packages/backend/src/core/admin/plugins/services/export.service.ts @@ -55,6 +55,17 @@ export class ExportPluginsAdminService { }); } + // Check if version_code is greater than the current version_code + if ( + version_code && + configJSON.version_code && + version_code <= configJSON.version_code + ) { + return res.status(400).json({ + message: 'Version code must be greater than the current version code', + }); + } + configJSON.allow_default = allow_default; configJSON.version = version ?? configJSON.version; configJSON.version_code = version_code ?? configJSON.version_code; @@ -70,23 +81,21 @@ export class ExportPluginsAdminService { updated_at: new Date(), }) .where(eq(core_plugins.code, code)); - - return; + } else { + await this.databaseService.db + .update(core_plugins) + .set({ + version, + version_code, + allow_default, + updated_at: new Date(), + }) + .where(eq(core_plugins.code, code)); } - await this.databaseService.db - .update(core_plugins) - .set({ - version, - version_code, - allow_default, - updated_at: new Date(), - }) - .where(eq(core_plugins.code, code)); - // Prepare the export const tempFolderName = removeSpecialCharacters( - `${code}-${version}-${generateRandomString(5)}-${currentUnixDate()}`, + `${code}-${version ?? plugin.version}-${generateRandomString(5)}-${currentUnixDate()}`, ); const tempPath = join(this.tempPath, tempFolderName); await mkdir(tempPath, { recursive: true }); @@ -135,10 +144,11 @@ export class ExportPluginsAdminService { // Copy shared files const sharedSource = ABSOLUTE_PATHS.plugin({ code }).shared; - if (!existsSync(sharedSource)) return; - const sharedPath = join(tempPath, 'shared'); - await mkdir(sharedPath, { recursive: true }); - await cp(sharedSource, sharedPath, { recursive: true }); + if (existsSync(sharedSource)) { + const sharedPath = join(tempPath, 'shared'); + await mkdir(sharedPath, { recursive: true }); + await cp(sharedSource, sharedPath, { recursive: true }); + } // Create tar const file = join(ABSOLUTE_PATHS.uploads.temp, `${tempFolderName}.tgz`); diff --git a/packages/backend/src/helpers/controller.decorator.ts b/packages/backend/src/helpers/controller.decorator.ts index 08537b675..ac78788ab 100644 --- a/packages/backend/src/helpers/controller.decorator.ts +++ b/packages/backend/src/helpers/controller.decorator.ts @@ -1,9 +1,11 @@ import { AdminAuthGuard } from '@/guards/admin-auth.guard'; import { AuthGuard } from '@/guards/auth.guard'; +import { OnlyForDevelopment } from '@/guards/dev.guard'; import { applyDecorators, Controller, UseGuards } from '@nestjs/common'; import { ApiSecurity, ApiTags } from '@nestjs/swagger'; interface Args { + isDev?: boolean; plugin_code: string; plugin_name: string; route?: string; @@ -30,9 +32,14 @@ export function Controllers({ isAdmin, isProtect, route, + isDev, }: ArgsWithAdmin | ArgsWithout | ArgsWithProtect) { const decorators = [Controller(`${plugin_code}${route ? `/${route}` : ''}`)]; + if (isDev) { + decorators.push(UseGuards(OnlyForDevelopment)); + } + if (isAdmin) { decorators.push( ApiTags(`Admin - ${plugin_name}`), diff --git a/packages/backend/src/main.ts b/packages/backend/src/main.ts index 971be240a..c2903cfaf 100644 --- a/packages/backend/src/main.ts +++ b/packages/backend/src/main.ts @@ -22,6 +22,7 @@ export const nestjsMainApp = async (app: INestApplication, options?: Args) => { app.enableCors({ ...options?.cors, credentials: true, + exposedHeaders: ['Content-Disposition'], origin: [ process.env.NEXT_PUBLIC_FRONTEND_URL ?? 'http://localhost:3000', ...(options?.cors?.origin ?? []), diff --git a/packages/frontend/src/api/fetcher-client.ts b/packages/frontend/src/api/fetcher-client.ts index de51d2bca..236b5bcbc 100644 --- a/packages/frontend/src/api/fetcher-client.ts +++ b/packages/frontend/src/api/fetcher-client.ts @@ -40,6 +40,10 @@ export async function fetcherClient< : null, }); + if (res.headers.get('Content-Disposition')) { + return { res, data: {} as TData }; + } + let data = {} as TData; try { data = await res.json(); diff --git a/packages/frontend/src/components/data-table/toolbar/filter/filter.tsx b/packages/frontend/src/components/data-table/toolbar/filter/filter.tsx index 68971470a..0623f28b6 100644 --- a/packages/frontend/src/components/data-table/toolbar/filter/filter.tsx +++ b/packages/frontend/src/components/data-table/toolbar/filter/filter.tsx @@ -52,11 +52,11 @@ export function FilterToolbarDataTable({ - + }> {children} - + ); diff --git a/packages/frontend/src/components/editor/editor.tsx b/packages/frontend/src/components/editor/editor.tsx index 97644c33f..0eaa489bb 100644 --- a/packages/frontend/src/components/editor/editor.tsx +++ b/packages/frontend/src/components/editor/editor.tsx @@ -234,7 +234,7 @@ export const Editor = ({ if (!editor) return null; return ( - - + ); }; diff --git a/packages/frontend/src/components/ui/alert-dialog.tsx b/packages/frontend/src/components/ui/alert-dialog.tsx index 221eaad07..42d907e47 100644 --- a/packages/frontend/src/components/ui/alert-dialog.tsx +++ b/packages/frontend/src/components/ui/alert-dialog.tsx @@ -27,7 +27,7 @@ const AlertDialog = ({ const [open, setOpen] = React.useState(false); return ( - {children} - + ); }; diff --git a/packages/frontend/src/components/ui/carousel.tsx b/packages/frontend/src/components/ui/carousel.tsx index 90b54e3fc..45fa6c287 100644 --- a/packages/frontend/src/components/ui/carousel.tsx +++ b/packages/frontend/src/components/ui/carousel.tsx @@ -102,7 +102,7 @@ function Carousel({ }, [api, onSelect]); return ( - {children} - + ); } diff --git a/packages/frontend/src/components/ui/chart.tsx b/packages/frontend/src/components/ui/chart.tsx index b85d7b105..2a4551167 100644 --- a/packages/frontend/src/components/ui/chart.tsx +++ b/packages/frontend/src/components/ui/chart.tsx @@ -50,7 +50,7 @@ const ChartContainer = ({ const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`; return ( - +
-
+ ); }; diff --git a/packages/frontend/src/components/ui/dialog.tsx b/packages/frontend/src/components/ui/dialog.tsx index 6e2a7e821..f6be07d45 100644 --- a/packages/frontend/src/components/ui/dialog.tsx +++ b/packages/frontend/src/components/ui/dialog.tsx @@ -31,7 +31,7 @@ const Dialog = ({ const [isDirty, setIsDirty] = React.useState(false); return ( - { @@ -50,7 +50,7 @@ const Dialog = ({ > {children} - + ); }; diff --git a/packages/frontend/src/components/ui/form.tsx b/packages/frontend/src/components/ui/form.tsx index d8d429744..f14c278bc 100644 --- a/packages/frontend/src/components/ui/form.tsx +++ b/packages/frontend/src/components/ui/form.tsx @@ -67,9 +67,9 @@ const FormField = < ...props }: ControllerProps) => { return ( - + - + ); }; @@ -111,9 +111,9 @@ const FormItem = ({ const id = React.useId(); return ( - +
- + ); }; diff --git a/packages/frontend/src/components/ui/sheet.tsx b/packages/frontend/src/components/ui/sheet.tsx index e80672912..9cb8ddd02 100644 --- a/packages/frontend/src/components/ui/sheet.tsx +++ b/packages/frontend/src/components/ui/sheet.tsx @@ -28,7 +28,7 @@ const Sheet = ({ const [open, setOpen] = React.useState(false); return ( - {children} - + ); }; diff --git a/packages/frontend/src/components/ui/sidebar.tsx b/packages/frontend/src/components/ui/sidebar.tsx index 495115e10..db5492da0 100644 --- a/packages/frontend/src/components/ui/sidebar.tsx +++ b/packages/frontend/src/components/ui/sidebar.tsx @@ -129,7 +129,7 @@ const SidebarProvider = ({ ); return ( - +
- + ); }; diff --git a/packages/frontend/src/components/ui/toggle-group.tsx b/packages/frontend/src/components/ui/toggle-group.tsx index 658c4d6fe..1a0601eba 100644 --- a/packages/frontend/src/components/ui/toggle-group.tsx +++ b/packages/frontend/src/components/ui/toggle-group.tsx @@ -26,9 +26,9 @@ const ToggleGroup = ({ className={cn('flex items-center justify-center gap-1', className)} {...props} > - + {children} - + ); diff --git a/packages/frontend/src/views/admin/layout/wrapper.tsx b/packages/frontend/src/views/admin/layout/wrapper.tsx index 0a5f1a0a4..7db2d2417 100644 --- a/packages/frontend/src/views/admin/layout/wrapper.tsx +++ b/packages/frontend/src/views/admin/layout/wrapper.tsx @@ -30,8 +30,8 @@ export const WrapperAdminLayout = ({ }; return ( - + {children} - + ); }; diff --git a/packages/frontend/src/views/admin/views/core/plugins/actions/create/create.tsx b/packages/frontend/src/views/admin/views/core/plugins/actions/create/create.tsx index 8637f117f..50b545e8f 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/actions/create/create.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/actions/create/create.tsx @@ -28,7 +28,7 @@ export const CreateActionPluginAdmin = () => { return ( } + /> + ); +}; diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/layout/export/export.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/export/export.tsx new file mode 100644 index 000000000..24be1aa40 --- /dev/null +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/export/export.tsx @@ -0,0 +1,47 @@ +'use client'; + +import { Button } from '@/components/ui/button'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog'; +import { Loader } from '@/components/ui/loader'; +import { DownloadIcon } from 'lucide-react'; +import { useTranslations } from 'next-intl'; +import React from 'react'; + +const Content = React.lazy(async () => + import('./content').then(module => ({ + default: module.ContentExportActionDevPluginAdmin, + })), +); + +export const ExportActionDevPluginAdmin = () => { + const t = useTranslations('admin.core.plugins.dev.export'); + + return ( + + + + + + + + {t('title')} + {t('desc')} + + + }> + + + + + ); +}; diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/layout/layout.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/layout.tsx index d1e3702e3..19279e68c 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/layout/layout.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/layout.tsx @@ -11,6 +11,7 @@ import React from 'react'; import { getPluginDataAdmin } from '../query-api'; import { TabsDevPluginAdmin } from '../tabs'; +import { ExportActionDevPluginAdmin } from './export/export'; import { WrapperDevPluginAdminLayout } from './wrapper'; interface Props { @@ -49,7 +50,14 @@ export const DevPluginAdminLayout = async ({ code, children }: Props) => { ]); return ( - + @@ -85,7 +93,7 @@ export const DevPluginAdminLayout = async ({ code, children }: Props) => {
} > - {/* */} + {CONFIG.node_development && } diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/layout/wrapper.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/wrapper.tsx index 6d116c8b6..bd3d75950 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/layout/wrapper.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/layout/wrapper.tsx @@ -1,16 +1,19 @@ 'use client'; -import { DevPluginAdminContext } from '../hooks/use-dev-plugin'; +import { + DevPluginAdminContext, + DevPluginAdminContextArgs, +} from '../hooks/use-dev-plugin'; export const WrapperDevPluginAdminLayout = ({ children, - pluginCode, + data, }: { children: React.ReactNode; - pluginCode: string; + data: DevPluginAdminContextArgs; }) => { return ( - + {children} ); diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/content.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/content.tsx index 23bb9b630..d958d0baf 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/content.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/content.tsx @@ -19,7 +19,7 @@ export const ContentNavDevPluginAdmin = ({ textsAndIcons: TextAndIconsAsideAdmin[]; }) => { const t = useTranslations('core.global.errors'); - const { pluginCode } = useDevPluginAdmin(); + const { code } = useDevPluginAdmin(); return ( , form: UseFormReturn>, ) => { - if (!pluginCode) return; - try { if (data) { await editMutationApi({ ...values, previous_code: data.code, - plugin_code: pluginCode, + plugin_code: code, parent_code: values.parent_code === 'null' ? undefined : values.parent_code, keywords: (values.keywords ?? []).map(keyword => keyword.value), @@ -65,7 +63,7 @@ export const useCreateNavPluginAdmin = ({ } else { await createMutationApi({ ...values, - plugin_code: pluginCode, + plugin_code: code, parent_code: values.parent_code === 'null' ? undefined : values.parent_code, keywords: (values.keywords ?? []).map(keyword => keyword.value), diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/actions/delete/hooks/use-delete-nav-plugin-admin.ts b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/actions/delete/hooks/use-delete-nav-plugin-admin.ts index 94e7dcf57..96149923a 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/actions/delete/hooks/use-delete-nav-plugin-admin.ts +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/actions/delete/hooks/use-delete-nav-plugin-admin.ts @@ -13,7 +13,7 @@ export const useDeleteNavPluginAdmin = ({ const t = useTranslations('admin.core.plugins.dev.nav.delete'); const tCore = useTranslations('core.global.errors'); const { setOpen } = useAlertDialog(); - const { pluginCode } = useDevPluginAdmin(); + const { code: pluginCode } = useDevPluginAdmin(); const onSubmit = async () => { try { diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/item.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/item.tsx index 8ec9b8c47..cadc52b36 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/item.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/nav/item/item.tsx @@ -16,7 +16,7 @@ export const ItemContentNavDevPluginAdmin = ({ parentId?: string; textsAndIcons: TextAndIconsAsideAdmin[]; }) => { - const { pluginCode } = useDevPluginAdmin(); + const { code } = useDevPluginAdmin(); const tAdmin = useTranslations('admin.core.plugins.dev.nav'); const langKey = parentId ? `${parentId}_${data.code}` : data.code; const textAndIcon = textsAndIcons.find(item => item.id === langKey); @@ -32,14 +32,14 @@ export const ItemContentNavDevPluginAdmin = ({

{tAdmin.rich('lang_key', { key: () => ( - {`admin_${pluginCode}.nav.${langKey}`} + {`admin_${code}.nav.${langKey}`} ), })}

{tAdmin.rich('link_url_with_link', { link: () => ( - {`/admin/${pluginCode}/${parentId ? `${parentId}/` : ''}${data.code}`} + {`/admin/${code}/${parentId ? `${parentId}/` : ''}${data.code}`} ), })}

diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/create-edit/hooks/use-create-edit-permission-admin-plugin-admin.ts b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/create-edit/hooks/use-create-edit-permission-admin-plugin-admin.ts index 43e4f6440..e20c69fa1 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/create-edit/hooks/use-create-edit-permission-admin-plugin-admin.ts +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/create-edit/hooks/use-create-edit-permission-admin-plugin-admin.ts @@ -18,7 +18,7 @@ export const useCreateEditPermissionAdminPluginAdmin = ({ dataWithI18n: PermissionsAdminWithI18n[]; parentId: string | undefined; }) => { - const { pluginCode } = useDevPluginAdmin(); + const { code } = useDevPluginAdmin(); const t = useTranslations( 'admin.core.plugins.dev.permissions-admin.create_edit', ); @@ -44,14 +44,14 @@ export const useCreateEditPermissionAdminPluginAdmin = ({ await editMutationApi({ ...values, parent_id: values.parent_id === 'null' ? undefined : values.parent_id, - plugin_code: pluginCode, + plugin_code: code, old_id: data.id, }); } else { await createMutationApi({ ...values, parent_id: values.parent_id === 'null' ? undefined : values.parent_id, - plugin_code: pluginCode, + plugin_code: code, }); } diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/actions/delete/hooks/use-delete-permission-admin-plugin-admin.ts b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/actions/delete/hooks/use-delete-permission-admin-plugin-admin.ts index b464867b5..61bed2ee6 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/actions/delete/hooks/use-delete-permission-admin-plugin-admin.ts +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/actions/delete/hooks/use-delete-permission-admin-plugin-admin.ts @@ -15,12 +15,12 @@ export const useDeletePermissionAdminPluginAdmin = ({ const t = useTranslations('admin.core.plugins.dev.permissions-admin.delete'); const tCore = useTranslations('core.global.errors'); const { setOpen } = useAlertDialog(); - const { pluginCode } = useDevPluginAdmin(); + const { code } = useDevPluginAdmin(); const onSubmit = async () => { try { await mutationApi({ - plugin_code: Array.isArray(pluginCode) ? pluginCode[0] : pluginCode, + plugin_code: code, id, parent_id: parentId, }); diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/item.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/item.tsx index 67883cdaa..938adafd7 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/item.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/permissions-admin/item/item.tsx @@ -16,7 +16,7 @@ export const ItemPermissionsAdminDevPluginAdmin = ({ parentId: string | undefined; }) => { const t = useTranslations('admin.core.plugins.dev.permissions-admin'); - const { pluginCode } = useDevPluginAdmin(); + const { code } = useDevPluginAdmin(); return (
@@ -28,7 +28,7 @@ export const ItemPermissionsAdminDevPluginAdmin = ({

{t.rich('lang_key', { key: () => ( - {`admin_${pluginCode}.admin_permissions.${id}`} + {`admin_${code}.admin_permissions.${id}`} ), })}

@@ -37,7 +37,7 @@ export const ItemPermissionsAdminDevPluginAdmin = ({ {t.rich('page_permission', { page: () => ( - {`/admin/${pluginCode}/${id.replace('can_manage_', '').split('_').join('/')}`} + {`/admin/${code}/${id.replace('can_manage_', '').split('_').join('/')}`} ), })} diff --git a/packages/frontend/src/views/admin/views/core/plugins/dev/tabs.tsx b/packages/frontend/src/views/admin/views/core/plugins/dev/tabs.tsx index 13d7489a3..aebc5b243 100644 --- a/packages/frontend/src/views/admin/views/core/plugins/dev/tabs.tsx +++ b/packages/frontend/src/views/admin/views/core/plugins/dev/tabs.tsx @@ -14,12 +14,20 @@ export const TabsDevPluginAdmin = ({ code }: { code: string }) => { active={pathname === `/admin/core/plugins/${code}/dev`} href={`/admin/core/plugins/${code}/dev`} > - {t('overview.title')} + {t('overview')} - + {t('nav.title')} - + {t('permissions-admin.title')} diff --git a/packages/frontend/src/views/admin/views/core/styles/theme-editor/wrapper.tsx b/packages/frontend/src/views/admin/views/core/styles/theme-editor/wrapper.tsx index f63581627..cf2042afd 100644 --- a/packages/frontend/src/views/admin/views/core/styles/theme-editor/wrapper.tsx +++ b/packages/frontend/src/views/admin/views/core/styles/theme-editor/wrapper.tsx @@ -217,10 +217,8 @@ export const WrapperThemeEditorAdmin = ({ }; return ( - + {children} - + ); }; diff --git a/packages/frontend/src/views/layout/auth/wrapper.tsx b/packages/frontend/src/views/layout/auth/wrapper.tsx index bd6524b2e..b7e388731 100644 --- a/packages/frontend/src/views/layout/auth/wrapper.tsx +++ b/packages/frontend/src/views/layout/auth/wrapper.tsx @@ -10,7 +10,5 @@ export const WrapperAuthLayout = ({ children: React.ReactNode; data: ShowAuthObj; }) => { - return ( - {children} - ); + return {children}; }; diff --git a/packages/frontend/src/views/layout/providers.tsx b/packages/frontend/src/views/layout/providers.tsx index 6b77b80ba..f81d1041d 100644 --- a/packages/frontend/src/views/layout/providers.tsx +++ b/packages/frontend/src/views/layout/providers.tsx @@ -37,9 +37,9 @@ export const RootProviders = ({ /> {middlewareData ? ( - + {children} - + ) : ( children )} diff --git a/packages/frontend/src/views/theme/views/auth/sign/up/wrapper.tsx b/packages/frontend/src/views/theme/views/auth/sign/up/wrapper.tsx index 9b115bb03..8e4b1117c 100644 --- a/packages/frontend/src/views/theme/views/auth/sign/up/wrapper.tsx +++ b/packages/frontend/src/views/theme/views/auth/sign/up/wrapper.tsx @@ -20,9 +20,7 @@ export const SignUpWrapper = ({ if (!emailSuccess) { return ( - - {children} - + {children} ); } diff --git a/packages/shared/src/admin/plugins.dto.ts b/packages/shared/src/admin/plugins.dto.ts index 1cdf8acb6..1923c6a6c 100644 --- a/packages/shared/src/admin/plugins.dto.ts +++ b/packages/shared/src/admin/plugins.dto.ts @@ -126,7 +126,7 @@ export class ShowPluginsAdminQuery extends PaginationQuery { } export class ExportPluginsAdminBody { - @ApiPropertyOptional({ example: '1.0.0' }) + @ApiPropertyOptional({ example: '0.0.1' }) @IsOptional() @IsString() version?: string;