From 915d4a5cb1a4d0686555ea8acf11995365d86c52 Mon Sep 17 00:00:00 2001 From: sreehari jayaraj Date: Fri, 22 Sep 2023 14:18:16 +0530 Subject: [PATCH] fix: token description size limited --- packages/nc-gui/components/account/Token.vue | 179 ++++++++++--------- 1 file changed, 96 insertions(+), 83 deletions(-) diff --git a/packages/nc-gui/components/account/Token.vue b/packages/nc-gui/components/account/Token.vue index 40b9467d98..725c0c4fd5 100644 --- a/packages/nc-gui/components/account/Token.vue +++ b/packages/nc-gui/components/account/Token.vue @@ -90,7 +90,7 @@ const deleteToken = async (token: string): Promise => { } const generateToken = async () => { - isTokenNameEmpty.value = !selectedTokenData.value.description?.length + isTokenNameEmpty.value = !selectedTokenData.value.description?.length || selectedTokenData.value.description?.length > 255 if (isTokenNameEmpty.value) return try { @@ -100,10 +100,9 @@ const generateToken = async () => { // message.success(t('msg.success.tokenGenerated')) selectedTokenData.value = {} await loadTokens() - } catch (e: any) { - message.error(await extractSdkResponseErrorMsg(e)) + } finally { + $e('a:api-token:generate') } - $e('a:api-token:generate') } const copyToken = async (token: string | undefined) => { @@ -128,6 +127,14 @@ const triggerDeleteModal = (tokenToDelete: string, tokenDescription: string) => const descriptionInput: VNodeRef = (el) => (el as HTMLInputElement)?.focus() +const errorMessage = computed(() => { + if (!selectedTokenData.value.description?.length) { + return 'Token name should not be empty' + } else if (selectedTokenData.value.description?.length > 255) { + return 'Token name should not be more than 255 characters' + } +}) + const handleCancel = () => { showNewTokenModal.value = false isTokenNameEmpty.value = false @@ -155,89 +162,95 @@ const handleCancel = () => { Create personal API tokens to use in automation or external apps. -
-
- Token name - Creator - Token - Actions -
-
-
-
- - token name should not be empty +
+
+
+ Token name + Creator + Token + Actions +
+
+
+
+
+ + {{ errorMessage }} +
+
+ + {{ $t('general.cancel') }} + + + {{ $t('general.save') }} + +
+
+
-
- - {{ $t('general.cancel') }} - - - {{ $t('general.save') }} - +
+
-
-
- -
-
- - - {{ el.description }} - - - - - {{ el.created_by }} - - - - - {{ el.token }} - - ********************************** - - - -
- - - - -
-
-
-
+
+ + + {{ el.description }} + + + + + {{ el.created_by }} + + + + + {{ el.token }} + + ************************************** + + + +
+ + + + +
+
+
+
+
-
+