Browse Source

fix: review changes #7173

pull/7173/head
Ramesh Mane 1 year ago
parent
commit
27a2f159fd
  1. 27
      packages/nc-gui/components/account/Token.vue
  2. 4
      packages/nc-gui/components/smartsheet/grid/Table.vue
  3. 2
      packages/nc-gui/components/smartsheet/header/Cell.vue
  4. 2
      packages/nc-gui/components/smartsheet/header/Menu.vue
  5. 7
      packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue
  6. 6
      packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
  7. 31
      packages/nc-gui/components/webhook/Editor.vue
  8. 33
      packages/nc-gui/helpers/parsers/parserHelpers.ts
  9. 5
      packages/nc-gui/lang/en.json

27
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))
}

4
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)"
>
<div v-e="['a:row:clear']" class="flex gap-2 items-center">
@ -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])"
>
<div v-e="['a:row:clear-range']" class="flex gap-2 items-center">
<GeneralIcon icon="closeBox" class="text-gray-500" />

2
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

2
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -292,7 +292,7 @@ const onInsertAfter = () => {
</div>
<template #overlay>
<a-menu class="shadow bg-white nc-column-options">
<a-menu-item @click="onEditPress" :disabled="!!isSystemColumn(column) && column?.uidt !== UITypes.ID">
<a-menu-item @click="onEditPress" :disabled="isSystemColumn(column) && column?.uidt !== UITypes.ID">
<div class="nc-column-edit nc-header-menu-item">
<component :is="iconMap.edit" class="text-gray-700 mx-0.65 my-0.75" />
<!-- Edit -->

7
packages/nc-gui/components/smartsheet/toolbar/CreateGroupBy.vue

@ -83,13 +83,12 @@ const onArrowUp = () => {
<template>
<div
class="flex flex-col w-full pt-4 pb-2 min-w-64 nc-group-create-modal"
class="flex flex-col w-full pt-4 pb-2 min-w-64 nc-group-by-create-modal"
@keydown.arrow-down.prevent="onArrowDown"
@keydown.arrow-up.prevent="onArrowUp"
@keydown.enter.prevent="onClick(options[activeFieldIndex])"
>
<div class="flex pb-3 px-4 border-b-1 border-gray-100">
<!-- Todo language for selectFieldToGroup -->
<input ref="inputRef" v-model="search" class="w-full focus:outline-none" :placeholder="$t('msg.selectFieldToGroup')" />
</div>
<div class="flex-col w-full max-h-100 max-w-76 nc-scrollbar-md !overflow-y-auto">
@ -97,8 +96,8 @@ const onArrowUp = () => {
<div
v-for="(option, index) in options"
:key="index"
v-e="['c:sort:add:column:select']"
class="flex flex-row h-10 items-center gap-x-1.5 px-2.5 hover:bg-gray-100 cursor-pointer nc-group-column-search-item"
v-e="['c:group-by:add:column:select']"
class="flex flex-row h-10 items-center gap-x-1.5 px-2.5 hover:bg-gray-100 cursor-pointer nc-group-by-column-search-item"
:class="{
'bg-gray-100': activeFieldIndex === index,
}"

6
packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue

@ -180,7 +180,7 @@ const loadAllowedLookups = async () => {
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 () => {
>
<NcButton
v-e="['c:group-by:add']"
class="nc-add-group-btn !text-brand-500"
class="nc-add-group-by-btn !text-brand-500"
style="width: fit-content"
size="small"
type="text"

31
packages/nc-gui/components/webhook/Editor.vue

@ -20,6 +20,7 @@ import {
useNuxtApp,
watch,
} from '#imports'
import { extractNextDefaultName } from '~/helpers/parsers/parserHelpers'
interface Props {
hook?: HookType
@ -49,13 +50,13 @@ const titleDomRef = ref<HTMLInputElement | undefined>()
const useForm = Form.useForm
const defaultWebhookName = 'Webhook'
const defaultHookName = t('labels.webhook')
let hookRef = reactive<
Omit<HookType, 'notification'> & { notification: Record<string, any>; 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()

33
packages/nc-gui/helpers/parsers/parserHelpers.ts

@ -191,3 +191,36 @@ export const filterNullOrUndefinedObjectProperties = <T extends Record<string, a
return result
}, {} as Record<string, any>) 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`
}

5
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"
}
}
}
}
Loading…
Cancel
Save