From 5830d16382d0f326e31a005fe9a49d8e2856a459 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Thu, 2 Nov 2023 07:57:13 +0100 Subject: [PATCH] feat(apps): add "enable on guest dashboard option" --- next-env.d.ts | 1 - .../AppDetailsContainer.tsx | 8 +--- .../components/InstallForm/InstallForm.tsx | 13 +++++- .../UpdateSettingsModal.tsx | 6 +-- .../components/AppStoreTile/AppStoreTile.tsx | 3 +- .../helpers/__tests__/table.helpers.test.ts | 3 +- .../app-store/helpers/table.helpers.ts | 2 - .../actions/app-actions/install-app-action.ts | 6 +-- .../app-actions/update-app-config-action.ts | 4 +- src/client/messages/en.json | 10 ++++- src/lib/helpers/text-helpers.ts | 1 + src/server/db/schema.ts | 1 + src/server/services/apps/apps.service.test.ts | 16 +++---- src/server/services/apps/apps.service.ts | 45 +++++++++++++++---- 14 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 src/lib/helpers/text-helpers.ts diff --git a/next-env.d.ts b/next-env.d.ts index fd36f949..4f11a03d 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/src/app/(dashboard)/app-store/[id]/components/AppDetailsContainer/AppDetailsContainer.tsx b/src/app/(dashboard)/app-store/[id]/components/AppDetailsContainer/AppDetailsContainer.tsx index b53de597..e98d0c97 100644 --- a/src/app/(dashboard)/app-store/[id]/components/AppDetailsContainer/AppDetailsContainer.tsx +++ b/src/app/(dashboard)/app-store/[id]/components/AppDetailsContainer/AppDetailsContainer.tsx @@ -116,8 +116,7 @@ export const AppDetailsContainer: React.FC = ({ app, localDomain }) => { const handleInstallSubmit = async (values: FormValues) => { setCustomStatus('installing'); installDisclosure.close(); - const { exposed, domain } = values; - installMutation.execute({ id: app.id, form: values, exposed, domain }); + installMutation.execute({ id: app.id, form: values }); }; const handleUnistallSubmit = () => { @@ -139,8 +138,7 @@ export const AppDetailsContainer: React.FC = ({ app, localDomain }) => { const handleUpdateSettingsSubmit = async (values: FormValues) => { updateSettingsDisclosure.close(); - const { exposed, domain } = values; - updateConfigMutation.execute({ id: app.id, form: values, exposed, domain }); + updateConfigMutation.execute({ id: app.id, form: values }); }; const handleUpdateSubmit = async () => { @@ -185,8 +183,6 @@ export const AppDetailsContainer: React.FC = ({ app, localDomain }) => { onClose={updateSettingsDisclosure.close} info={app.info} config={castAppConfig(app?.config)} - exposed={app?.exposed} - domain={app?.domain || ''} />
diff --git a/src/app/(dashboard)/app-store/[id]/components/InstallForm/InstallForm.tsx b/src/app/(dashboard)/app-store/[id]/components/InstallForm/InstallForm.tsx index 4741d50e..c0e7d1e1 100644 --- a/src/app/(dashboard)/app-store/[id]/components/InstallForm/InstallForm.tsx +++ b/src/app/(dashboard)/app-store/[id]/components/InstallForm/InstallForm.tsx @@ -14,7 +14,7 @@ import { validateAppConfig } from '../../utils/validators'; interface IProps { formFields: FormField[]; onSubmit: (values: FormValues) => void; - initalValues?: { exposed?: boolean; domain?: string } & { [key: string]: string | boolean | undefined }; + initalValues?: { [key: string]: unknown }; info: AppInfo; loading?: boolean; } @@ -22,6 +22,7 @@ interface IProps { export type FormValues = { exposed?: boolean; domain?: string; + isVisibleOnGuestDashboard?: boolean; [key: string]: string | boolean | undefined; }; @@ -50,7 +51,7 @@ export const InstallForm: React.FC = ({ formFields, info, onSubmit, init useEffect(() => { if (initalValues && !isDirty) { Object.entries(initalValues).forEach(([key, value]) => { - setValue(key, value); + setValue(key, value as string); }); } }, [initalValues, isDirty, setValue]); @@ -153,6 +154,14 @@ export const InstallForm: React.FC = ({ formFields, info, onSubmit, init return (
{formFields.filter(typeFilter).map(renderField)} + ( + + )} + /> {info.exposable && renderExposeForm()}