diff --git a/packages/frontend/src/assets/domains.json b/packages/frontend/src/assets/domains.json index 9b8f03b3..1cff7a29 100644 --- a/packages/frontend/src/assets/domains.json +++ b/packages/frontend/src/assets/domains.json @@ -1,7 +1,7 @@ [ { - "domainid":1, - "projectid":1, + "domainid": 1, + "projectid": 1, "domain": "randomurl.snowballtools.xyz", "status": "live" } diff --git a/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx b/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx index eb555207..2969dfb8 100644 --- a/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx +++ b/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx @@ -9,10 +9,7 @@ import { import Domains from './settings/Domains'; import GeneralTabPanel from './settings/GeneralTabPanel'; - -const EnvironmentVariables = () => { - return
Environment Variables
; -}; +import { EnvironmentVariablesTabPanel } from './settings/EnvironmentVariablesTabPanel'; const Members = () => { return
Members
; @@ -35,7 +32,7 @@ const tabsData = [ label: 'Environment variables', icon: '^', value: 'environmentVariables', - component: EnvironmentVariables, + component: EnvironmentVariablesTabPanel, }, { label: 'Members', diff --git a/packages/frontend/src/components/projects/project/settings/EnvironmentVariable.tsx b/packages/frontend/src/components/projects/project/settings/EnvironmentVariable.tsx new file mode 100644 index 00000000..b31ba114 --- /dev/null +++ b/packages/frontend/src/components/projects/project/settings/EnvironmentVariable.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { UseFormRegister } from 'react-hook-form'; + +import { Typography, Input, IconButton } from '@material-tailwind/react'; + +import { EnvironmentVariablesFormValues } from './EnvironmentVariablesTabPanel'; + +interface EnvironmentVariableProps { + onDelete: () => void; + register: UseFormRegister; + index: number; +} + +const EnvironmentVariable = ({ + onDelete, + register, + index, +}: EnvironmentVariableProps) => { + return ( +
+
+ Key + +
+
+ Value + +
+
+ onDelete()}> + {'>'} + +
+
+ ); +}; + +export default EnvironmentVariable; diff --git a/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx b/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx new file mode 100644 index 00000000..730291b6 --- /dev/null +++ b/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx @@ -0,0 +1,121 @@ +import React, { useState } from 'react'; +import { useFieldArray, useForm } from 'react-hook-form'; + +import { + Typography, + Collapse, + Card, + Button, + Checkbox, +} from '@material-tailwind/react'; + +import EnvironmentVariable from './EnvironmentVariable'; + +export type EnvironmentVariablesFormValues = { + variables: { + key: string; + value: string; + }[]; + environment: { + development: boolean; + preview: boolean; + production: boolean; + }; +}; + +export const EnvironmentVariablesTabPanel = () => { + const { handleSubmit, register, control } = + useForm({ + defaultValues: { + variables: [{ key: '', value: '' }], + environment: { + development: false, + preview: false, + production: false, + }, + }, + }); + + const [createNewVariable, setCreateNewVariable] = useState(false); + + const { fields, append, remove } = useFieldArray({ + name: 'variables', + control, + }); + + return ( + <> + Environment variables + + A new deployment is required for your changes to take effect. + +
+
setCreateNewVariable((cur) => !cur)} + > + + Create new variable +
+ + +
{})}> + {fields.map((field, index) => { + return ( +
+ remove(index)} + /> +
+ ); + })} +
+ + +
+
+ + + +
+
+ +
+
+
+
+
+ + ); +};