Browse Source

Merge pull request #6802 from nocodb/nc-fix/create-view-btn-ux-revamp

Create view btn ux revamp
pull/6812/head
Muhammed Mustafa 1 year ago committed by GitHub
parent
commit
fe44843f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue
  2. 15
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  3. 44
      packages/nc-gui/components/dashboard/TreeView/ViewsList.vue
  4. 10
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

31
packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue

@ -2,8 +2,15 @@
import type { ViewType } from 'nocodb-sdk' import type { ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
const props = defineProps<{
// Prop used to align the dropdown to the left in sidebar
alignLeftLevel: number | undefined
}>()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const alignLeftLevel = toRef(props, 'alignLeftLevel')
const { refreshCommandPalette } = useCommandPalette() const { refreshCommandPalette } = useCommandPalette()
const viewsStore = useViewsStore() const viewsStore = useViewsStore()
const { loadViews, navigateToView } = viewsStore const { loadViews, navigateToView } = viewsStore
@ -16,6 +23,14 @@ const toBeCreateType = ref<ViewTypes>()
const isOpen = ref(false) const isOpen = ref(false)
const overlayClassName = computed(() => {
if (alignLeftLevel.value === 1) return 'nc-view-create-dropdown nc-view-create-dropdown-left-1'
if (alignLeftLevel.value === 2) return 'nc-view-create-dropdown nc-view-create-dropdown-left-2'
return 'nc-view-create-dropdown'
})
async function onOpenModal({ async function onOpenModal({
title = '', title = '',
type, type,
@ -84,7 +99,7 @@ async function onOpenModal({
</script> </script>
<template> <template>
<NcDropdown v-model:visible="isOpen" destroy-popup-on-hide @click.stop="isOpen = true"> <NcDropdown v-model:visible="isOpen" destroy-popup-on-hide :overlay-class-name="overlayClassName" @click.stop="isOpen = true">
<slot /> <slot />
<template #overlay> <template #overlay>
<NcMenu class="max-w-48"> <NcMenu class="max-w-48">
@ -151,3 +166,17 @@ async function onOpenModal({
@apply text-brand-400; @apply text-brand-400;
} }
</style> </style>
<style lang="scss">
.nc-view-create-dropdown {
@apply !max-w-43 !min-w-43;
}
.nc-view-create-dropdown-left-1 {
@apply !left-18;
}
.nc-view-create-dropdown-left-2 {
@apply !left-23.5;
}
</style>

15
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -169,7 +169,6 @@ const isTableOpened = computed(() => {
> >
<div class="flex flex-row h-full items-center"> <div class="flex flex-row h-full items-center">
<NcButton <NcButton
v-if="(table.meta as any)?.hasNonDefaultViews"
v-e="['c:table:toggle-expand']" v-e="['c:table:toggle-expand']"
type="text" type="text"
size="xxsmall" size="xxsmall"
@ -182,7 +181,6 @@ const isTableOpened = computed(() => {
:class="{ '!rotate-180': isExpanded }" :class="{ '!rotate-180': isExpanded }"
/> />
</NcButton> </NcButton>
<div v-else class="sm:min-w-5.75 xs:min-w-7.5 h-2"></div>
<div class="flex w-auto" :data-testid="`tree-view-table-draggable-handle-${table.title}`"> <div class="flex w-auto" :data-testid="`tree-view-table-draggable-handle-${table.title}`">
<div <div
class="flex items-center nc-table-icon" class="flex items-center nc-table-icon"
@ -296,19 +294,6 @@ const isTableOpened = computed(() => {
</NcMenu> </NcMenu>
</template> </template>
</NcDropdown> </NcDropdown>
<DashboardTreeViewCreateViewBtn v-if="isUIAllowed('viewCreateOrEdit')">
<NcButton
v-e="['c:view:create']"
type="text"
size="xxsmall"
class="nc-create-view-btn nc-sidebar-node-btn"
:class="{
'!md:(visible opacity-100)': openedTableId === table.id,
}"
>
<GeneralIcon icon="plus" class="text-xl leading-5" style="-webkit-text-stroke: 0.15px" />
</NcButton>
</DashboardTreeViewCreateViewBtn>
</div> </div>
</div> </div>
<DlgTableDelete <DlgTableDelete

44
packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

@ -6,6 +6,7 @@ import Sortable from 'sortablejs'
import type { Menu as AntMenu } from 'ant-design-vue' import type { Menu as AntMenu } from 'ant-design-vue'
import { import {
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
isDefaultBase,
message, message,
onMounted, onMounted,
parseProp, parseProp,
@ -32,6 +33,10 @@ const table = inject(SidebarTableInj)!
const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) const { isLeftSidebarOpen } = storeToRefs(useSidebarStore())
const { activeTableId } = storeToRefs(useTablesStore())
const { isUIAllowed } = useRoles()
const { isMobileMode } = useGlobal() const { isMobileMode } = useGlobal()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
@ -77,6 +82,13 @@ function markItem(id: string) {
}, 300) }, 300)
} }
const isDefaultSource = computed(() => {
const source = base.value?.sources?.find((b) => b.id === table.value.source_id)
if (!source) return false
return isDefaultBase(source)
})
/** validate view title */ /** validate view title */
function validate(view: ViewType) { function validate(view: ViewType) {
if (!view.title || view.title.trim().length < 0) { if (!view.title || view.title.trim().length < 0) {
@ -367,12 +379,41 @@ function onOpenModal({
<template> <template>
<a-menu <a-menu
v-if="views.length"
ref="menuRef" ref="menuRef"
:class="{ dragging }" :class="{ dragging }"
class="nc-views-menu flex flex-col w-full !border-r-0 !bg-inherit" class="nc-views-menu flex flex-col w-full !border-r-0 !bg-inherit"
:selected-keys="selected" :selected-keys="selected"
> >
<DashboardTreeViewCreateViewBtn
v-if="isUIAllowed('viewCreateOrEdit')"
:class="{
'!pl-18 !xs:(pl-19.75)': isDefaultSource,
'!pl-23.5 !xs:(pl-27)': !isDefaultSource,
}"
:align-left-level="isDefaultSource ? 1 : 2"
>
<div
role="button"
class="nc-create-view-btn flex flex-row items-center cursor-pointer rounded-md w-full"
:class="{
'text-brand-500 hover:text-brand-600': activeTableId === table.id,
'text-gray-500 hover:text-brand-500': activeTableId !== table.id,
}"
>
<div class="flex flex-row items-center pl-1.25 !py-1.5 text-inherit">
<GeneralIcon icon="plus" />
<div class="pl-1.75">
{{
$t('general.createEntity', {
entity: $t('objects.view'),
})
}}
</div>
</div>
</div>
</DashboardTreeViewCreateViewBtn>
<template v-if="views.length">
<DashboardTreeViewViewsNode <DashboardTreeViewViewsNode
v-for="view of views" v-for="view of views"
:id="view.id" :id="view.id"
@ -392,6 +433,7 @@ function onOpenModal({
@rename="onRename" @rename="onRename"
@select-icon="setIcon($event, view)" @select-icon="setIcon($event, view)"
/> />
</template>
</a-menu> </a-menu>
</template> </template>

10
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -316,7 +316,7 @@ useMenuCloseOnEsc(open)
<div class="p-4 pr-0 bg-white w-90 rounded-2xl nc-table-toolbar-menu" data-testid="nc-fields-menu" @click.stop> <div class="p-4 pr-0 bg-white w-90 rounded-2xl nc-table-toolbar-menu" data-testid="nc-fields-menu" @click.stop>
<div <div
v-if="!filterQuery && !isPublic && (activeView?.type === ViewTypes.GALLERY || activeView?.type === ViewTypes.KANBAN)" v-if="!filterQuery && !isPublic && (activeView?.type === ViewTypes.GALLERY || activeView?.type === ViewTypes.KANBAN)"
class="flex flex-col gap-y-2 pr-6 mb-6" class="flex flex-col gap-y-2 pr-4 mb-6"
> >
<div class="flex text-sm select-none">Select cover image field</div> <div class="flex text-sm select-none">Select cover image field</div>
<a-select <a-select
@ -330,17 +330,17 @@ useMenuCloseOnEsc(open)
</a-select> </a-select>
</div> </div>
<div class="pr-6" @click.stop> <div class="pr-4" @click.stop>
<a-input v-model:value="filterQuery" :placeholder="$t('placeholder.searchFields')" class="!rounded-lg"> <a-input v-model:value="filterQuery" :placeholder="$t('placeholder.searchFields')" class="!rounded-lg">
<template #prefix> <img src="~/assets/nc-icons/search.svg" class="h-3.5 w-3.5 mr-1" /> </template <template #prefix> <img src="~/assets/nc-icons/search.svg" class="h-3.5 w-3.5 mr-1" /> </template
></a-input> ></a-input>
</div> </div>
<div v-if="!filterQuery" class="pr-6"> <div v-if="!filterQuery" class="pr-4">
<div class="pt-0.25 w-full bg-gray-50"></div> <div class="pt-0.25 w-full bg-gray-50"></div>
</div> </div>
<div class="flex flex-col my-1.5 nc-scrollbar-md max-h-[47.5vh] pr-5"> <div class="flex flex-col my-1.5 nc-scrollbar-md max-h-[47.5vh] pr-3">
<div class="nc-fields-list"> <div class="nc-fields-list">
<div <div
v-if="!fields?.filter((el) => el.title.toLowerCase().includes(filterQuery.toLowerCase())).length" v-if="!fields?.filter((el) => el.title.toLowerCase().includes(filterQuery.toLowerCase())).length"
@ -421,7 +421,7 @@ useMenuCloseOnEsc(open)
</Draggable> </Draggable>
</div> </div>
</div> </div>
<div class="flex pr-6 mt-1 gap-2"> <div class="flex pr-4 mt-1 gap-2">
<NcButton <NcButton
v-if="!filterQuery" v-if="!filterQuery"
type="ghost" type="ghost"

Loading…
Cancel
Save