소스 검색

feat(install form): add input placeholder

chore: fix code smells
Nicolas Meienberger 2 년 전
부모
커밋
1e12261614

+ 3 - 0
packages/dashboard/src/generated/graphql.tsx

@@ -129,6 +129,7 @@ export type FormField = {
   label: Scalars['String'];
   label: Scalars['String'];
   max?: Maybe<Scalars['Float']>;
   max?: Maybe<Scalars['Float']>;
   min?: Maybe<Scalars['Float']>;
   min?: Maybe<Scalars['Float']>;
+  placeholder?: Maybe<Scalars['String']>;
   required?: Maybe<Scalars['Boolean']>;
   required?: Maybe<Scalars['Boolean']>;
   type: FieldTypesEnum;
   type: FieldTypesEnum;
 };
 };
@@ -339,6 +340,7 @@ export type GetAppQuery = {
         max?: number | null;
         max?: number | null;
         min?: number | null;
         min?: number | null;
         hint?: string | null;
         hint?: string | null;
+        placeholder?: string | null;
         required?: boolean | null;
         required?: boolean | null;
         env_variable: string;
         env_variable: string;
       }>;
       }>;
@@ -814,6 +816,7 @@ export const GetAppDocument = gql`
           max
           max
           min
           min
           hint
           hint
+          placeholder
           required
           required
           env_variable
           env_variable
         }
         }

+ 1 - 0
packages/dashboard/src/graphql/queries/getApp.graphql

@@ -33,6 +33,7 @@ query GetApp($appId: String!) {
         max
         max
         min
         min
         hint
         hint
+        placeholder
         required
         required
         env_variable
         env_variable
       }
       }

+ 9 - 1
packages/dashboard/src/modules/Apps/components/InstallForm.tsx

@@ -29,7 +29,15 @@ const InstallForm: React.FC<IProps> = ({ formFields, onSubmit, initalValues, exp
         key={field.env_variable}
         key={field.env_variable}
         name={field.env_variable}
         name={field.env_variable}
         render={({ input, meta }) => (
         render={({ input, meta }) => (
-          <FormInput hint={field.hint || ''} className="mb-3" error={meta.error} isInvalid={meta.invalid && (meta.submitError || meta.submitFailed)} label={field.label} {...input} />
+          <FormInput
+            hint={field.hint || ''}
+            placeholder={field.placeholder || ''}
+            className="mb-3"
+            error={meta.error}
+            isInvalid={meta.invalid && (meta.submitError || meta.submitFailed)}
+            label={field.label}
+            {...input}
+          />
         )}
         )}
       />
       />
     );
     );

+ 2 - 2
packages/system-api/src/core/updates/v040.ts

@@ -63,7 +63,7 @@ export const updateV040 = async (): Promise<void> => {
 
 
     // Migrate apps
     // Migrate apps
     if (fileExists('/runtipi/state/apps.json')) {
     if (fileExists('/runtipi/state/apps.json')) {
-      const state = await readJsonFile('/runtipi/state/apps.json');
+      const state = readJsonFile('/runtipi/state/apps.json');
       const parsedState = appStateSchema.safeParse(state);
       const parsedState = appStateSchema.safeParse(state);
 
 
       if (parsedState.success) {
       if (parsedState.success) {
@@ -75,7 +75,7 @@ export const updateV040 = async (): Promise<void> => {
 
 
     // Migrate users
     // Migrate users
     if (fileExists('/state/users.json')) {
     if (fileExists('/state/users.json')) {
-      const state = await readJsonFile('/runtipi/state/users.json');
+      const state = readJsonFile('/runtipi/state/users.json');
       const parsedState = userStateSchema.safeParse(state);
       const parsedState = userStateSchema.safeParse(state);
 
 
       if (parsedState.success) {
       if (parsedState.success) {

+ 1 - 0
packages/system-api/src/modules/apps/apps.helpers.ts

@@ -10,6 +10,7 @@ import { AppEntityType } from './app.types';
 const formFieldSchema = z.object({
 const formFieldSchema = z.object({
   type: z.nativeEnum(FieldTypes),
   type: z.nativeEnum(FieldTypes),
   label: z.string(),
   label: z.string(),
+  placeholder: z.string().optional(),
   max: z.number().optional(),
   max: z.number().optional(),
   min: z.number().optional(),
   min: z.number().optional(),
   hint: z.string().optional(),
   hint: z.string().optional(),

+ 3 - 3
packages/system-api/src/modules/apps/apps.service.ts

@@ -116,7 +116,7 @@ const installApp = async (id: string, form: Record<string, string>, exposed?: bo
     // Create app folder
     // Create app folder
     createFolder(`/app/storage/app-data/${id}`);
     createFolder(`/app/storage/app-data/${id}`);
 
 
-    const appInfo = await readJsonFile(`/runtipi/apps/${id}/config.json`);
+    const appInfo = readJsonFile(`/runtipi/apps/${id}/config.json`);
     const parsedAppInfo = appInfoSchema.safeParse(appInfo);
     const parsedAppInfo = appInfoSchema.safeParse(appInfo);
 
 
     if (!parsedAppInfo.success) {
     if (!parsedAppInfo.success) {
@@ -205,7 +205,7 @@ const updateAppConfig = async (id: string, form: Record<string, string>, exposed
     throw new Error(`App ${id} not found`);
     throw new Error(`App ${id} not found`);
   }
   }
 
 
-  const appInfo = await readJsonFile(`/runtipi/apps/${id}/config.json`);
+  const appInfo = readJsonFile(`/runtipi/apps/${id}/config.json`);
   const parsedAppInfo = appInfoSchema.safeParse(appInfo);
   const parsedAppInfo = appInfoSchema.safeParse(appInfo);
 
 
   if (!parsedAppInfo.success) {
   if (!parsedAppInfo.success) {
@@ -331,7 +331,7 @@ const updateApp = async (id: string) => {
   const { success, stdout } = await eventDispatcher.dispatchEventAsync(EventTypes.APP, ['update', id]);
   const { success, stdout } = await eventDispatcher.dispatchEventAsync(EventTypes.APP, ['update', id]);
 
 
   if (success) {
   if (success) {
-    const appInfo = await readJsonFile(`/runtipi/apps/${id}/config.json`);
+    const appInfo = readJsonFile(`/runtipi/apps/${id}/config.json`);
     const parsedAppInfo = appInfoSchema.parse(appInfo);
     const parsedAppInfo = appInfoSchema.parse(appInfo);
 
 
     await App.update({ id }, { status: AppStatusEnum.RUNNING, version: parsedAppInfo.tipi_version });
     await App.update({ id }, { status: AppStatusEnum.RUNNING, version: parsedAppInfo.tipi_version });

+ 3 - 0
packages/system-api/src/modules/apps/apps.types.ts

@@ -76,6 +76,9 @@ class FormField {
   @Field(() => String, { nullable: true })
   @Field(() => String, { nullable: true })
   hint?: string;
   hint?: string;
 
 
+  @Field(() => String, { nullable: true })
+  placeholder?: string;
+
   @Field(() => Boolean, { nullable: true })
   @Field(() => Boolean, { nullable: true })
   required?: boolean;
   required?: boolean;