-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web): Fix Helm Template structure and styling issues
- Refactored pod environment fields into separate components instead of defining them directly within the Helm Template
- Loading branch information
1 parent
79d52ab
commit 76bbb72
Showing
4 changed files
with
90 additions
and
128 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
web/src/pages/helm-template/components/pod-environment-fields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useFieldArray, useFormContext } from 'react-hook-form'; | ||
import { Plus, Trash2 } from 'lucide-react'; | ||
import { FormInput } from '@/components/form/form-input'; | ||
import { cn } from '@/lib/utils'; | ||
import { FC } from 'react'; | ||
|
||
type PodEnvironmentFieldsProps = { | ||
podIndex: number; | ||
}; | ||
|
||
const PodEnvironmentFields: FC<PodEnvironmentFieldsProps> = ({ podIndex }) => { | ||
const { control } = useFormContext(); | ||
const { fields, append, remove } = useFieldArray({ | ||
control, | ||
name: `pods.${podIndex}.environment`, | ||
}); | ||
|
||
return ( | ||
<div className="mb-2 mt-6"> | ||
<div className="mb-2 flex items-center"> | ||
<p className="text-base font-bold">Environments</p> | ||
|
||
<button | ||
type="button" | ||
onClick={() => append({ name: '', value: '' })} | ||
className="btn btn-xs ml-4" | ||
> | ||
Add <Plus className="size-3" /> | ||
</button> | ||
</div> | ||
<div className="grid grid-cols-2 gap-4"> | ||
{fields.map((field, envIdx) => ( | ||
<div | ||
className="mb-4 flex items-center divide-x divide-gray-200 rounded-md border border-gray-200 dark:divide-gray-500 dark:border-gray-500 [&>div]:mb-0" | ||
key={field.id} | ||
> | ||
<FormInput | ||
id={`env_name_${envIdx}`} | ||
name={`pods.${podIndex}.environment.${envIdx}.name`} | ||
label="" | ||
placeholder="Env" | ||
className="h-12 w-full rounded-s-md px-2 outline-none" | ||
/> | ||
<FormInput | ||
id={`env_value_${envIdx}`} | ||
name={`pods.${podIndex}.environment.${envIdx}.value`} | ||
label="" | ||
placeholder="Hi" | ||
className={cn('h-12 w-full rounded-s-md px-2 outline-none', { | ||
'rounded-e-md': envIdx === 0, | ||
})} | ||
/> | ||
{envIdx > 0 && ( | ||
<button | ||
onClick={() => remove(envIdx)} | ||
className="btn btn-error rounded-e-md rounded-s-none" | ||
> | ||
<Trash2 /> | ||
</button> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PodEnvironmentFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.