From c436c9b05081e66b1b3929bb275a9a5cb159dd55 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 17 Feb 2024 06:09:48 +0000 Subject: [PATCH] feat(nc-gui): webhook and api token placeholder --- packages/nc-gui/components/account/Token.vue | 55 ++++++++++++++----- .../smartsheet/details/Webhooks.vue | 9 +-- packages/nc-gui/lang/en.json | 5 +- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/packages/nc-gui/components/account/Token.vue b/packages/nc-gui/components/account/Token.vue index 72fff9fe80..549d28e1cd 100644 --- a/packages/nc-gui/components/account/Token.vue +++ b/packages/nc-gui/components/account/Token.vue @@ -45,6 +45,8 @@ const pagination = reactive({ pageSize: 10, }) +const isLoadingAllTokens = ref(true) + const setDefaultTokenName = () => { selectedTokenData.value.description = extractNextDefaultName( [...allTokens.value.map((el) => el?.description || '')], @@ -94,7 +96,7 @@ const updateAllTokens = (type: 'delete' | 'add', token: IApiTokenInfo) => { setDefaultTokenName() } -const loadTokens = async (page = currentPage.value, limit = currentLimit.value) => { +const loadTokens = async (page = currentPage.value, limit = currentLimit.value, hideShowNewToken = false) => { currentPage.value = page try { const response: any = await api.orgTokens.list({ @@ -103,18 +105,30 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value) offset: searchText.value.length === 0 ? (page - 1) * limit : 0, }, } as RequestParams) - if (!response) return + if (!response) { + isLoadingAllTokens.value = false + return + } pagination.total = response.pageInfo.totalRows ?? 0 pagination.pageSize = 10 tokens.value = response.list as IApiTokenInfo[] + if (hideShowNewToken) { + showNewTokenModal.value = false + selectedTokenData.value = {} + } + if (!allTokens.value.length) { await loadAllTokens(pagination.total) } } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) + } finally { + if (isLoadingAllTokens.value) { + isLoadingAllTokens.value = false + } } } @@ -159,11 +173,10 @@ const generateToken = async () => { if (!isValidTokenName.value) return try { const token = await api.orgTokens.create(selectedTokenData.value) - showNewTokenModal.value = false + // Token generated successfully // message.success(t('msg.success.tokenGenerated')) - selectedTokenData.value = {} - await loadTokens() + await loadTokens(currentPage.value, currentLimit.value, true) updateAllTokens('add', token as IApiTokenInfo) } catch (e: any) { @@ -216,7 +229,7 @@ const handleCancel = () => {
{{ $t('title.apiTokens') }}
- + {
{{ $t('msg.apiTokenCreate') }} -
+
{{ $t('title.tokenName') }} @@ -268,6 +281,7 @@ const handleCancel = () => { class="!rounded-lg !py-1" placeholder="Token Name" data-testid="nc-token-input" + :disabled="isLoading" @press-enter="generateToken" /> { {{ $t('general.cancel') }} - + {{ $t('general.save') }}
@@ -351,6 +359,25 @@ const handleCancel = () => {
+
+ + +
{{ $t('placeholder.noTokenCreated') }}
+
+ {{ $t('placeholder.noTokenCreatedLabel') }} +
+ + + + + + +
-
- -
{{ $t('msg.createWebhookMsg1') }}
-
+
+ + +
{{ $t('msg.createWebhookMsg1') }}
+
{{ $t('msg.createWebhookMsg2') }}
{{ $t('msg.createWebhookMsg3') }}
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index 00daec7a10..c75722146d 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -398,6 +398,7 @@ "findRowByScanningCode": "Find record by scanning a QR or Barcode", "tokenManagement": "Token Management", "addNewToken": "Add new token", + "createNewToken": "Create new token", "accountSettings": "Account Settings", "resetPasswordMenu": "Reset Password", "tokens": "Tokens", @@ -961,7 +962,9 @@ "value": "Value", "key": "Key", "createTable": "Create your First Table!", - "createTableLabel": "From scratch or import or connect to external database" + "createTableLabel": "From scratch or import or connect to external database", + "noTokenCreated":"No API Tokens created", + "noTokenCreatedLabel" :"Looks like you haven’t generated any API tokens yet." }, "msg": { "clickToCopyFieldId": "Click to copy Field Id",