Fix apps/console lint issues
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -6,8 +6,8 @@ import type { APIKeysPageQuery } from "/__generated__/iam/APIKeysPageQuery.graph
|
||||
import { IAMRelayProvider } from "/providers/IAMRelayProvider";
|
||||
|
||||
function APIKeysPageLoaderInner() {
|
||||
const [queryRef, loadQuery] =
|
||||
useQueryLoader<APIKeysPageQuery>(apiKeysPageQuery);
|
||||
const [queryRef, loadQuery]
|
||||
= useQueryLoader<APIKeysPageQuery>(apiKeysPageQuery);
|
||||
|
||||
useEffect(() => {
|
||||
loadQuery({});
|
||||
|
||||
@@ -107,25 +107,25 @@ export function PersonalAPIKeyList(props: {
|
||||
|
||||
const connectionID = ConnectionHandler.getConnectionID(
|
||||
viewer.id,
|
||||
"PersonalAPIKeyListFragment_personalAPIKeys"
|
||||
"PersonalAPIKeyListFragment_personalAPIKeys",
|
||||
);
|
||||
|
||||
const { formState, handleSubmit, register, control, reset } =
|
||||
useFormWithSchema(createSchema, {
|
||||
const { formState, handleSubmit, register, control, reset }
|
||||
= useFormWithSchema(createSchema, {
|
||||
defaultValues: {
|
||||
name: new Date().toISOString().split("T")[0],
|
||||
expiresIn: "1month",
|
||||
},
|
||||
});
|
||||
|
||||
const [createCommit, isCreating] =
|
||||
useMutation<PersonalAPIKeyListCreateMutation>(createMutation);
|
||||
const [createCommit, isCreating]
|
||||
= useMutation<PersonalAPIKeyListCreateMutation>(createMutation);
|
||||
|
||||
const handleCreate = (data: CreateFormData) => {
|
||||
const expiresAt = computeExpiresAt(data.expiresIn);
|
||||
const connectionID = ConnectionHandler.getConnectionID(
|
||||
viewer.id,
|
||||
"PersonalAPIKeyListFragment_personalAPIKeys"
|
||||
"PersonalAPIKeyListFragment_personalAPIKeys",
|
||||
);
|
||||
|
||||
createCommit({
|
||||
@@ -170,25 +170,27 @@ export function PersonalAPIKeyList(props: {
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{viewer.personalAPIKeys.edges.length === 0 ? (
|
||||
<Card padded>
|
||||
<div className="text-center py-12">
|
||||
<h3 className="text-lg font-medium text-gray-900 mb-2">
|
||||
{__("No API keys")}
|
||||
</h3>
|
||||
<p className="text-gray-600 mb-6">
|
||||
{__("Create an API key to authenticate programmatic access.")}
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<Card padded>
|
||||
<PersonalAPIKeysTable
|
||||
edges={viewer.personalAPIKeys.edges}
|
||||
connectionId={connectionID}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
{viewer.personalAPIKeys.edges.length === 0
|
||||
? (
|
||||
<Card padded>
|
||||
<div className="text-center py-12">
|
||||
<h3 className="text-lg font-medium text-gray-900 mb-2">
|
||||
{__("No API keys")}
|
||||
</h3>
|
||||
<p className="text-gray-600 mb-6">
|
||||
{__("Create an API key to authenticate programmatic access.")}
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
: (
|
||||
<Card padded>
|
||||
<PersonalAPIKeysTable
|
||||
edges={viewer.personalAPIKeys.edges}
|
||||
connectionId={connectionID}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
@@ -196,7 +198,7 @@ export function PersonalAPIKeyList(props: {
|
||||
title={<Breadcrumb items={[__("API Keys"), __("Create")]} />}
|
||||
onClose={() => reset()}
|
||||
>
|
||||
<form onSubmit={handleSubmit(handleCreate)}>
|
||||
<form onSubmit={e => void handleSubmit(handleCreate)(e)}>
|
||||
<DialogContent padded className="space-y-5">
|
||||
<Field error={formState.errors.name?.message}>
|
||||
<Label>{__("Name")}</Label>
|
||||
|
||||
@@ -46,8 +46,8 @@ export function PersonalAPIKeyRow(props: {
|
||||
const key = useFragment(personalAPIKeyRowFragment, fKey);
|
||||
const expired = new Date(key.expiresAt) < now;
|
||||
|
||||
const [revokeCommit, isRevoking] =
|
||||
useMutation<PersonalAPIKeyRow_revokeMutation>(revokeMutation);
|
||||
const [revokeCommit, isRevoking]
|
||||
= useMutation<PersonalAPIKeyRow_revokeMutation>(revokeMutation);
|
||||
|
||||
const handleRevoke = () => {
|
||||
confirm(
|
||||
@@ -64,11 +64,11 @@ export function PersonalAPIKeyRow(props: {
|
||||
title: __("Error"),
|
||||
description: formatError(
|
||||
__("Failed to revoke API key."),
|
||||
errors as GraphQLError[]
|
||||
errors as GraphQLError[],
|
||||
),
|
||||
variant: "error",
|
||||
});
|
||||
reject(errors);
|
||||
reject(new Error(errors[0]?.message ?? __("Failed to revoke API key.")));
|
||||
return;
|
||||
}
|
||||
toast({
|
||||
@@ -83,7 +83,7 @@ export function PersonalAPIKeyRow(props: {
|
||||
title: __("Error"),
|
||||
description: formatError(
|
||||
__("Failed to revoke API key."),
|
||||
error
|
||||
error,
|
||||
),
|
||||
variant: "error",
|
||||
});
|
||||
@@ -95,11 +95,11 @@ export function PersonalAPIKeyRow(props: {
|
||||
{
|
||||
title: __("Revoke API Key"),
|
||||
message: __(
|
||||
`Are you sure you want to revoke the API key "${key.name}"? This action cannot be undone.`
|
||||
`Are you sure you want to revoke the API key "${key.name}"? This action cannot be undone.`,
|
||||
),
|
||||
label: __("Revoke"),
|
||||
variant: "danger",
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ export function PersonalAPIKeyTokenAction(props: {
|
||||
title: __("Error"),
|
||||
description: formatError(
|
||||
__("Failed to load API key token."),
|
||||
error
|
||||
error,
|
||||
),
|
||||
variant: "error",
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user