From e48ab6ca45eed9923f75320d2899df07f52a8e52 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 14 Oct 2023 20:46:24 +0200 Subject: [PATCH] api name length check --- src/Pages/UserProfile/index.js | 8 ++++++++ src/utils.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/Pages/UserProfile/index.js b/src/Pages/UserProfile/index.js index 5d72541..c6783ad 100644 --- a/src/Pages/UserProfile/index.js +++ b/src/Pages/UserProfile/index.js @@ -484,8 +484,16 @@ export default function UserProfile() { placeholder="Name" value={newApiKeyName} onChange={(e) => setNewApikeyName(e.target.value)} + maxLength={Constants.GLOBALS.MAX_USER_API_KEY_NAME_LENGTH} /> } + okButtonProps={{ + disabled: + newApiKeyName.length < + Constants.GLOBALS.MIN_USER_API_KEY_NAME_LENGTH || + newApiKeyName.length > + Constants.GLOBALS.MAX_USER_API_KEY_NAME_LENGTH, + }} okText={t("userProfile.button.createApiKey.popconfirm.okText")} cancelText={t("common.button.cancel")} onConfirm={() => onCreateNewApiKeyConfirm()} diff --git a/src/utils.js b/src/utils.js index 3ba6c79..9dc306f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -104,6 +104,8 @@ export const Constants = { MAX_LOG_MANAGER_ADDRESS_LENGTH: 100, MIN_ROBOTICS_ROBOT_NAME_LENGTH: 2, MAX_ROBOTICS_ROBOT_NAME_LENGTH: 30, + MIN_USER_API_KEY_NAME_LENGTH: 2, + MAX_USER_API_KEY_NAME_LENGTH: 30, }, MAX_AVATAR_SIZE: 5 * 1024 * 1024, ACCEPTED_AVATAR_FILE_TYPES: [