mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
Merge pull request #3169 from Infisical/bitbucket-workspace-select-fix
Fix: Address Bitbucket Configuration UI Bug Preventing Workspace Selection
This commit is contained in:
+54
-18
@@ -45,17 +45,33 @@ const formSchema = z
|
|||||||
.object({
|
.object({
|
||||||
secretPath: z.string().default("/"),
|
secretPath: z.string().default("/"),
|
||||||
sourceEnvironment: z.object({ name: z.string(), slug: z.string() }),
|
sourceEnvironment: z.object({ name: z.string(), slug: z.string() }),
|
||||||
targetRepo: z.object({ name: z.string(), appId: z.string() }),
|
targetRepo: z.object({ name: z.string(), appId: z.string().optional() }).nullish(),
|
||||||
targetWorkspace: z.object({ name: z.string(), slug: z.string() }),
|
targetWorkspace: z.object({ name: z.string(), slug: z.string() }),
|
||||||
targetEnvironment: z.object({ name: z.string(), uuid: z.string() }).optional(),
|
targetEnvironment: z.object({ name: z.string(), uuid: z.string() }).nullish(),
|
||||||
scope: z.object({ label: z.string(), value: z.nativeEnum(BitbucketScope) })
|
scope: z.object({ label: z.string(), value: z.nativeEnum(BitbucketScope) })
|
||||||
})
|
})
|
||||||
.superRefine((val, ctx) => {
|
.superRefine((val, ctx) => {
|
||||||
|
if (!val.targetWorkspace) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["targetWorkspace"],
|
||||||
|
message: "Bitbucket Workspace required"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!val.targetRepo) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["targetRepo"],
|
||||||
|
message: "Bitbucket Repo required"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (val.scope.value === BitbucketScope.Env && !val.targetEnvironment) {
|
if (val.scope.value === BitbucketScope.Env && !val.targetEnvironment) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
path: ["targetEnvironment"],
|
path: ["targetEnvironment"],
|
||||||
message: "Required"
|
message: "Bitbucket Deployment Environment required"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -66,7 +82,7 @@ export const BitbucketConfigurePage = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const createIntegration = useCreateIntegration();
|
const createIntegration = useCreateIntegration();
|
||||||
|
|
||||||
const { watch, control, reset, handleSubmit } = useForm<TFormData>({
|
const { watch, control, handleSubmit, setValue, reset } = useForm<TFormData>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
secretPath: "/"
|
secretPath: "/"
|
||||||
@@ -90,14 +106,15 @@ export const BitbucketConfigurePage = () => {
|
|||||||
workspaceSlug: bitBucketWorkspace?.slug
|
workspaceSlug: bitBucketWorkspace?.slug
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: bitbucketEnvironments } = useGetIntegrationAuthBitBucketEnvironments(
|
const { data: bitbucketEnvironments, isPending: isBitbucketEnvironmentsLoading } =
|
||||||
{
|
useGetIntegrationAuthBitBucketEnvironments(
|
||||||
integrationAuthId: (integrationAuthId as string) ?? "",
|
{
|
||||||
workspaceSlug: bitBucketWorkspace?.slug,
|
integrationAuthId: (integrationAuthId as string) ?? "",
|
||||||
repoSlug: bitBucketRepo?.appId
|
workspaceSlug: bitBucketWorkspace?.slug ?? "",
|
||||||
},
|
repoSlug: bitBucketRepo?.appId ?? ""
|
||||||
{ enabled: Boolean(bitBucketWorkspace?.slug && bitBucketRepo?.appId) }
|
},
|
||||||
);
|
{ enabled: Boolean(bitBucketWorkspace?.slug && bitBucketRepo?.appId) }
|
||||||
|
);
|
||||||
|
|
||||||
const onSubmit = async ({
|
const onSubmit = async ({
|
||||||
targetRepo,
|
targetRepo,
|
||||||
@@ -107,6 +124,8 @@ export const BitbucketConfigurePage = () => {
|
|||||||
targetEnvironment,
|
targetEnvironment,
|
||||||
scope
|
scope
|
||||||
}: TFormData) => {
|
}: TFormData) => {
|
||||||
|
if (!targetRepo || !targetWorkspace) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createIntegration.mutateAsync({
|
await createIntegration.mutateAsync({
|
||||||
integrationAuthId,
|
integrationAuthId,
|
||||||
@@ -147,7 +166,14 @@ export const BitbucketConfigurePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!bitbucketRepos || !bitbucketWorkspaces || !currentWorkspace) return;
|
if (
|
||||||
|
bitBucketWorkspace ||
|
||||||
|
bitBucketRepo ||
|
||||||
|
!bitbucketRepos ||
|
||||||
|
!bitbucketWorkspaces ||
|
||||||
|
!currentWorkspace
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
reset({
|
reset({
|
||||||
targetRepo: bitbucketRepos[0],
|
targetRepo: bitbucketRepos[0],
|
||||||
@@ -224,12 +250,17 @@ export const BitbucketConfigurePage = () => {
|
|||||||
getOptionValue={(option) => option.slug}
|
getOptionValue={(option) => option.slug}
|
||||||
value={value}
|
value={value}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
onChange={onChange}
|
onChange={(option) => {
|
||||||
|
onChange(option);
|
||||||
|
setValue("targetRepo", null);
|
||||||
|
setValue("targetEnvironment", null);
|
||||||
|
}}
|
||||||
options={bitbucketWorkspaces}
|
options={bitbucketWorkspaces}
|
||||||
placeholder={
|
placeholder={
|
||||||
bitbucketWorkspaces?.length ? "Select a workspace..." : "No workspaces found..."
|
bitbucketWorkspaces?.length ? "Select a workspace..." : "No workspaces found..."
|
||||||
}
|
}
|
||||||
isDisabled={!bitbucketWorkspaces?.length}
|
isLoading={isBitbucketWorkspacesLoading}
|
||||||
|
isDisabled={!bitbucketWorkspaces?.length || isBitbucketWorkspacesLoading}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
@@ -243,12 +274,16 @@ export const BitbucketConfigurePage = () => {
|
|||||||
getOptionValue={(option) => option.appId!}
|
getOptionValue={(option) => option.appId!}
|
||||||
value={value}
|
value={value}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
onChange={onChange}
|
onChange={(option) => {
|
||||||
|
onChange(option);
|
||||||
|
setValue("targetEnvironment", null);
|
||||||
|
}}
|
||||||
options={bitbucketRepos}
|
options={bitbucketRepos}
|
||||||
placeholder={
|
placeholder={
|
||||||
bitbucketRepos?.length ? "Select a repository..." : "No repositories found..."
|
bitbucketRepos?.length ? "Select a repository..." : "No repositories found..."
|
||||||
}
|
}
|
||||||
isDisabled={!bitbucketRepos?.length}
|
isLoading={isBitbucketReposLoading}
|
||||||
|
isDisabled={!bitbucketRepos?.length || isBitbucketReposLoading}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
@@ -290,7 +325,8 @@ export const BitbucketConfigurePage = () => {
|
|||||||
? "Select an environment..."
|
? "Select an environment..."
|
||||||
: "No environments found..."
|
: "No environments found..."
|
||||||
}
|
}
|
||||||
isDisabled={!bitbucketEnvironments?.length}
|
isLoading={isBitbucketEnvironmentsLoading && Boolean(bitBucketRepo)}
|
||||||
|
isDisabled={!bitbucketEnvironments?.length || isBitbucketEnvironmentsLoading}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user