mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
8.1 KiB
239 lines
8.1 KiB
2 years ago
|
<script lang="ts" setup>
|
||
|
import { message } from 'ant-design-vue'
|
||
2 years ago
|
import { useI18n } from 'vue-i18n'
|
||
2 years ago
|
import {
|
||
|
ActiveViewInj,
|
||
|
IsLockedInj,
|
||
|
IsPublicInj,
|
||
|
extractSdkResponseErrorMsg,
|
||
|
inject,
|
||
|
ref,
|
||
|
useNuxtApp,
|
||
2 years ago
|
useProject,
|
||
2 years ago
|
useSmartsheetStoreOrThrow,
|
||
2 years ago
|
useUIPermission,
|
||
|
} from '#imports'
|
||
2 years ago
|
import { LockType } from '~/lib'
|
||
|
import { viewIcons } from '~/utils'
|
||
2 years ago
|
import MdiLockOutlineIcon from '~icons/mdi/lock-outline'
|
||
|
import MdiAccountIcon from '~icons/mdi/account'
|
||
|
import MdiAccountGroupIcon from '~icons/mdi/account-group'
|
||
|
|
||
2 years ago
|
const { t } = useI18n()
|
||
|
|
||
2 years ago
|
const sharedViewListDlg = ref(false)
|
||
|
|
||
|
const isPublicView = inject(IsPublicInj, ref(false))
|
||
|
|
||
|
const isView = false
|
||
|
|
||
2 years ago
|
const { $api, $e } = useNuxtApp()
|
||
2 years ago
|
|
||
|
const selectedView = inject(ActiveViewInj)
|
||
|
|
||
|
const isLocked = inject(IsLockedInj)
|
||
|
|
||
|
const showWebhookDrawer = ref(false)
|
||
|
|
||
2 years ago
|
const showApiSnippetDrawer = ref(false)
|
||
|
|
||
2 years ago
|
const quickImportDialog = ref(false)
|
||
|
|
||
|
const { isUIAllowed } = useUIPermission()
|
||
|
|
||
2 years ago
|
const { isSharedBase } = useProject()
|
||
|
|
||
2 years ago
|
const Icon = computed(() => {
|
||
|
switch ((selectedView?.value as any)?.lock_type) {
|
||
|
case LockType.Personal:
|
||
|
return MdiAccountIcon
|
||
|
case LockType.Locked:
|
||
|
return MdiLockOutlineIcon
|
||
|
case LockType.Collaborative:
|
||
|
default:
|
||
|
return MdiAccountGroupIcon
|
||
|
}
|
||
|
})
|
||
|
|
||
|
async function changeLockType(type: LockType) {
|
||
|
$e('a:grid:lockmenu', { lockType: type })
|
||
|
|
||
2 years ago
|
if (!selectedView?.value) return
|
||
|
|
||
2 years ago
|
if (type === 'personal') {
|
||
2 years ago
|
// Coming soon
|
||
|
return message.info(t('msg.toast.futureRelease'))
|
||
2 years ago
|
}
|
||
|
try {
|
||
2 years ago
|
;(selectedView.value as any).lock_type = type
|
||
|
$api.dbView.update(selectedView.value.id as string, {
|
||
2 years ago
|
lock_type: type,
|
||
|
})
|
||
|
|
||
|
message.success(`Successfully Switched to ${type} view`)
|
||
|
} catch (e: any) {
|
||
|
message.error(await extractSdkResponseErrorMsg(e))
|
||
|
}
|
||
|
}
|
||
2 years ago
|
|
||
|
const { isSqlView } = useSmartsheetStoreOrThrow()
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<div>
|
||
2 years ago
|
<a-dropdown :trigger="['click']">
|
||
2 years ago
|
<a-button v-t="['c:actions']" class="nc-actions-menu-btn nc-toolbar-btn">
|
||
2 years ago
|
<div class="flex gap-2 items-center">
|
||
2 years ago
|
<component
|
||
|
:is="viewIcons[selectedView?.type].icon"
|
||
|
class="nc-view-icon group-hover:hidden"
|
||
2 years ago
|
:style="{ color: viewIcons[selectedView?.type].color }"
|
||
2 years ago
|
/>
|
||
2 years ago
|
<span class="!text-sm font-weight-normal"
|
||
|
><GeneralTruncateText>{{ selectedView?.title }}</GeneralTruncateText></span
|
||
|
>
|
||
2 years ago
|
<component :is="Icon" class="text-gray-500" :class="`nc-icon-${selectedView?.lock_type}`" />
|
||
2 years ago
|
<MdiMenuDown class="text-grey" />
|
||
|
</div>
|
||
|
</a-button>
|
||
|
|
||
|
<template #overlay>
|
||
2 years ago
|
<a-menu class="ml-6 !text-sm !px-0 !py-2 !rounded">
|
||
2 years ago
|
<a-menu-item-group>
|
||
2 years ago
|
<a-sub-menu
|
||
|
v-if="isUIAllowed('view-type')"
|
||
|
key="lock-type"
|
||
|
class="scrollbar-thin-dull min-w-50 max-h-90vh overflow-auto !py-0"
|
||
|
>
|
||
2 years ago
|
<template #title>
|
||
2 years ago
|
<div v-t="['c:navdraw:preview-as']" class="nc-project-menu-item group px-0 !py-0">
|
||
2 years ago
|
<SmartsheetToolbarLockType hide-tick :type="selectedView?.lock_type || LockType.Collaborative" />
|
||
2 years ago
|
|
||
|
<MaterialSymbolsChevronRightRounded
|
||
2 years ago
|
class="transform group-hover:(scale-115 text-accent) text-xl text-gray-400"
|
||
2 years ago
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<template #expandIcon></template>
|
||
2 years ago
|
<a-menu-item @click="changeLockType(LockType.Collaborative)">
|
||
|
<SmartsheetToolbarLockType :type="LockType.Collaborative" />
|
||
2 years ago
|
</a-menu-item>
|
||
2 years ago
|
<a-menu-item @click="changeLockType(LockType.Locked)">
|
||
|
<SmartsheetToolbarLockType :type="LockType.Locked" />
|
||
2 years ago
|
</a-menu-item>
|
||
2 years ago
|
<a-menu-item @click="changeLockType(LockType.Personal)">
|
||
|
<SmartsheetToolbarLockType :type="LockType.Personal" />
|
||
2 years ago
|
</a-menu-item>
|
||
|
</a-sub-menu>
|
||
2 years ago
|
<a-menu-divider />
|
||
2 years ago
|
<a-sub-menu key="download">
|
||
|
<template #title>
|
||
2 years ago
|
<!-- Download -->
|
||
2 years ago
|
<div v-t="['c:navdraw:preview-as']" class="nc-project-menu-item group">
|
||
2 years ago
|
<MdiDownload class="group-hover:text-accent text-gray-500" />
|
||
2 years ago
|
{{ $t('general.download') }}
|
||
2 years ago
|
<div class="flex-1" />
|
||
|
|
||
|
<MaterialSymbolsChevronRightRounded
|
||
2 years ago
|
class="transform group-hover:(scale-115 text-accent) text-xl text-gray-400"
|
||
2 years ago
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<template #expandIcon></template>
|
||
2 years ago
|
<SmartsheetToolbarExportSubActions />
|
||
2 years ago
|
</a-sub-menu>
|
||
2 years ago
|
<template v-if="isUIAllowed('csvImport') && !isView && !isPublicView && !isSqlView">
|
||
2 years ago
|
<a-sub-menu key="upload">
|
||
2 years ago
|
<!-- Upload -->
|
||
2 years ago
|
<template #title>
|
||
|
<div v-t="['c:navdraw:preview-as']" class="nc-project-menu-item group">
|
||
2 years ago
|
<MdiUpload class="group-hover:text-accent text-gray-500" />
|
||
2 years ago
|
{{ $t('general.upload') }}
|
||
2 years ago
|
<div class="flex-1" />
|
||
|
|
||
|
<MaterialSymbolsChevronRightRounded
|
||
|
class="transform group-hover:(scale-115 text-accent) text-xl text-gray-400"
|
||
|
/>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<template #expandIcon></template>
|
||
|
<a-menu-item>
|
||
|
<div
|
||
|
v-if="isUIAllowed('csvImport') && !isView && !isPublicView"
|
||
|
v-t="['a:actions:upload-csv']"
|
||
|
class="nc-project-menu-item"
|
||
|
:class="{ disabled: isLocked }"
|
||
|
@click="!isLocked ? (quickImportDialog = true) : {}"
|
||
|
>
|
||
|
<MdiUploadOutline class="text-gray-500" />
|
||
|
<!-- Upload CSV -->
|
||
|
{{ $t('activity.uploadCSV') }}
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
|
</a-sub-menu>
|
||
|
</template>
|
||
2 years ago
|
<a-menu-divider />
|
||
2 years ago
|
<a-menu-item>
|
||
|
<div
|
||
|
v-if="isUIAllowed('SharedViewList') && !isView && !isPublicView"
|
||
|
v-t="['a:actions:shared-view-list']"
|
||
2 years ago
|
class="py-2 flex gap-2 items-center"
|
||
2 years ago
|
@click="sharedViewListDlg = true"
|
||
2 years ago
|
>
|
||
|
<MdiViewListOutline class="text-gray-500" />
|
||
|
<!-- Shared View List -->
|
||
|
{{ $t('activity.listSharedView') }}
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
2 years ago
|
<a-menu-item v-if="!isSqlView">
|
||
2 years ago
|
<div
|
||
|
v-if="isUIAllowed('webhook') && !isView && !isPublicView"
|
||
|
v-t="['c:actions:webhook']"
|
||
2 years ago
|
class="py-2 flex gap-2 items-center"
|
||
2 years ago
|
@click="showWebhookDrawer = true"
|
||
|
>
|
||
|
<MdiHook class="text-gray-500" />
|
||
|
{{ $t('objects.webhooks') }}
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
2 years ago
|
<a-menu-item>
|
||
|
<div
|
||
|
v-if="!isSharedBase && !isPublicView"
|
||
|
v-t="['c:snippet:open']"
|
||
|
class="py-2 flex gap-2 items-center"
|
||
|
@click="showApiSnippetDrawer = true"
|
||
|
>
|
||
|
<MdiXml class="text-gray-500" />
|
||
2 years ago
|
<!-- Get API Snippet -->
|
||
|
{{ $t('activity.getApiSnippet') }}
|
||
2 years ago
|
</div>
|
||
|
</a-menu-item>
|
||
2 years ago
|
</a-menu-item-group>
|
||
|
</a-menu>
|
||
|
</template>
|
||
|
</a-dropdown>
|
||
|
|
||
|
<DlgQuickImport v-if="quickImportDialog" v-model="quickImportDialog" import-type="csv" :import-only="true" />
|
||
|
|
||
|
<WebhookDrawer v-if="showWebhookDrawer" v-model="showWebhookDrawer" />
|
||
|
|
||
2 years ago
|
<a-modal v-model:visible="sharedViewListDlg" :title="$t('activity.listSharedView')" width="max(900px,60vw)" :footer="null">
|
||
2 years ago
|
<SmartsheetToolbarSharedViewList v-if="sharedViewListDlg" />
|
||
|
</a-modal>
|
||
2 years ago
|
<SmartsheetApiSnippet v-model="showApiSnippetDrawer" />
|
||
2 years ago
|
</div>
|
||
|
</template>
|
||
2 years ago
|
|
||
|
<style scoped>
|
||
2 years ago
|
:deep(.ant-dropdown-menu-submenu-title) {
|
||
|
@apply py-0;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-dropdown-menu-item-group-title) {
|
||
|
@apply hidden;
|
||
2 years ago
|
}
|
||
|
</style>
|