feat(sh-admin): introducing infra-tokens to admin dashboard (#4202)

Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Joel Jacob Stephen
2024-07-29 15:20:06 +03:00
committed by GitHub
parent 783d911f8d
commit c24d5c5302
18 changed files with 753 additions and 74 deletions

View File

@@ -0,0 +1,12 @@
mutation CreateInfraToken($label: String!, $expiryInDays: Int) {
createInfraToken(label: $label, expiryInDays: $expiryInDays) {
info {
id
label
lastUsedOn
createdOn
expiresOn
}
token
}
}

View File

@@ -0,0 +1,3 @@
mutation RevokeInfraToken($id: ID!) {
revokeInfraToken(id: $id)
}

View File

@@ -0,0 +1,9 @@
query InfraTokens($skip: Int, $take: Int) {
infraTokens(skip: $skip, take: $take) {
id
label
createdOn
lastUsedOn
expiresOn
}
}

View File

@@ -36,6 +36,9 @@ export const AUTH_PROVIDER_NOT_SPECIFIED =
export const BOTH_EMAILS_CANNOT_BE_SAME =
'[GraphQL] email/both_emails_cannot_be_same' as const;
export const INFRA_TOKEN_LABEL_SHORT =
'[GraphQL] infra_token/label_too_short' as const;
type ErrorMessages = {
message: string;
alternateMessage?: string;
@@ -68,6 +71,9 @@ const ERROR_MESSAGES: Record<string, ErrorMessages> = {
[BOTH_EMAILS_CANNOT_BE_SAME]: {
message: 'state.emails_cannot_be_same',
},
[INFRA_TOKEN_LABEL_SHORT]: {
message: 'state.infra_token_label_short',
},
};
export const getCompiledErrorMessage = (name: string, altMessage = false) => {

View File

@@ -0,0 +1,17 @@
export function shortDateTime(
date: string | number | Date,
includeTime: boolean = true
) {
return new Date(date).toLocaleString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
...(includeTime
? {
hour: "numeric",
minute: "numeric",
second: "numeric",
}
: {}),
})
}