diff --git a/frontend/src/component/admin/apiToken/ApiTokenForm/TokenInfo/TokenInfo.tsx b/frontend/src/component/admin/apiToken/ApiTokenForm/TokenInfo/TokenInfo.tsx index 94ccf16f67..f64ce444f3 100644 --- a/frontend/src/component/admin/apiToken/ApiTokenForm/TokenInfo/TokenInfo.tsx +++ b/frontend/src/component/admin/apiToken/ApiTokenForm/TokenInfo/TokenInfo.tsx @@ -3,15 +3,15 @@ import { StyledInput, StyledInputDescription } from '../ApiTokenForm.styles'; import type { ApiTokenFormErrorType } from '../useApiTokenForm'; interface ITokenInfoProps { - username: string; - setUsername: React.Dispatch>; + tokenName: string; + setTokenName: React.Dispatch>; errors: { [key: string]: string }; clearErrors: (error?: ApiTokenFormErrorType) => void; } export const TokenInfo = ({ - username, - setUsername, + tokenName, + setTokenName, errors, clearErrors, }: ITokenInfoProps) => { @@ -21,13 +21,13 @@ export const TokenInfo = ({ What would you like to call this token? setUsername(e.target.value)} + value={tokenName} + name='tokenName' + onChange={(e) => setTokenName(e.target.value)} label='Token name' - error={errors.username !== undefined} - errorText={errors.username} - onFocus={() => clearErrors('username')} + error={errors.tokenName !== undefined} + errorText={errors.tokenName} + onFocus={() => clearErrors('tokenName')} autoFocus /> diff --git a/frontend/src/component/admin/apiToken/ApiTokenForm/useApiTokenForm.ts b/frontend/src/component/admin/apiToken/ApiTokenForm/useApiTokenForm.ts index 7ec110ed07..14a844ff87 100644 --- a/frontend/src/component/admin/apiToken/ApiTokenForm/useApiTokenForm.ts +++ b/frontend/src/component/admin/apiToken/ApiTokenForm/useApiTokenForm.ts @@ -11,7 +11,7 @@ import { import { useHasRootAccess } from 'hooks/useHasAccess'; import type { SelectOption } from './TokenTypeSelector/TokenTypeSelector'; -export type ApiTokenFormErrorType = 'username' | 'projects'; +export type ApiTokenFormErrorType = 'tokenName' | 'projects'; export const useApiTokenForm = (project?: string) => { const { environments } = useEnvironments(); const { uiConfig } = useUiConfig(); @@ -50,7 +50,7 @@ export const useApiTokenForm = (project?: string) => { const firstAccessibleType = apiTokenTypes.find((t) => t.enabled)?.key; - const [username, setUsername] = useState(''); + const [tokenName, setTokenName] = useState(''); const [type, setType] = useState(firstAccessibleType || TokenType.CLIENT); const [projects, setProjects] = useState([ project ? project : '*', @@ -80,7 +80,7 @@ export const useApiTokenForm = (project?: string) => { }; const getApiTokenPayload = (): IApiTokenCreate => ({ - username, + tokenName, type, environment, projects, @@ -88,8 +88,8 @@ export const useApiTokenForm = (project?: string) => { const isValid = () => { const newErrors: Partial> = {}; - if (!username) { - newErrors.username = 'Username is required'; + if (!tokenName) { + newErrors.tokenName = 'Token name is required'; } if (projects.length === 0) { newErrors.projects = 'At least one project is required'; @@ -110,12 +110,12 @@ export const useApiTokenForm = (project?: string) => { }; return { - username, + tokenName, type, apiTokenTypes, projects, environment, - setUsername, + setTokenName, setTokenType, setProjects, setEnvironment, diff --git a/frontend/src/component/admin/apiToken/CreateApiToken/CreateApiToken.tsx b/frontend/src/component/admin/apiToken/CreateApiToken/CreateApiToken.tsx index 4c0a05bb5d..d1b21be05d 100644 --- a/frontend/src/component/admin/apiToken/CreateApiToken/CreateApiToken.tsx +++ b/frontend/src/component/admin/apiToken/CreateApiToken/CreateApiToken.tsx @@ -62,11 +62,11 @@ export const CreateApiToken = ({ modal = false }: ICreateApiTokenProps) => { const { getApiTokenPayload, - username, + tokenName, type, projects, environment, - setUsername, + setTokenName, setTokenType, setProjects, setEnvironment, @@ -149,8 +149,8 @@ export const CreateApiToken = ({ modal = false }: ICreateApiTokenProps) => { } > diff --git a/frontend/src/component/environments/EnvironmentTable/EnvironmentActionCell/EnvironmentCloneModal/EnvironmentCloneModal.tsx b/frontend/src/component/environments/EnvironmentTable/EnvironmentActionCell/EnvironmentCloneModal/EnvironmentCloneModal.tsx index ee3dfc90f7..955ded3e5b 100644 --- a/frontend/src/component/environments/EnvironmentTable/EnvironmentActionCell/EnvironmentCloneModal/EnvironmentCloneModal.tsx +++ b/frontend/src/component/environments/EnvironmentTable/EnvironmentActionCell/EnvironmentCloneModal/EnvironmentCloneModal.tsx @@ -164,7 +164,7 @@ export const EnvironmentCloneModal = ({ }); const getApiTokenCreatePayload = (): IApiTokenCreate => ({ - username: `${name}_token`, + tokenName: `${name}_token`, type: 'CLIENT', environment: name, projects: tokenProjects, diff --git a/frontend/src/component/onboarding/dialog/GenerateApiKey.tsx b/frontend/src/component/onboarding/dialog/GenerateApiKey.tsx index 9a9a9af5d7..0e291d5405 100644 --- a/frontend/src/component/onboarding/dialog/GenerateApiKey.tsx +++ b/frontend/src/component/onboarding/dialog/GenerateApiKey.tsx @@ -217,7 +217,7 @@ export const GenerateApiKey = ({ environment, type: sdkType, projects: [project], - username: `api-key-${project}-${environment}`, + tokenName: `api-key-${project}-${environment}`, }, project, ); diff --git a/frontend/src/component/project/Project/ProjectSettings/ProjectApiAccess/CreateProjectApiTokenForm.tsx b/frontend/src/component/project/Project/ProjectSettings/ProjectApiAccess/CreateProjectApiTokenForm.tsx index 9fcf54190a..66bc6e9da5 100644 --- a/frontend/src/component/project/Project/ProjectSettings/ProjectApiAccess/CreateProjectApiTokenForm.tsx +++ b/frontend/src/component/project/Project/ProjectSettings/ProjectApiAccess/CreateProjectApiTokenForm.tsx @@ -34,11 +34,11 @@ export const CreateProjectApiTokenForm = () => { const { getApiTokenPayload, - username, + tokenName, type, apiTokenTypes, environment, - setUsername, + setTokenName, setTokenType, setEnvironment, isValid, @@ -120,8 +120,8 @@ export const CreateProjectApiTokenForm = () => { } > diff --git a/frontend/src/hooks/api/actions/useApiTokensApi/useApiTokensApi.ts b/frontend/src/hooks/api/actions/useApiTokensApi/useApiTokensApi.ts index 92ff48c561..1920e2c8ad 100644 --- a/frontend/src/hooks/api/actions/useApiTokensApi/useApiTokensApi.ts +++ b/frontend/src/hooks/api/actions/useApiTokensApi/useApiTokensApi.ts @@ -1,7 +1,7 @@ import useAPI from '../useApi/useApi'; export interface IApiTokenCreate { - username: string; + tokenName: string; type: string; environment?: string; projects: string[]; diff --git a/frontend/src/hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi.ts b/frontend/src/hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi.ts index 55a002ecf9..9f28ccf2d4 100644 --- a/frontend/src/hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi.ts +++ b/frontend/src/hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi.ts @@ -1,7 +1,7 @@ import useAPI from '../useApi/useApi'; export interface IApiTokenCreate { - username: string; + tokenName: string; type: string; environment?: string; projects: string[];