From bb5c6bebffea6413086d581c52c75ae7500b0423 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 26 Apr 2025 22:20:37 -0600 Subject: [PATCH] Add conditional rendering for watchPaths field based on triggerType in SaveGithubProvider and SaveGithubProviderCompose components. --- .../general/generic/save-github-provider.tsx | 154 +++++++++--------- .../generic/save-github-provider-compose.tsx | 148 +++++++++-------- 2 files changed, 156 insertions(+), 146 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx index e1fa90bf..0bf1ac8a 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-github-provider.tsx @@ -92,6 +92,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => { const repository = form.watch("repository"); const githubId = form.watch("githubId"); + const triggerType = form.watch("triggerType"); const { data: repositories, isLoading: isLoadingRepositories } = api.github.getGithubRepositories.useQuery( @@ -428,85 +429,88 @@ export const SaveGithubProvider = ({ applicationId }: Props) => { )} /> - ( - -
- Watch Paths - - - - - - -

- Add paths to watch for changes. When files in these - paths change, a new deployment will be triggered. -

-
-
-
-
-
- {field.value?.map((path, index) => ( - - {path} - { - const newPaths = [...(field.value || [])]; - newPaths.splice(index, 1); - field.onChange(newPaths); + {triggerType === "push" && ( + ( + +
+ Watch Paths + + + + + + +

+ Add paths to watch for changes. When files in + these paths change, a new deployment will be + triggered. +

+
+
+
+
+
+ {field.value?.map((path, index) => ( + + {path} + { + const newPaths = [...(field.value || [])]; + newPaths.splice(index, 1); + field.onChange(newPaths); + }} + /> + + ))} +
+
+ + { + if (e.key === "Enter") { + e.preventDefault(); + const input = e.currentTarget; + const path = input.value.trim(); + if (path) { + field.onChange([...(field.value || []), path]); + input.value = ""; + } + } }} /> - - ))} -
-
- - { - if (e.key === "Enter") { - e.preventDefault(); - const input = e.currentTarget; - const path = input.value.trim(); - if (path) { - field.onChange([...(field.value || []), path]); - input.value = ""; - } + + -
- -
- )} - /> + > + + +
+ +
+ )} + /> + )} { const repository = form.watch("repository"); const githubId = form.watch("githubId"); - + const triggerType = form.watch("triggerType"); const { data: repositories, isLoading: isLoadingRepositories } = api.github.getGithubRepositories.useQuery( { @@ -431,84 +431,90 @@ export const SaveGithubProviderCompose = ({ composeId }: Props) => { )} /> - ( - -
- Watch Paths - - - -
- ? -
-
- -

- Add paths to watch for changes. When files in these - paths change, a new deployment will be triggered. -

-
-
-
-
-
- {field.value?.map((path, index) => ( - - {path} - { - const newPaths = [...(field.value || [])]; - newPaths.splice(index, 1); - form.setValue("watchPaths", newPaths); + {triggerType === "push" && ( + ( + +
+ Watch Paths + + + +
+ ? +
+
+ +

+ Add paths to watch for changes. When files in + these paths change, a new deployment will be + triggered. +

+
+
+
+
+
+ {field.value?.map((path, index) => ( + + {path} + { + const newPaths = [...(field.value || [])]; + newPaths.splice(index, 1); + form.setValue("watchPaths", newPaths); + }} + /> + + ))} +
+ +
+ { + if (e.key === "Enter") { + e.preventDefault(); + const input = e.currentTarget; + const value = input.value.trim(); + if (value) { + const newPaths = [ + ...(field.value || []), + value, + ]; + form.setValue("watchPaths", newPaths); + input.value = ""; + } + } }} /> - - ))} -
- -
- { - if (e.key === "Enter") { - e.preventDefault(); - const input = e.currentTarget; + -
-
- -
- )} - /> + }} + > + Add + +
+ + +
+ )} + /> + )}