Add conditional rendering for watchPaths field based on triggerType in SaveGithubProvider and SaveGithubProviderCompose components.

This commit is contained in:
Mauricio Siu 2025-04-26 22:20:37 -06:00
parent 144d48057c
commit bb5c6bebff
2 changed files with 156 additions and 146 deletions

View File

@ -92,6 +92,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
const repository = form.watch("repository"); const repository = form.watch("repository");
const githubId = form.watch("githubId"); const githubId = form.watch("githubId");
const triggerType = form.watch("triggerType");
const { data: repositories, isLoading: isLoadingRepositories } = const { data: repositories, isLoading: isLoadingRepositories } =
api.github.getGithubRepositories.useQuery( api.github.getGithubRepositories.useQuery(
@ -428,6 +429,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
{triggerType === "push" && (
<FormField <FormField
control={form.control} control={form.control}
name="watchPaths" name="watchPaths"
@ -442,8 +444,9 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent>
<p> <p>
Add paths to watch for changes. When files in these Add paths to watch for changes. When files in
paths change, a new deployment will be triggered. these paths change, a new deployment will be
triggered.
</p> </p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
@ -507,6 +510,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
)}
<FormField <FormField
control={form.control} control={form.control}

View File

@ -93,7 +93,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
const repository = form.watch("repository"); const repository = form.watch("repository");
const githubId = form.watch("githubId"); const githubId = form.watch("githubId");
const triggerType = form.watch("triggerType");
const { data: repositories, isLoading: isLoadingRepositories } = const { data: repositories, isLoading: isLoadingRepositories } =
api.github.getGithubRepositories.useQuery( api.github.getGithubRepositories.useQuery(
{ {
@ -431,6 +431,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
{triggerType === "push" && (
<FormField <FormField
control={form.control} control={form.control}
name="watchPaths" name="watchPaths"
@ -447,8 +448,9 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent>
<p> <p>
Add paths to watch for changes. When files in these Add paths to watch for changes. When files in
paths change, a new deployment will be triggered. these paths change, a new deployment will be
triggered.
</p> </p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
@ -479,7 +481,10 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
const input = e.currentTarget; const input = e.currentTarget;
const value = input.value.trim(); const value = input.value.trim();
if (value) { if (value) {
const newPaths = [...(field.value || []), value]; const newPaths = [
...(field.value || []),
value,
];
form.setValue("watchPaths", newPaths); form.setValue("watchPaths", newPaths);
input.value = ""; input.value = "";
} }
@ -509,6 +514,7 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => {
</FormItem> </FormItem>
)} )}
/> />
)}
<FormField <FormField
control={form.control} control={form.control}
name="enableSubmodules" name="enableSubmodules"