Skip to content

Commit

Permalink
fix: Create/delete plugins while restarting server
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Oct 21, 2024
1 parent 7cf480a commit 113da9d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class ChangeFilesAdminPluginsService {
}),
getEntryName: code => `typeof ${code}`,
reconstructFileContent: (imports, entries, originalContent) => {
// TODO: Remove console.log
// eslint-disable-next-line no-console
console.log({ imports, entries, originalContent });

let newContent = '';
imports.forEach((path, name) => {
newContent += `import type ${name} from '${path}';\n`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const createPackagesJSON = ({
geist: '^1.3.1',
'lucide-react': '^0.451.0',
next: '15.0.0-rc.1',
'next-intl': '^3.21.0-canary.0',
'next-intl': '3.21.0-canary.0',
react: '19.0.0-rc-6cf85185-20241014',
'react-dom': '19.0.0-rc-6cf85185-20241014',
'react-hook-form': '^7.53.0',
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"graphql-tag": "^2.12.6",
"lucide-react": "^0.420.0",
"next": "15.0.0-canary.179",
"next-intl": "^3.21.0-canary.0",
"next-intl": "3.21.0-canary.0",
"postcss": "^8.4.42",
"react": "^19.0.0-rc-d6cb4e77-20240911",
"react-dom": "^19.0.0-rc-d6cb4e77-20240911",
Expand Down
7 changes: 6 additions & 1 deletion packages/frontend/src/components/form/auto-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ export function AutoForm<
})}

{children}
<div className="flex w-full flex-wrap items-center justify-end gap-2">
<div
className={cn('flex w-full flex-wrap items-center gap-2', {
'justify-end': !setOpen,
'[&>*]:flex-1': setOpen,
})}
>
{setOpen ? (
<Button
disabled={form.formState.isSubmitting}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { UseFormReturn } from 'react-hook-form';
import { toast } from 'sonner';
import * as z from 'zod';

import { checkConnectionMutationApi } from '../../../hooks/check-connection-mutation-api';
import { mutationCreateApi } from './mutation-create-api';
import { mutationEditApi } from './mutation-edit-api';

Expand Down Expand Up @@ -106,29 +105,6 @@ export const useCreateEditPluginAdmin = ({ data }: Args) => {
return;
}

if (!data) {
// Wait 3 seconds before reloading the page
await new Promise<void>(resolve =>
setTimeout(async () => {
form.reset({}, { keepValues: true });
const data = await checkConnectionMutationApi();

if (data?.error) {
toast.error(tCore('title'), {
description: tCore('internal_server_error'),
});

resolve();
}

window.location.reload();
resolve();
}, 3000),
);

return;
}

toast.success(t('edit.success'), {
description: values.name,
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslations } from 'next-intl';
import { toast } from 'sonner';

import { checkConnectionMutationApi } from '../../../../hooks/check-connection-mutation-api';
// import { checkConnectionMutationApi } from '../../../../hooks/check-connection-mutation-api';
import { mutationApi } from './mutation-api';

export const useDeletePluginAdmin = ({ code }: { code: string }) => {
Expand All @@ -18,23 +18,23 @@ export const useDeletePluginAdmin = ({ code }: { code: string }) => {
return;
}

// Wait 3 seconds before reloading the page
await new Promise<void>(resolve =>
setTimeout(async () => {
const data = await checkConnectionMutationApi();
// // Wait 3 seconds before reloading the page
// await new Promise<void>(resolve =>
// setTimeout(async () => {
// const data = await checkConnectionMutationApi();

if (data?.error) {
toast.error(tCore('title'), {
description: tCore('internal_server_error'),
});
// if (data?.error) {
// toast.error(tCore('title'), {
// description: tCore('internal_server_error'),
// });

resolve();
}
// resolve();
// }

window.location.reload();
resolve();
}, 3000),
);
// window.location.reload();
// resolve();
// }, 3000),
// );
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UseFormReturn } from 'react-hook-form';
import { toast } from 'sonner';
import * as z from 'zod';

import { checkConnectionMutationApi } from '../../hooks/check-connection-mutation-api';
// import { checkConnectionMutationApi } from '../../hooks/check-connection-mutation-api';
import { UploadPluginAdminProps } from '../upload';
import { mutationApi } from './mutation-api';

Expand Down Expand Up @@ -49,23 +49,23 @@ export const useUploadPluginAdmin = ({ data }: UploadPluginAdminProps) => {
return;
}

// Wait 3 seconds before reloading the page
await new Promise<void>(resolve =>
setTimeout(async () => {
const data = await checkConnectionMutationApi();
// // Wait 3 seconds before reloading the page
// await new Promise<void>(resolve =>
// setTimeout(async () => {
// const data = await checkConnectionMutationApi();

if (data?.error) {
toast.error(tCore('title'), {
description: tCore('internal_server_error'),
});
// if (data?.error) {
// toast.error(tCore('title'), {
// description: tCore('internal_server_error'),
// });

resolve();
}
// resolve();
// }

window.location.reload();
resolve();
}, 3000),
);
// window.location.reload();
// resolve();
// }, 3000),
// );
};

return { onSubmit, formSchema };
Expand Down

0 comments on commit 113da9d

Please sign in to comment.