mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 12:46:36 +00:00
refactor: rename project and base
- Rename `Project` => `Base` - Rename `Base` => `Source` - Remove `db` from data/meta api endpoints - Add backward compatibility for old apis - Migrations for renaming table and columns Signed-off-by: Pranav C <pranavxc@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
useDashboard,
|
||||
useI18n,
|
||||
useNuxtApp,
|
||||
useProject,
|
||||
useBase,
|
||||
} from '#imports'
|
||||
|
||||
interface ShareBase {
|
||||
@@ -29,23 +29,23 @@ const { dashboardUrl } = useDashboard()
|
||||
|
||||
const { $api, $e } = useNuxtApp()
|
||||
|
||||
const base = ref<null | ShareBase>(null)
|
||||
const sharedBase = ref<null | ShareBase>(null)
|
||||
|
||||
const showEditBaseDropdown = ref(false)
|
||||
|
||||
const { project } = storeToRefs(useProject())
|
||||
const { base } = storeToRefs(useBase())
|
||||
|
||||
const { copy } = useCopy()
|
||||
|
||||
const url = computed(() => (base.value && base.value.uuid ? `${dashboardUrl.value}#/base/${base.value.uuid}` : null))
|
||||
const url = computed(() => (sharedBase.value && sharedBase.value.uuid ? `${dashboardUrl.value}#/base/${sharedBase.value.uuid}` : null))
|
||||
|
||||
const loadBase = async () => {
|
||||
try {
|
||||
if (!project.value.id) return
|
||||
if (!base.value.id) return
|
||||
|
||||
const res = await $api.project.sharedBaseGet(project.value.id)
|
||||
const res = await $api.base.sharedBaseGet(base.value.id)
|
||||
|
||||
base.value = {
|
||||
sharedBase.value = {
|
||||
uuid: res.uuid,
|
||||
url: res.url,
|
||||
role: res.roles,
|
||||
@@ -57,14 +57,14 @@ const loadBase = async () => {
|
||||
|
||||
const createShareBase = async (role = ShareBaseRole.Viewer) => {
|
||||
try {
|
||||
if (!project.value.id) return
|
||||
if (!base.value.id) return
|
||||
|
||||
const res = await $api.project.sharedBaseUpdate(project.value.id, {
|
||||
const res = await $api.base.sharedBaseUpdate(base.value.id, {
|
||||
roles: role,
|
||||
})
|
||||
|
||||
base.value = res ?? {}
|
||||
base.value!.role = role
|
||||
sharedBase.value = res ?? {}
|
||||
sharedBase.value!.role = role
|
||||
} catch (e: any) {
|
||||
message.error(await extractSdkResponseErrorMsg(e))
|
||||
}
|
||||
@@ -74,10 +74,10 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
|
||||
|
||||
const disableSharedBase = async () => {
|
||||
try {
|
||||
if (!project.value.id) return
|
||||
if (!base.value.id) return
|
||||
|
||||
await $api.project.sharedBaseDisable(project.value.id)
|
||||
base.value = null
|
||||
await $api.base.sharedBaseDisable(base.value.id)
|
||||
sharedBase.value = null
|
||||
} catch (e: any) {
|
||||
message.error(await extractSdkResponseErrorMsg(e))
|
||||
}
|
||||
@@ -87,15 +87,15 @@ const disableSharedBase = async () => {
|
||||
|
||||
const recreate = async () => {
|
||||
try {
|
||||
if (!project.value.id) return
|
||||
if (!base.value.id) return
|
||||
|
||||
const sharedBase = await $api.project.sharedBaseCreate(project.value.id, {
|
||||
roles: base.value?.role || ShareBaseRole.Viewer,
|
||||
const sharedBase = await $api.base.sharedBaseCreate(base.value.id, {
|
||||
roles: sharedBase.value?.role || ShareBaseRole.Viewer,
|
||||
})
|
||||
|
||||
const newBase = sharedBase || {}
|
||||
|
||||
base.value = { ...newBase, role: base.value?.role }
|
||||
sharedBase.value = { ...newBase, role: sharedBase.value?.role }
|
||||
} catch (e: any) {
|
||||
message.error(await extractSdkResponseErrorMsg(e))
|
||||
}
|
||||
@@ -145,7 +145,7 @@ style="background: transparent; border: 1px solid #ddd"></iframe>`)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!base.value) {
|
||||
if (!sharedBase.value) {
|
||||
loadBase()
|
||||
}
|
||||
})
|
||||
@@ -153,14 +153,14 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2 w-full" data-testid="nc-share-base-sub-modal">
|
||||
<!-- Generate publicly shareable readonly base -->
|
||||
<!-- Generate publicly shareable readonly source -->
|
||||
<div class="flex text-xs text-gray-500 justify-start ml-1">{{ $t('msg.info.generatePublicShareableReadonlyBase') }}</div>
|
||||
|
||||
<div class="flex flex-row justify-between mx-1">
|
||||
<a-dropdown v-model="showEditBaseDropdown" class="flex" overlay-class-name="nc-dropdown-shared-base-toggle">
|
||||
<a-button>
|
||||
<div class="flex flex-row rounded-md items-center space-x-2 nc-disable-shared-base">
|
||||
<div v-if="base?.uuid">{{ $t('activity.shareBase.enable') }}</div>
|
||||
<div v-if="sharedBase?.uuid">{{ $t('activity.shareBase.enable') }}</div>
|
||||
<div v-else>{{ $t('activity.shareBase.disable') }}</div>
|
||||
<IcRoundKeyboardArrowDown class="h-[1rem]" />
|
||||
</div>
|
||||
@@ -169,7 +169,7 @@ onMounted(() => {
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item>
|
||||
<div v-if="base?.uuid" class="py-3" @click="disableSharedBase">{{ $t('activity.shareBase.disable') }}</div>
|
||||
<div v-if="sharedBase?.uuid" class="py-3" @click="disableSharedBase">{{ $t('activity.shareBase.disable') }}</div>
|
||||
<div v-else class="py-3" @click="createShareBase(ShareBaseRole.Viewer)">{{ $t('activity.shareBase.enable') }}</div>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
@@ -177,8 +177,8 @@ onMounted(() => {
|
||||
</a-dropdown>
|
||||
|
||||
<a-select
|
||||
v-if="base?.uuid"
|
||||
v-model:value="base.role"
|
||||
v-if="sharedBase?.uuid"
|
||||
v-model:value="sharedBase.role"
|
||||
class="flex nc-shared-base-role"
|
||||
dropdown-class-name="nc-dropdown-share-base-role"
|
||||
>
|
||||
@@ -201,7 +201,7 @@ onMounted(() => {
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</div>
|
||||
<div v-if="base?.uuid" class="flex flex-row mt-2 bg-red-50 py-4 mx-1 px-2 items-center rounded-sm w-full justify-between">
|
||||
<div v-if="sharedBase?.uuid" class="flex flex-row mt-2 bg-red-50 py-4 mx-1 px-2 items-center rounded-sm w-full justify-between">
|
||||
<span class="flex text-xs overflow-x-hidden overflow-ellipsis text-gray-700 pl-2 nc-url">{{ url }}</span>
|
||||
|
||||
<div class="flex border-l-1 pt-1 pl-1">
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useDashboard,
|
||||
useI18n,
|
||||
useNuxtApp,
|
||||
useProject,
|
||||
useBase,
|
||||
} from '#imports'
|
||||
import type { User, Users } from '#imports'
|
||||
|
||||
@@ -32,7 +32,7 @@ const emit = defineEmits(['closed', 'reload'])
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { project } = storeToRefs(useProject())
|
||||
const { base } = storeToRefs(useBase())
|
||||
|
||||
const { isMobileMode } = useGlobal()
|
||||
|
||||
@@ -72,21 +72,21 @@ const close = () => {
|
||||
const saveUser = async () => {
|
||||
$e('a:user:invite', { role: usersData.value.role })
|
||||
|
||||
if (!project.value.id) return
|
||||
if (!base.value.id) return
|
||||
|
||||
await formRef.value?.validateFields()
|
||||
|
||||
try {
|
||||
if (selectedUser?.id) {
|
||||
await $api.auth.projectUserUpdate(project.value.id, selectedUser.id, {
|
||||
await $api.auth.baseUserUpdate(base.value.id, selectedUser.id, {
|
||||
roles: usersData.value.role as ProjectRoles,
|
||||
email: selectedUser.email,
|
||||
project_id: project.value.id,
|
||||
projectName: project.value.title,
|
||||
base_id: base.value.id,
|
||||
baseName: base.value.title,
|
||||
})
|
||||
close()
|
||||
} else {
|
||||
const res = await $api.auth.projectUserAdd(project.value.id, {
|
||||
const res = await $api.auth.baseUserAdd(base.value.id, {
|
||||
roles: usersData.value.role,
|
||||
email: usersData.value.emails,
|
||||
} as ProjectUserReqType)
|
||||
@@ -114,7 +114,7 @@ const copyUrl = async () => {
|
||||
try {
|
||||
await copy(inviteUrl.value)
|
||||
|
||||
// Copied shareable base url to clipboard!
|
||||
// Copied shareable source url to clipboard!
|
||||
message.success(t('msg.success.shareableURLCopied'))
|
||||
} catch (e: any) {
|
||||
message.error(e.message)
|
||||
@@ -275,7 +275,7 @@ watch(
|
||||
|
||||
<div class="flex flex-row justify-end gap-x-2 border-t-1 border-gray-100 pt-3">
|
||||
<a-button key="back" class="!rounded-md" @click="cancel">Cancel</a-button>
|
||||
<a-button class="!rounded-md">Manage project access</a-button>
|
||||
<a-button class="!rounded-md">Manage base access</a-button>
|
||||
<a-button key="submit" class="!rounded-md" type="primary" :loading="loading">Share</a-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user