Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): show proper tooltip

Ramesh Manec2de43a50766
diff --git a/packages/nc-gui/components/smartsheet/toolbar/NotAllowedTooltip.vue b/packages/nc-gui/components/smartsheet/toolbar/NotAllowedTooltip.vue
index e824b97bf2..30ffefed81 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/NotAllowedTooltip.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/NotAllowedTooltip.vue
@@ -23,7 +23,9 @@ defineProps<{
trigger="hover"
>
<template #title>
- {{ message }}
+ <slot name="title">
+ {{ message }}
+ </slot>
</template>
<slot />
</NcTooltip>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue
index 55b718279b..f298eb1b5d 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue
@@ -31,7 +31,14 @@ const table = computed(() => props.table)
const viewsStore = useViewsStore()
-const { navigateToView, duplicateView, updateView, isUserViewOwner, onOpenCopyViewConfigFromAnotherViewModal } = viewsStore
+const {
+ navigateToView,
+ duplicateView,
+ updateView,
+ isUserViewOwner,
+ onOpenCopyViewConfigFromAnotherViewModal,
+ getViewsCountByTableId,
+} = viewsStore
const { isCopyViewConfigFromAnotherViewFeatureEnabled } = storeToRefs(viewsStore)
@@ -208,6 +215,28 @@ const isUploadAllowed = computed(() => {
)
})
+const copyViewConfigMenuItemStatus = computed(() => {
+ const result = {
+ isDisabled: false,
+ tooltip: '',
+ }
+
+ if (isPersonalView.value && !isViewOwner.value) {
+ result.isDisabled = true
+ result.tooltip = t('tooltip.onlyViewOwnerCanCopyViewConfig')
+ } else if (lockType.value === LockType.Locked) {
+ result.isDisabled = true
+ result.tooltip = t('title.thisViewIsLockType', {
+ type: t(viewLockIcons[lockType.value]?.title).toLowerCase(),
+ })
+ } else if (getViewsCountByTableId(table.value!.id!) < 2) {
+ result.isDisabled = true
+ result.tooltip = t('tooltip.youNeedAtLeastOneExistingViewToCopyConfigurations')
+ }
+
+ return result
+})
+
defineOptions({
inheritAttrs: false,
})
@@ -291,20 +320,18 @@ defineOptions({
/>
<SmartsheetToolbarNotAllowedTooltip
v-if="isEeUI && isUIAllowed('viewCreateOrEdit') && isCopyViewConfigFromAnotherViewFeatureEnabled"
- :enabled="(isPersonalView && !isViewOwner) || lockType === LockType.Locked"
- :message="
- isPersonalView && !isViewOwner
- ? $t('tooltip.onlyViewOwnerCanCopyViewConfig')
- : $t('title.thisViewIsLockType', {
- type: $t(viewLockIcons[lockType]?.title).toLowerCase(),
- })
- "
+ :enabled="copyViewConfigMenuItemStatus.isDisabled"
>
+ <template #title>
+ <div class="max-w-70">
+ {{ copyViewConfigMenuItemStatus.tooltip }}
+ </div>
+ </template>
<PaymentUpgradeBadgeProvider :feature="PlanFeatureTypes.FEATURE_COPY_VIEW_SETTING_FROM_OTHER">
<template #default="{ click }">
<NcMenuItem
inner-class="w-full"
- :disabled="(isPersonalView && !isViewOwner) || lockType === LockType.Locked"
+ :disabled="copyViewConfigMenuItemStatus.isDisabled"
@click="click(PlanFeatureTypes.FEATURE_COPY_VIEW_SETTING_FROM_OTHER, () => onClickCopyViewConfig())"
>
<div
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index a30e253739..020a19403c 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -1912,7 +1912,8 @@
"pasteOperationLimitedToMaxRows": "Paste operation limited to {max} rows. Additional rows were truncated.",
"onlyOwnerOrCreatorCanReAssign": "Only owner or creator can re-assign",
"onlyViewOwnerCanAssignAsPersonalView": "Only view owner can assign as personal view",
- "onlyViewOwnerCanCopyViewConfig": "Only view owner can copy view configuration"
+ "onlyViewOwnerCanCopyViewConfig": "Only view owner can copy view configuration",
+ "youNeedAtLeastOneExistingViewToCopyConfigurations": "You need at least one existing view to copy configurations. Create a view first to enable this option."
},
"placeholder": {
"searchIcons": "Search icons",
diff --git a/packages/nc-gui/store/views.ts b/packages/nc-gui/store/views.ts
index 7146d05e16..71dcc8deb3 100644
--- a/packages/nc-gui/store/views.ts
+++ b/packages/nc-gui/store/views.ts
@@ -810,6 +810,10 @@ export const useViewsStore = defineStore('viewsStore', () => {
)
}
+ const getViewsCountByTableId = (tableId: string) => {
+ return (viewsByTable.value.get(tableId) || []).length
+ }
+
const onOpenCopyViewConfigFromAnotherViewModal = ({
defaultSelectedCopyViewConfigTypes,
destView = activeView.value,
@@ -986,6 +990,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
getViewReadableUrlSlug,
onOpenCopyViewConfigFromAnotherViewModal,
isUserViewOwner,
+ getViewsCountByTableId,
}
})