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

View File

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