mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 19:28:16 +00:00
Minor UX update to identities
This commit is contained in:
@@ -13,7 +13,7 @@ export const useGetIdentityUniversalAuth = (identityId: string) => {
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (identityId === "") return undefined;
|
if (identityId === "") throw new Error("Identity ID is required");
|
||||||
|
|
||||||
const { data: { identityUniversalAuth } } = await apiRequest.get<{ identityUniversalAuth: IdentityUniversalAuth }>(
|
const { data: { identityUniversalAuth } } = await apiRequest.get<{ identityUniversalAuth: IdentityUniversalAuth }>(
|
||||||
`/api/v1/auth/universal-auth/identities/${identityId}`
|
`/api/v1/auth/universal-auth/identities/${identityId}`
|
||||||
|
|||||||
+5
-1
@@ -52,8 +52,12 @@ export const IdentitySection = withPermission(
|
|||||||
handlePopUpClose("deleteIdentity");
|
handlePopUpClose("deleteIdentity");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
const error = err as any;
|
||||||
|
const text = error?.response?.data?.message
|
||||||
|
?? "Failed to delete identity"
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to delete identity",
|
text,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-12
@@ -61,7 +61,8 @@ export const IdentityUniversalAuthClientSecretModal = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { createNotification } = useNotificationContext();
|
const { createNotification } = useNotificationContext();
|
||||||
const [token, setToken] = useState("");
|
const [token, setToken] = useState("");
|
||||||
const [isTokenCopied, setIsTokenCopied] = useToggle(false);
|
const [isClientSecretCopied, setIsClientSecretCopied] = useToggle(false);
|
||||||
|
const [isClientIdCopied, setIsClientIdCopied] = useToggle(false);
|
||||||
|
|
||||||
const popUpData = (popUp?.universalAuthClientSecret?.data as {
|
const popUpData = (popUp?.universalAuthClientSecret?.data as {
|
||||||
identityId?: string;
|
identityId?: string;
|
||||||
@@ -90,17 +91,21 @@ export const IdentityUniversalAuthClientSecretModal = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let timer: NodeJS.Timeout;
|
let timer: NodeJS.Timeout;
|
||||||
if (isTokenCopied) {
|
if (isClientSecretCopied) {
|
||||||
timer = setTimeout(() => setIsTokenCopied.off(), 2000);
|
timer = setTimeout(() => setIsClientSecretCopied.off(), 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [isTokenCopied]);
|
}, [isClientSecretCopied]);
|
||||||
|
|
||||||
const copyTokenToClipboard = () => {
|
useEffect(() => {
|
||||||
navigator.clipboard.writeText(token);
|
let timer: NodeJS.Timeout;
|
||||||
setIsTokenCopied.on();
|
if (isClientIdCopied) {
|
||||||
};
|
timer = setTimeout(() => setIsClientIdCopied.off(), 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [isClientIdCopied]);
|
||||||
|
|
||||||
const onFormSubmit = async ({
|
const onFormSubmit = async ({
|
||||||
description,
|
description,
|
||||||
@@ -189,9 +194,12 @@ export const IdentityUniversalAuthClientSecretModal = ({
|
|||||||
ariaLabel="copy icon"
|
ariaLabel="copy icon"
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
className="group relative"
|
className="group relative"
|
||||||
onClick={() => navigator.clipboard.writeText(identityUniversalAuth?.clientId ?? "")}
|
onClick={() => {
|
||||||
|
navigator.clipboard.writeText(identityUniversalAuth?.clientId ?? "")
|
||||||
|
setIsClientIdCopied.on();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={isTokenCopied ? faCheck : faCopy} />
|
<FontAwesomeIcon icon={isClientIdCopied ? faCheck : faCopy} />
|
||||||
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
|
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
|
||||||
{t("common.click-to-copy")}
|
{t("common.click-to-copy")}
|
||||||
</span>
|
</span>
|
||||||
@@ -219,9 +227,12 @@ export const IdentityUniversalAuthClientSecretModal = ({
|
|||||||
ariaLabel="copy icon"
|
ariaLabel="copy icon"
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
className="group relative"
|
className="group relative"
|
||||||
onClick={copyTokenToClipboard}
|
onClick={() => {
|
||||||
|
navigator.clipboard.writeText(token);
|
||||||
|
setIsClientSecretCopied.on();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={isTokenCopied ? faCheck : faCopy} />
|
<FontAwesomeIcon icon={isClientSecretCopied ? faCheck : faCopy} />
|
||||||
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
|
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
|
||||||
{t("common.click-to-copy")}
|
{t("common.click-to-copy")}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user