|
|
|
@ -3,6 +3,7 @@ interface ShareBase {
|
|
|
|
|
uuid?: string |
|
|
|
|
url?: string |
|
|
|
|
role?: string |
|
|
|
|
fk_custom_url_id?: string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum ShareBaseRole { |
|
|
|
@ -14,6 +15,8 @@ const { dashboardUrl } = useDashboard()
|
|
|
|
|
|
|
|
|
|
const { $api, $e } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
const { copy } = useCopy() |
|
|
|
|
|
|
|
|
|
const sharedBase = ref<null | ShareBase>(null) |
|
|
|
|
|
|
|
|
|
const { base } = storeToRefs(useBase()) |
|
|
|
@ -22,18 +25,21 @@ const { getBaseUrl, appInfo } = useGlobal()
|
|
|
|
|
|
|
|
|
|
const workspaceStore = useWorkspace() |
|
|
|
|
|
|
|
|
|
const url = computed(() => { |
|
|
|
|
if (!sharedBase.value || !sharedBase.value.uuid) return '' |
|
|
|
|
|
|
|
|
|
const dashboardBaseUrl = computed(() => { |
|
|
|
|
// get base url for workspace |
|
|
|
|
const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId) |
|
|
|
|
|
|
|
|
|
let dashboardUrl1 = dashboardUrl.value |
|
|
|
|
|
|
|
|
|
if (baseUrl) { |
|
|
|
|
dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}` |
|
|
|
|
return `${baseUrl}${appInfo.value?.dashboardPath}` |
|
|
|
|
} |
|
|
|
|
return encodeURI(`${dashboardUrl1}#/base/${sharedBase.value.uuid}`) |
|
|
|
|
|
|
|
|
|
return dashboardUrl.value |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const url = computed(() => { |
|
|
|
|
if (!sharedBase.value || !sharedBase.value.uuid) return '' |
|
|
|
|
|
|
|
|
|
return encodeURI(`${dashboardBaseUrl.value}#/base/${sharedBase.value.uuid}`) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const loadBase = async () => { |
|
|
|
@ -46,24 +52,32 @@ const loadBase = async () => {
|
|
|
|
|
uuid: res.uuid, |
|
|
|
|
url: res.url, |
|
|
|
|
role: res.roles, |
|
|
|
|
fk_custom_url_id: res?.fk_custom_url_id, |
|
|
|
|
} |
|
|
|
|
} catch (e: any) { |
|
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const createShareBase = async (role = ShareBaseRole.Viewer) => { |
|
|
|
|
const createShareBase = async (role = ShareBaseRole.Viewer, custUrl = undefined) => { |
|
|
|
|
try { |
|
|
|
|
if (!base.value.id) return |
|
|
|
|
|
|
|
|
|
const res = await $api.base.sharedBaseUpdate(base.value.id, { |
|
|
|
|
roles: role, |
|
|
|
|
original_url: url.value, |
|
|
|
|
...(custUrl !== undefined ? { custom_url_path: custUrl ?? null } : {}), |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
sharedBase.value = res ?? {} |
|
|
|
|
sharedBase.value!.role = role |
|
|
|
|
|
|
|
|
|
base.value.uuid = res.uuid |
|
|
|
|
|
|
|
|
|
if (custUrl !== undefined) { |
|
|
|
|
sharedBase.value!.fk_custom_url_id = res.fk_custom_url_id |
|
|
|
|
base.value.fk_custom_url_id = res.fk_custom_url_id |
|
|
|
|
} |
|
|
|
|
} catch (e: any) { |
|
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
|
} |
|
|
|
@ -126,6 +140,10 @@ const onRoleToggle = async () => {
|
|
|
|
|
isRoleToggleLoading.value = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const copyCustomUrl = async (custUrl = '') => { |
|
|
|
|
return await copy(`${dashboardBaseUrl.value}#/p/${encodeURIComponent(custUrl)}`) |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
@ -141,11 +159,18 @@ const onRoleToggle = async () => {
|
|
|
|
|
@click="toggleSharedBase" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="isSharedBaseEnabled" class="flex flex-col w-full mt-3 border-t-1 pt-3 border-gray-100"> |
|
|
|
|
<div v-if="isSharedBaseEnabled" class="flex flex-col gap-3 w-full mt-3 border-t-1 pt-3 border-gray-100"> |
|
|
|
|
<GeneralCopyUrl v-model:url="url" /> |
|
|
|
|
<DlgShareAndCollaborateCustomUrl |
|
|
|
|
v-if="sharedBase?.uuid" |
|
|
|
|
:id="sharedBase.fk_custom_url_id" |
|
|
|
|
:dashboard-url="dashboardBaseUrl" |
|
|
|
|
:copy-custom-url="copyCustomUrl" |
|
|
|
|
@update-custom-url="createShareBase(undefined, $event)" |
|
|
|
|
/> |
|
|
|
|
<div |
|
|
|
|
v-if="!appInfo.ee && sharedBase?.role === ShareBaseRole.Editor" |
|
|
|
|
class="flex flex-row justify-between mt-3 bg-gray-50 px-3 py-2 rounded-md" |
|
|
|
|
class="flex flex-row justify-between bg-gray-50 px-3 py-2 rounded-md" |
|
|
|
|
> |
|
|
|
|
<div class="text-black">{{ $t('activity.editingAccess') }}</div> |
|
|
|
|
<a-switch |
|
|
|
|