feat(install form): add input placeholder
chore: fix code smells
This commit is contained in:
parent
bed2404541
commit
1e12261614
7 changed files with 22 additions and 6 deletions
|
@ -129,6 +129,7 @@ export type FormField = {
|
|||
label: Scalars['String'];
|
||||
max?: Maybe<Scalars['Float']>;
|
||||
min?: Maybe<Scalars['Float']>;
|
||||
placeholder?: Maybe<Scalars['String']>;
|
||||
required?: Maybe<Scalars['Boolean']>;
|
||||
type: FieldTypesEnum;
|
||||
};
|
||||
|
@ -339,6 +340,7 @@ export type GetAppQuery = {
|
|||
max?: number | null;
|
||||
min?: number | null;
|
||||
hint?: string | null;
|
||||
placeholder?: string | null;
|
||||
required?: boolean | null;
|
||||
env_variable: string;
|
||||
}>;
|
||||
|
@ -814,6 +816,7 @@ export const GetAppDocument = gql`
|
|||
max
|
||||
min
|
||||
hint
|
||||
placeholder
|
||||
required
|
||||
env_variable
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ query GetApp($appId: String!) {
|
|||
max
|
||||
min
|
||||
hint
|
||||
placeholder
|
||||
required
|
||||
env_variable
|
||||
}
|
||||
|
|
|
@ -29,7 +29,15 @@ const InstallForm: React.FC<IProps> = ({ formFields, onSubmit, initalValues, exp
|
|||
key={field.env_variable}
|
||||
name={field.env_variable}
|
||||
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}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -63,7 +63,7 @@ export const updateV040 = async (): Promise<void> => {
|
|||
|
||||
// Migrate apps
|
||||
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);
|
||||
|
||||
if (parsedState.success) {
|
||||
|
@ -75,7 +75,7 @@ export const updateV040 = async (): Promise<void> => {
|
|||
|
||||
// Migrate users
|
||||
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);
|
||||
|
||||
if (parsedState.success) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import { AppEntityType } from './app.types';
|
|||
const formFieldSchema = z.object({
|
||||
type: z.nativeEnum(FieldTypes),
|
||||
label: z.string(),
|
||||
placeholder: z.string().optional(),
|
||||
max: z.number().optional(),
|
||||
min: z.number().optional(),
|
||||
hint: z.string().optional(),
|
||||
|
|
|
@ -116,7 +116,7 @@ const installApp = async (id: string, form: Record<string, string>, exposed?: bo
|
|||
// Create app folder
|
||||
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);
|
||||
|
||||
if (!parsedAppInfo.success) {
|
||||
|
@ -205,7 +205,7 @@ const updateAppConfig = async (id: string, form: Record<string, string>, exposed
|
|||
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);
|
||||
|
||||
if (!parsedAppInfo.success) {
|
||||
|
@ -331,7 +331,7 @@ const updateApp = async (id: string) => {
|
|||
const { success, stdout } = await eventDispatcher.dispatchEventAsync(EventTypes.APP, ['update', id]);
|
||||
|
||||
if (success) {
|
||||
const appInfo = await readJsonFile(`/runtipi/apps/${id}/config.json`);
|
||||
const appInfo = readJsonFile(`/runtipi/apps/${id}/config.json`);
|
||||
const parsedAppInfo = appInfoSchema.parse(appInfo);
|
||||
|
||||
await App.update({ id }, { status: AppStatusEnum.RUNNING, version: parsedAppInfo.tipi_version });
|
||||
|
|
|
@ -76,6 +76,9 @@ class FormField {
|
|||
@Field(() => String, { nullable: true })
|
||||
hint?: string;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
placeholder?: string;
|
||||
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
required?: boolean;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue