mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 10:29:17 +00:00
fix: address changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { apiRequest } from "@app/config/request";
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
@@ -13,7 +13,8 @@ import {
|
|||||||
IdentityMembershipOrg,
|
IdentityMembershipOrg,
|
||||||
IdentityOidcAuth,
|
IdentityOidcAuth,
|
||||||
IdentityTokenAuth,
|
IdentityTokenAuth,
|
||||||
IdentityUniversalAuth} from "./types";
|
IdentityUniversalAuth
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
export const identitiesKeys = {
|
export const identitiesKeys = {
|
||||||
getIdentityById: (identityId: string) => [{ identityId }, "identity"] as const,
|
getIdentityById: (identityId: string) => [{ identityId }, "identity"] as const,
|
||||||
@@ -64,9 +65,16 @@ export const useGetIdentityProjectMemberships = (identityId: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityUniversalAuth = (identityId: string) => {
|
export const useGetIdentityUniversalAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityUniversalAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityUniversalAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityUniversalAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -76,8 +84,10 @@ export const useGetIdentityUniversalAuth = (identityId: string) => {
|
|||||||
);
|
);
|
||||||
return identityUniversalAuth;
|
return identityUniversalAuth;
|
||||||
},
|
},
|
||||||
|
cacheTime: 0,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,9 +106,16 @@ export const useGetIdentityUniversalAuthClientSecrets = (identityId: string) =>
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityGcpAuth = (identityId: string) => {
|
export const useGetIdentityGcpAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityGcpAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityGcpAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityGcpAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityGcpAuth(identityId),
|
queryKey: identitiesKeys.getIdentityGcpAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -109,13 +126,22 @@ export const useGetIdentityGcpAuth = (identityId: string) => {
|
|||||||
return identityGcpAuth;
|
return identityGcpAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityAwsAuth = (identityId: string) => {
|
export const useGetIdentityAwsAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityAwsAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityAwsAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityAwsAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityAwsAuth(identityId),
|
queryKey: identitiesKeys.getIdentityAwsAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -126,13 +152,22 @@ export const useGetIdentityAwsAuth = (identityId: string) => {
|
|||||||
return identityAwsAuth;
|
return identityAwsAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityAzureAuth = (identityId: string) => {
|
export const useGetIdentityAzureAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityAzureAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityAzureAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityAzureAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityAzureAuth(identityId),
|
queryKey: identitiesKeys.getIdentityAzureAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -143,13 +178,22 @@ export const useGetIdentityAzureAuth = (identityId: string) => {
|
|||||||
return identityAzureAuth;
|
return identityAzureAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityKubernetesAuth = (identityId: string) => {
|
export const useGetIdentityKubernetesAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityKubernetesAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityKubernetesAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityKubernetesAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId),
|
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -160,13 +204,22 @@ export const useGetIdentityKubernetesAuth = (identityId: string) => {
|
|||||||
return identityKubernetesAuth;
|
return identityKubernetesAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityTokenAuth = (identityId: string) => {
|
export const useGetIdentityTokenAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityTokenAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityTokenAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityTokenAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityTokenAuth(identityId),
|
queryKey: identitiesKeys.getIdentityTokenAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -177,7 +230,9 @@ export const useGetIdentityTokenAuth = (identityId: string) => {
|
|||||||
return identityTokenAuth;
|
return identityTokenAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,9 +251,16 @@ export const useGetIdentityTokensTokenAuth = (identityId: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetIdentityOidcAuth = (identityId: string) => {
|
export const useGetIdentityOidcAuth = (
|
||||||
|
identityId: string,
|
||||||
|
options?: UseQueryOptions<
|
||||||
|
IdentityOidcAuth,
|
||||||
|
unknown,
|
||||||
|
IdentityOidcAuth,
|
||||||
|
ReturnType<typeof identitiesKeys.getIdentityOidcAuth>
|
||||||
|
>
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: Boolean(identityId),
|
|
||||||
queryKey: identitiesKeys.getIdentityOidcAuth(identityId),
|
queryKey: identitiesKeys.getIdentityOidcAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {
|
const {
|
||||||
@@ -209,6 +271,8 @@ export const useGetIdentityOidcAuth = (identityId: string) => {
|
|||||||
return identityOidcAuth;
|
return identityOidcAuth;
|
||||||
},
|
},
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
cacheTime: 0
|
cacheTime: 0,
|
||||||
|
...options,
|
||||||
|
enabled: Boolean(identityId) && (options?.enabled ?? true)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
+22
-12
@@ -21,7 +21,8 @@ import {
|
|||||||
useDeleteIdentityKubernetesAuth,
|
useDeleteIdentityKubernetesAuth,
|
||||||
useDeleteIdentityOidcAuth,
|
useDeleteIdentityOidcAuth,
|
||||||
useDeleteIdentityTokenAuth,
|
useDeleteIdentityTokenAuth,
|
||||||
useDeleteIdentityUniversalAuth} from "@app/hooks/api";
|
useDeleteIdentityUniversalAuth
|
||||||
|
} from "@app/hooks/api";
|
||||||
import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api/identities";
|
import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api/identities";
|
||||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
@@ -54,7 +55,10 @@ const identityAuthMethods = [
|
|||||||
|
|
||||||
const schema = yup
|
const schema = yup
|
||||||
.object({
|
.object({
|
||||||
authMethod: yup.mixed<IdentityAuthMethod>().oneOf(Object.values(IdentityAuthMethod)).required("Auth method is required")
|
authMethod: yup
|
||||||
|
.mixed<IdentityAuthMethod>()
|
||||||
|
.oneOf(Object.values(IdentityAuthMethod))
|
||||||
|
.required("Auth method is required")
|
||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
@@ -74,13 +78,19 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
|
|
||||||
const initialAuthMethod = popUp?.identityAuthMethod?.data?.authMethod;
|
const initialAuthMethod = popUp?.identityAuthMethod?.data?.authMethod;
|
||||||
|
|
||||||
const { control, watch, setValue } = useForm<FormData>({
|
const { control, watch, setValue, reset } = useForm<FormData>({
|
||||||
resolver: yupResolver(schema),
|
resolver: yupResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
authMethod: initialAuthMethod
|
authMethod: initialAuthMethod
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// reset form on open
|
||||||
|
if (popUp.identityAuthMethod.isOpen)
|
||||||
|
reset({ authMethod: popUp?.identityAuthMethod?.data?.authMethod });
|
||||||
|
}, [popUp.identityAuthMethod.isOpen]);
|
||||||
|
|
||||||
const identityAuthMethodData = {
|
const identityAuthMethodData = {
|
||||||
identityId: popUp?.identityAuthMethod.data?.identityId,
|
identityId: popUp?.identityAuthMethod.data?.identityId,
|
||||||
name: popUp?.identityAuthMethod?.data?.name,
|
name: popUp?.identityAuthMethod?.data?.name,
|
||||||
@@ -103,7 +113,6 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
const onRevokeAuthMethodSubmit = async (authMethod: IdentityAuthMethod) => {
|
const onRevokeAuthMethodSubmit = async (authMethod: IdentityAuthMethod) => {
|
||||||
if (!orgId || !authMethod) return;
|
if (!orgId || !authMethod) return;
|
||||||
try {
|
try {
|
||||||
console.log("onRevokeAuthMethodSubmit identityId: ", identityAuthMethodData);
|
|
||||||
switch (authMethod) {
|
switch (authMethod) {
|
||||||
case IdentityAuthMethod.UNIVERSAL_AUTH: {
|
case IdentityAuthMethod.UNIVERSAL_AUTH: {
|
||||||
await revokeUniversalAuth({
|
await revokeUniversalAuth({
|
||||||
@@ -159,9 +168,7 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
}
|
}
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully removed ${
|
text: `Successfully removed ${identityAuthToNameMap[authMethod]} on ${identityAuthMethodData.name}`,
|
||||||
identityAuthToNameMap[authMethod]
|
|
||||||
} on ${identityAuthMethodData.name}`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,9 +177,7 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Failed to remove ${identityAuthToNameMap[authMethod]} on ${
|
text: `Failed to remove ${identityAuthToNameMap[authMethod]} on ${identityAuthMethodData.name}`,
|
||||||
identityAuthMethodData.name
|
|
||||||
}`,
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -272,7 +277,9 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
<ModalContent
|
<ModalContent
|
||||||
title={`${
|
title={`${
|
||||||
identityAuthMethodData.authMethod === initialAuthMethod ? "Update" : "Configure"
|
identityAuthMethodData.authMethod === initialAuthMethod ? "Update" : "Configure"
|
||||||
} Identity Auth Method for ${identityAuthToNameMap[identityAuthMethodData.authMethod!] ?? ""}`}
|
} Identity Auth Method for ${
|
||||||
|
identityAuthToNameMap[identityAuthMethodData.authMethod!] ?? ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -283,7 +290,9 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
<Select
|
<Select
|
||||||
defaultValue={field.value}
|
defaultValue={field.value}
|
||||||
{...field}
|
{...field}
|
||||||
onValueChange={(e) => {onChange(e)}}
|
onValueChange={(e) => {
|
||||||
|
onChange(e);
|
||||||
|
}}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
{identityAuthMethods.map(({ label, value }) => (
|
{identityAuthMethods.map(({ label, value }) => (
|
||||||
@@ -310,6 +319,7 @@ export const IdentityAuthMethodModal = ({ popUp, handlePopUpOpen, handlePopUpTog
|
|||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
} on ${identityAuthMethodData?.name ?? ""}?`}
|
||||||
onChange={(isOpen) => handlePopUpToggle("revokeAuthMethod", isOpen)}
|
onChange={(isOpen) => handlePopUpToggle("revokeAuthMethod", isOpen)}
|
||||||
deleteKey="confirm"
|
deleteKey="confirm"
|
||||||
|
buttonText="Remove"
|
||||||
onDeleteApproved={() => onRevokeAuthMethodSubmit(identityAuthMethodData.authMethod!)}
|
onDeleteApproved={() => onRevokeAuthMethodSubmit(identityAuthMethodData.authMethod!)}
|
||||||
/>
|
/>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|||||||
+30
-21
@@ -82,11 +82,12 @@ export const IdentityAwsAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityAwsAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityAwsAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityAwsAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityAwsAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityAwsAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
|
const { data } = useGetIdentityAwsAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
|
enabled: isCurrentAuthMethod
|
||||||
|
});
|
||||||
|
|
||||||
const popup = usePopUp([
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
"overwriteAuthMethod",
|
|
||||||
] as const);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -183,8 +184,7 @@ export const IdentityAwsAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -198,6 +198,7 @@ export const IdentityAwsAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -352,24 +353,27 @@ export const IdentityAwsAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
>
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -378,7 +382,7 @@ export const IdentityAwsAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -390,15 +394,20 @@ export const IdentityAwsAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
|
||||||
title={`Are you sure want to overwrite ${
|
|
||||||
initialAuthMethod || "the auth method"
|
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
|
||||||
deleteKey="confirm"
|
|
||||||
onDeleteApproved={async () => { await revokeAuth(initialAuthMethod); handleSubmit(onFormSubmit)(); }}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
|
identityAuthMethodData?.name ?? ""
|
||||||
|
}?`}
|
||||||
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
|
onDeleteApproved={async () => {
|
||||||
|
await revokeAuth(initialAuthMethod);
|
||||||
|
handleSubmit(onFormSubmit)();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+26
-20
@@ -70,11 +70,12 @@ export const IdentityAzureAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityAzureAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityAzureAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityAzureAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityAzureAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityAzureAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
|
const { data } = useGetIdentityAzureAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
|
enabled: isCurrentAuthMethod
|
||||||
|
});
|
||||||
|
|
||||||
const popup = usePopUp([
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
"overwriteAuthMethod",
|
|
||||||
] as const);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -172,8 +173,7 @@ export const IdentityAzureAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -187,6 +187,7 @@ export const IdentityAzureAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -341,23 +342,27 @@ export const IdentityAzureAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}>
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -366,7 +371,7 @@ export const IdentityAzureAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -378,13 +383,15 @@ export const IdentityAzureAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
<DeleteActionModal
|
<DeleteActionModal
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
title={`Are you sure want to overwrite ${
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
initialAuthMethod || "the auth method"
|
identityAuthMethodData?.name ?? ""
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
}?`}
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
deleteKey="confirm"
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
onDeleteApproved={async () => {
|
onDeleteApproved={async () => {
|
||||||
const result = await trigger();
|
const result = await trigger();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -395,11 +402,10 @@ export const IdentityAzureAuthForm = ({
|
|||||||
text: "Please fill in all required fields",
|
text: "Please fill in all required fields",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
popup.handlePopUpToggle("overwriteAuthMethod", false);
|
internalPopUpState.handlePopUpToggle("overwriteAuthMethod", false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
</form>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+45
-25
@@ -6,7 +6,15 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, DeleteActionModal, FormControl, IconButton, Input, Select, SelectItem } from "@app/components/v2";
|
import {
|
||||||
|
Button,
|
||||||
|
DeleteActionModal,
|
||||||
|
FormControl,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
SelectItem
|
||||||
|
} from "@app/components/v2";
|
||||||
import { useOrganization, useSubscription } from "@app/context";
|
import { useOrganization, useSubscription } from "@app/context";
|
||||||
import {
|
import {
|
||||||
useAddIdentityGcpAuth,
|
useAddIdentityGcpAuth,
|
||||||
@@ -71,17 +79,18 @@ export const IdentityGcpAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityGcpAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityGcpAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityGcpAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityGcpAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityGcpAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
const popup = usePopUp([
|
const { data } = useGetIdentityGcpAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
"overwriteAuthMethod",
|
enabled: isCurrentAuthMethod
|
||||||
] as const);
|
});
|
||||||
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
reset,
|
reset,
|
||||||
formState: { isSubmitting },
|
formState: { isSubmitting },
|
||||||
watch,
|
watch
|
||||||
} = useForm<FormData>({
|
} = useForm<FormData>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -180,12 +189,10 @@ export const IdentityGcpAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createNotification({
|
createNotification({
|
||||||
@@ -196,6 +203,7 @@ export const IdentityGcpAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -256,7 +264,11 @@ export const IdentityGcpAuthForm = ({
|
|||||||
control={control}
|
control={control}
|
||||||
name="allowedZones"
|
name="allowedZones"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl label="Allowed Zones" isError={Boolean(error)} errorText={error?.message}>
|
<FormControl
|
||||||
|
label="Allowed Zones"
|
||||||
|
isError={Boolean(error)}
|
||||||
|
errorText={error?.message}
|
||||||
|
>
|
||||||
<Input {...field} placeholder="us-west2-a, us-central1-a, ..." />
|
<Input {...field} placeholder="us-west2-a, us-central1-a, ..." />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
@@ -374,24 +386,27 @@ export const IdentityGcpAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
>
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -400,7 +415,7 @@ export const IdentityGcpAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -412,15 +427,20 @@ export const IdentityGcpAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
|
||||||
title={`Are you sure want to overwrite ${
|
|
||||||
initialAuthMethod || "the auth method"
|
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
|
||||||
deleteKey="confirm"
|
|
||||||
onDeleteApproved={async () => { await revokeAuth(initialAuthMethod); handleSubmit(onFormSubmit)(); }}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
|
identityAuthMethodData?.name ?? ""
|
||||||
|
}?`}
|
||||||
|
buttonText="Overwrite"
|
||||||
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
|
deleteKey="confirm"
|
||||||
|
onDeleteApproved={async () => {
|
||||||
|
await revokeAuth(initialAuthMethod);
|
||||||
|
handleSubmit(onFormSubmit)();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+38
-23
@@ -6,7 +6,14 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, DeleteActionModal, FormControl, IconButton, Input, TextArea } from "@app/components/v2";
|
import {
|
||||||
|
Button,
|
||||||
|
DeleteActionModal,
|
||||||
|
FormControl,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
TextArea
|
||||||
|
} from "@app/components/v2";
|
||||||
import { useOrganization, useSubscription } from "@app/context";
|
import { useOrganization, useSubscription } from "@app/context";
|
||||||
import {
|
import {
|
||||||
useAddIdentityKubernetesAuth,
|
useAddIdentityKubernetesAuth,
|
||||||
@@ -73,17 +80,18 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityKubernetesAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityKubernetesAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityKubernetesAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityKubernetesAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityKubernetesAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
const popup = usePopUp([
|
const { data } = useGetIdentityKubernetesAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
"overwriteAuthMethod",
|
enabled: isCurrentAuthMethod
|
||||||
] as const);
|
});
|
||||||
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
reset,
|
reset,
|
||||||
trigger,
|
trigger,
|
||||||
formState: { isSubmitting },
|
formState: { isSubmitting }
|
||||||
} = useForm<FormData>({
|
} = useForm<FormData>({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -192,8 +200,7 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,6 +214,7 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -275,7 +283,8 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="Allowed Audience"
|
label="Allowed Audience"
|
||||||
isError={Boolean(error)} errorText={error?.message}
|
isError={Boolean(error)}
|
||||||
|
errorText={error?.message}
|
||||||
tooltipText="An optional audience claim that the service account JWT token must have to authenticate with Infisical. Leave empty to allow any audience claim."
|
tooltipText="An optional audience claim that the service account JWT token must have to authenticate with Infisical. Leave empty to allow any audience claim."
|
||||||
>
|
>
|
||||||
<Input {...field} placeholder="" type="text" />
|
<Input {...field} placeholder="" type="text" />
|
||||||
@@ -288,7 +297,8 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
label="CA Certificate"
|
label="CA Certificate"
|
||||||
errorText={error?.message} isError={Boolean(error)}
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error)}
|
||||||
tooltipText="An optional PEM-encoded CA cert for the Kubernetes API server. This is used by the TLS client for secure communication with the Kubernetes API server."
|
tooltipText="An optional PEM-encoded CA cert for the Kubernetes API server. This is used by the TLS client for secure communication with the Kubernetes API server."
|
||||||
>
|
>
|
||||||
<TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
|
<TextArea {...field} placeholder="-----BEGIN CERTIFICATE----- ..." />
|
||||||
@@ -411,24 +421,27 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
>
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -437,7 +450,7 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -449,13 +462,15 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
<DeleteActionModal
|
<DeleteActionModal
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
title={`Are you sure want to overwrite ${
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
initialAuthMethod || "the auth method"
|
identityAuthMethodData?.name ?? ""
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
}?`}
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
deleteKey="confirm"
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
onDeleteApproved={async () => {
|
onDeleteApproved={async () => {
|
||||||
const result = await trigger();
|
const result = await trigger();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -466,10 +481,10 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
text: "Please fill in all required fields",
|
text: "Please fill in all required fields",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
popup.handlePopUpToggle("overwriteAuthMethod", false);
|
internalPopUpState.handlePopUpToggle("overwriteAuthMethod", false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</form>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+34
-20
@@ -7,7 +7,15 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { Button, DeleteActionModal,FormControl, IconButton, Input, TextArea, Tooltip } from "@app/components/v2";
|
import {
|
||||||
|
Button,
|
||||||
|
DeleteActionModal,
|
||||||
|
FormControl,
|
||||||
|
IconButton,
|
||||||
|
Input,
|
||||||
|
TextArea,
|
||||||
|
Tooltip
|
||||||
|
} from "@app/components/v2";
|
||||||
import { useOrganization, useSubscription } from "@app/context";
|
import { useOrganization, useSubscription } from "@app/context";
|
||||||
import { useAddIdentityOidcAuth, useUpdateIdentityOidcAuth } from "@app/hooks/api";
|
import { useAddIdentityOidcAuth, useUpdateIdentityOidcAuth } from "@app/hooks/api";
|
||||||
import { IdentityAuthMethod } from "@app/hooks/api/identities";
|
import { IdentityAuthMethod } from "@app/hooks/api/identities";
|
||||||
@@ -74,10 +82,11 @@ export const IdentityOidcAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityOidcAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityOidcAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityOidcAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityOidcAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityOidcAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
const popup = usePopUp([
|
const { data } = useGetIdentityOidcAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
"overwriteAuthMethod",
|
enabled: isCurrentAuthMethod
|
||||||
] as const);
|
});
|
||||||
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -201,8 +210,7 @@ export const IdentityOidcAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -216,6 +224,7 @@ export const IdentityOidcAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -495,24 +504,27 @@ export const IdentityOidcAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
>
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -521,7 +533,7 @@ export const IdentityOidcAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -533,13 +545,15 @@ export const IdentityOidcAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
<DeleteActionModal
|
<DeleteActionModal
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
title={`Are you sure want to overwrite ${
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
initialAuthMethod || "the auth method"
|
identityAuthMethodData?.name ?? ""
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
}?`}
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
deleteKey="confirm"
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
onDeleteApproved={async () => {
|
onDeleteApproved={async () => {
|
||||||
const result = await trigger();
|
const result = await trigger();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -550,10 +564,10 @@ export const IdentityOidcAuthForm = ({
|
|||||||
text: "Please fill in all required fields",
|
text: "Please fill in all required fields",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
popup.handlePopUpToggle("overwriteAuthMethod", false);
|
internalPopUpState.handlePopUpToggle("overwriteAuthMethod", false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</form>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+32
-22
@@ -65,10 +65,11 @@ export const IdentityTokenAuthForm = ({
|
|||||||
const { mutateAsync: addMutateAsync } = useAddIdentityTokenAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityTokenAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityTokenAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityTokenAuth();
|
||||||
|
|
||||||
const { data } = useGetIdentityTokenAuth(identityAuthMethodData?.identityId ?? "");
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
const popup = usePopUp([
|
const { data } = useGetIdentityTokenAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
"overwriteAuthMethod",
|
enabled: isCurrentAuthMethod
|
||||||
] as const);
|
});
|
||||||
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -123,21 +124,21 @@ export const IdentityTokenAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Failed to ${identityAuthMethodData?.authMethod === initialAuthMethod ? "update" : "configure"} identity`,
|
text: `Failed to ${isCurrentAuthMethod ? "update" : "configure"} identity`,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -251,23 +252,27 @@ export const IdentityTokenAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}>
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -276,7 +281,7 @@ export const IdentityTokenAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -288,15 +293,20 @@ export const IdentityTokenAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
|
||||||
title={`Are you sure want to overwrite ${
|
|
||||||
initialAuthMethod || "the auth method"
|
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
|
||||||
deleteKey="confirm"
|
|
||||||
onDeleteApproved={async () => { await revokeAuth(initialAuthMethod); handleSubmit(onFormSubmit)(); }}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
|
identityAuthMethodData?.name ?? ""
|
||||||
|
}?`}
|
||||||
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
|
onDeleteApproved={async () => {
|
||||||
|
await revokeAuth(initialAuthMethod);
|
||||||
|
handleSubmit(onFormSubmit)();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+31
-21
@@ -86,10 +86,12 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
|
const { mutateAsync: addMutateAsync } = useAddIdentityUniversalAuth();
|
||||||
const { mutateAsync: updateMutateAsync } = useUpdateIdentityUniversalAuth();
|
const { mutateAsync: updateMutateAsync } = useUpdateIdentityUniversalAuth();
|
||||||
const { data } = useGetIdentityUniversalAuth(identityAuthMethodData?.identityId ?? "");
|
|
||||||
const popup = usePopUp([
|
const isCurrentAuthMethod = identityAuthMethodData?.authMethod === initialAuthMethod;
|
||||||
"overwriteAuthMethod",
|
const { data } = useGetIdentityUniversalAuth(identityAuthMethodData?.identityId ?? "", {
|
||||||
] as const);
|
enabled: isCurrentAuthMethod
|
||||||
|
});
|
||||||
|
const internalPopUpState = usePopUp(["overwriteAuthMethod"] as const);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@@ -188,8 +190,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
handlePopUpToggle("identityAuthMethod", false);
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${identityAuthMethodData?.authMethod === initialAuthMethod ? "updated" : "configured"
|
text: `Successfully ${isCurrentAuthMethod ? "updated" : "configured"} auth method`,
|
||||||
} auth method`,
|
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -209,6 +210,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@@ -390,24 +392,27 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{(initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod) ?
|
{initialAuthMethod && identityAuthMethodData?.authMethod !== initialAuthMethod ? (
|
||||||
<Button
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
onClick={() => popup.handlePopUpToggle("overwriteAuthMethod", true)}
|
onClick={() => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", true)}
|
||||||
>
|
>
|
||||||
Overwrite
|
Overwrite
|
||||||
</Button>
|
</Button>
|
||||||
: <Button
|
) : (
|
||||||
|
<Button
|
||||||
className="mr-4"
|
className="mr-4"
|
||||||
size="sm"
|
size="sm"
|
||||||
type="submit"
|
type="submit"
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
isDisabled={isSubmitting}
|
isDisabled={isSubmitting}
|
||||||
>Submit</Button>
|
>
|
||||||
}
|
Submit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
@@ -416,7 +421,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{identityAuthMethodData?.authMethod === initialAuthMethod && (
|
{isCurrentAuthMethod && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
colorSchema="danger"
|
colorSchema="danger"
|
||||||
@@ -428,15 +433,20 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popup.popUp.overwriteAuthMethod?.isOpen}
|
|
||||||
title={`Are you sure want to overwrite ${
|
|
||||||
initialAuthMethod || "the auth method"
|
|
||||||
} on ${identityAuthMethodData?.name ?? ""}?`}
|
|
||||||
onChange={(isOpen) => popup.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
|
||||||
deleteKey="confirm"
|
|
||||||
onDeleteApproved={async () => { await revokeAuth(initialAuthMethod); handleSubmit(onFormSubmit)(); }}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
|
<DeleteActionModal
|
||||||
|
isOpen={internalPopUpState.popUp.overwriteAuthMethod?.isOpen}
|
||||||
|
title={`Are you sure want to overwrite ${initialAuthMethod || "the auth method"} on ${
|
||||||
|
identityAuthMethodData?.name ?? ""
|
||||||
|
}?`}
|
||||||
|
onChange={(isOpen) => internalPopUpState.handlePopUpToggle("overwriteAuthMethod", isOpen)}
|
||||||
|
deleteKey="confirm"
|
||||||
|
buttonText="Overwrite"
|
||||||
|
onDeleteApproved={async () => {
|
||||||
|
await revokeAuth(initialAuthMethod);
|
||||||
|
handleSubmit(onFormSubmit)();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user