@@ -141,11 +152,30 @@ function EggProcessContainer ({ egg }: { egg: Egg }) {
);
}
-export default function EggSettingsContainer ({ egg }: { egg: Egg }) {
- const { clearFlashes } = useFlash();
+interface Values {
+ name: string;
+ description: string;
+ startup: string;
+ dockerImages: string;
+ stopCommand: string;
+}
- const submit = () => {
+export default function EggSettingsContainer ({ egg }: { egg: Egg }) {
+ const history = useHistory();
+
+ const { clearFlashes, clearAndAddHttpError } = useFlash();
+
+ const submit = (values: Values, { setSubmitting }: FormikHelpers
) => {
clearFlashes('egg');
+
+ // TODO: Send data from code blocks.
+
+ updateEgg(egg.id, { ...values, dockerImages: values.dockerImages.split('\n') })
+ .catch(error => {
+ console.error(error);
+ clearAndAddHttpError({ key: 'egg', error });
+ })
+ .then(() => setSubmitting(false));
};
return (
@@ -154,29 +184,42 @@ export default function EggSettingsContainer ({ egg }: { egg: Egg }) {
initialValues={{
name: egg.name,
description: egg.description || '',
-
startup: egg.startup,
-
- stopCommand: egg.configStop,
+ dockerImages: egg.dockerImages.join('\n'),
+ stopCommand: egg.configStop || '',
}}
validationSchema={object().shape({
})}
>
-
+
+
+
+
+ history.push('/admin/eggs')}
+ />
+
+
+
+
+ )}
);
}
diff --git a/resources/scripts/components/elements/Field.tsx b/resources/scripts/components/elements/Field.tsx
index f45ce0fb4..5840983ed 100644
--- a/resources/scripts/components/elements/Field.tsx
+++ b/resources/scripts/components/elements/Field.tsx
@@ -1,6 +1,6 @@
import React, { forwardRef } from 'react';
import { Field as FormikField, FieldProps } from 'formik';
-import Input from '@/components/elements/Input';
+import Input, { Textarea } from '@/components/elements/Input';
import Label from '@/components/elements/Label';
import InputError from '@/components/elements/InputError';
import tw from 'twin.macro';
@@ -43,4 +43,33 @@ const Field = forwardRef(({ id, name, light = false, la
));
Field.displayName = 'Field';
+type Props2 = OwnProps & Omit, 'name'>;
+
+export const TextareaField = forwardRef(
+ function TextareaField ({ id, name, light = false, label, description, validate, ...props }, ref) {
+ return (
+
+ {
+ ({ field, form: { errors, touched } }: FieldProps) => (
+
+ {label && }
+
+
+ {description || null}
+
+
+ )
+ }
+
+ );
+ }
+);
+TextareaField.displayName = 'TextareaField';
+
export default Field;