diff --git a/packages/nc-gui/components/account/Token.vue b/packages/nc-gui/components/account/Token.vue
index e7338bdcde..6690c4b63a 100644
--- a/packages/nc-gui/components/account/Token.vue
+++ b/packages/nc-gui/components/account/Token.vue
@@ -3,6 +3,7 @@ import type { VNodeRef } from '@vue/runtime-core'
import { message } from 'ant-design-vue'
import type { ApiTokenType, RequestParams } from 'nocodb-sdk'
import { extractSdkResponseErrorMsg, isEeUI, ref, useApi, useCopy, useNuxtApp } from '#imports'
+import { extractNextDefaultName } from '~/helpers/parsers/parserHelpers'
const { api, isLoading } = useApi()
@@ -42,28 +43,8 @@ const pagination = reactive({
pageSize: 10,
})
-const getDefaultTokenValue = (tokens: IApiTokenInfo[]) => {
- let extractedSortedTokenNumbers =
- [...tokens]
- .map((e) => {
- let tokenName = e.description?.split('-')
- if (tokenName && tokenName[tokenName.length - 1] && !isNaN(Number(tokenName[tokenName.length - 1]?.trim()))) {
- return Number(tokenName[tokenName.length - 1]?.trim())
- }
- })
- .filter((e) => e)
- .sort((a, b) => {
- if (a !== undefined && b !== undefined) {
- return a - b
- }
- return 0
- }) || []
-
- if (extractedSortedTokenNumbers.length) {
- return `${defaultTokenName}-${(extractedSortedTokenNumbers[extractedSortedTokenNumbers.length - 1] || 0) + 1}`
- } else {
- return `${defaultTokenName}-1`
- }
+const getDefaultTokenName = (tokens: IApiTokenInfo[]) => {
+ return extractNextDefaultName([...tokens.map((el) => el?.description || '')], defaultTokenName)
}
const hideOrShowToken = (tokenId: string) => {
@@ -91,7 +72,7 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value)
pagination.pageSize = 10
tokens.value = response.list as IApiTokenInfo[]
- selectedTokenData.value.description = getDefaultTokenValue(tokens.value)
+ selectedTokenData.value.description = getDefaultTokenName(tokens.value)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
}
diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue
index 42dcfb3406..e762a9d8c5 100644
--- a/packages/nc-gui/components/smartsheet/grid/Table.vue
+++ b/packages/nc-gui/components/smartsheet/grid/Table.vue
@@ -1703,7 +1703,7 @@ onKeyStroke('ArrowDown', onDown)
(isLinksOrLTAR(fields[contextMenuTarget.col]) || !isVirtualCol(fields[contextMenuTarget.col]))
"
class="nc-base-menu-item"
- :disabled="!!isSystemColumn(fields[contextMenuTarget.col])"
+ :disabled="isSystemColumn(fields[contextMenuTarget.col])"
@click="clearCell(contextMenuTarget)"
>
@@ -1717,7 +1717,7 @@ onKeyStroke('ArrowDown', onDown)
v-else-if="contextMenuTarget && hasEditPermission"
class="nc-base-menu-item"
@click="clearSelectedRangeOfCells()"
- :disabled="!!isSystemColumn(fields[contextMenuTarget.col])"
+ :disabled="isSystemColumn(fields[contextMenuTarget.col])"
>
diff --git a/packages/nc-gui/components/smartsheet/header/Cell.vue b/packages/nc-gui/components/smartsheet/header/Cell.vue
index 5db5748dec..886074e4b8 100644
--- a/packages/nc-gui/components/smartsheet/header/Cell.vue
+++ b/packages/nc-gui/components/smartsheet/header/Cell.vue
@@ -49,7 +49,7 @@ const closeAddColumnDropdown = () => {
}
const openHeaderMenu = () => {
- if (isLocked.value || (!!isSystemColumn(column.value) && column.value.uidt !== UITypes.ID)) return
+ if (isLocked.value || (isSystemColumn(column.value) && column.value.uidt !== UITypes.ID)) return
if (!isForm.value && !isExpandedForm.value && isUIAllowed('fieldEdit') && !isMobileMode.value) {
editColumnDropdown.value = true
diff --git a/packages/nc-gui/components/smartsheet/header/Menu.vue b/packages/nc-gui/components/smartsheet/header/Menu.vue
index 088a9c023d..565a65212d 100644
--- a/packages/nc-gui/components/smartsheet/header/Menu.vue
+++ b/packages/nc-gui/components/smartsheet/header/Menu.vue
@@ -292,7 +292,7 @@ const onInsertAfter = () => {
-
+
diff --git a/packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue b/packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue
index d366b6d751..1d7e1865d2 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue
@@ -83,13 +83,12 @@ const onArrowUp = () => {
-
@@ -97,8 +96,8 @@ const onArrowUp = () => {
{
for (const col of meta.value?.columns || []) {
if (col.uidt !== UITypes.Lookup) continue
- let nextCol: ColumnType | undefined = col
+ let nextCol: ColumnType = col
// check the lookup column is supported type or not
while (nextCol && nextCol.uidt === UITypes.Lookup) {
const lookupRelation = (await getMeta(nextCol.fk_model_id as string))?.columns?.find(
@@ -193,7 +193,7 @@ const loadAllowedLookups = async () => {
nextCol = relatedTableMeta?.columns?.find(
(c) => c.id === ((nextCol?.colOptions as LookupType).fk_lookup_column_id as string),
- )
+ ) as ColumnType
// if next column is same as root lookup column then break the loop
// since it's going to be a circular loop, and ignore the column
@@ -304,7 +304,7 @@ watch(meta, async () => {
>
()
const useForm = Form.useForm
-const defaultWebhookName = 'Webhook'
+const defaultHookName = t('labels.webhook')
let hookRef = reactive<
Omit & { notification: Record; eventOperation?: string; condition: boolean }
>({
id: '',
- title: defaultWebhookName,
+ title: defaultHookName,
event: undefined,
operation: undefined,
eventOperation: undefined,
@@ -474,28 +475,8 @@ async function testWebhook() {
await webhookTestRef.value.testWebhook()
}
-function getDefaultTokenValue(hooks: HookType[]) {
- let extractedSortedTokenNumbers =
- [...hooks]
- .map((hook) => {
- let hookName = hook.title?.split('-')
- if (hookName && hookName[hookName.length - 1] && !isNaN(Number(hookName[hookName.length - 1]?.trim()))) {
- return Number(hookName[hookName.length - 1]?.trim())
- }
- })
- .filter((e) => e)
- .sort((a, b) => {
- if (a !== undefined && b !== undefined) {
- return a - b
- }
- return 0
- }) || []
-
- if (extractedSortedTokenNumbers.length) {
- return `${defaultWebhookName}-${(extractedSortedTokenNumbers[extractedSortedTokenNumbers.length - 1] || 0) + 1}`
- } else {
- return `${defaultWebhookName}-1`
- }
+const getDefaultHookName = (hooks: HookType[]) => {
+ return extractNextDefaultName([...hooks.map((el) => el?.title || '')], defaultHookName)
}
watch(
@@ -528,7 +509,7 @@ onMounted(async () => {
} else {
hookRef.eventOperation = eventList.value[0].value.join(' ')
}
- hookRef.title = getDefaultTokenValue(hooks.value)
+ hookRef.title = getDefaultHookName(hooks.value)
onNotificationTypeChange()
diff --git a/packages/nc-gui/helpers/parsers/parserHelpers.ts b/packages/nc-gui/helpers/parsers/parserHelpers.ts
index a54a10759e..d938d86374 100644
--- a/packages/nc-gui/helpers/parsers/parserHelpers.ts
+++ b/packages/nc-gui/helpers/parsers/parserHelpers.ts
@@ -191,3 +191,36 @@ export const filterNullOrUndefinedObjectProperties = ) as T
}
+
+/**
+ * Extracts the next default name based on the provided namesData, defaultName, and splitOperator.
+ *
+ * @param namesData - An array of strings containing existing names data.
+ * @param defaultName - The default name to extract and generate the next name from.
+ * @param splitOperator - The separator used to split the defaultName and numbers in existing namesData.
+ * Defaults to '-'. Example: If defaultName is 'Token' and splitOperator is '-',
+ * existing names like 'Token-1', 'Token-2', etc., will be considered.
+ * @returns The next default name with an incremented number based on existing namesData.
+ */
+export const extractNextDefaultName = (namesData: string[], defaultName: string, splitOperator: string = '-'): string => {
+ // Extract and sort numbers associated with the provided defaultName
+ const extractedSortedNumbers =
+ (namesData
+ .map((name) => {
+ const [_defaultName, number] = name.split(splitOperator)
+ if (_defaultName === defaultName && !isNaN(Number(number?.trim()))) {
+ return Number(number?.trim())
+ }
+ })
+ .filter((e) => e)
+ .sort((a, b) => {
+ if (a !== undefined && b !== undefined) {
+ return a - b
+ }
+ return 0
+ }) as number[]) || []
+
+ return extractedSortedNumbers.length
+ ? `${defaultName}${splitOperator}${extractedSortedNumbers[extractedSortedNumbers.length - 1] + 1}`
+ : `${defaultName}${splitOperator}1`
+}
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index 14035bb123..c0d31ee2fd 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -640,7 +640,8 @@
"sourceNameRequired": "Source name is required",
"changeWsName": "Change Workspace Name",
"pressEnter": "Press Enter",
- "newFormLoaded": "New form will be loaded after"
+ "newFormLoaded": "New form will be loaded after",
+ "webhook": "Webhook"
},
"activity": {
"openInANewTab": "Open in a new tab",
@@ -1343,4 +1344,4 @@
"roleUpdated": "Role updated successfully"
}
}
-}
+}
\ No newline at end of file