mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 05:26:08 +00:00
Merge branch 'develop' into feat/pnpm
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Api, WorkspaceListType } from 'nocodb-sdk';
|
||||
import { Api } from 'nocodb-sdk';
|
||||
import { NcContext } from './index';
|
||||
import { isEE } from './db';
|
||||
let api: Api<any>;
|
||||
|
||||
async function createXcdb(context: NcContext) {
|
||||
@@ -10,7 +11,14 @@ async function createXcdb(context: NcContext) {
|
||||
},
|
||||
});
|
||||
|
||||
const projectList = await api.project.list();
|
||||
let projectList;
|
||||
|
||||
if (isEE() && context.workspace?.id) {
|
||||
projectList = await api['workspaceProject'].list(context.workspace.id);
|
||||
} else {
|
||||
projectList = await api.project.list();
|
||||
}
|
||||
|
||||
for (const project of projectList.list) {
|
||||
// delete project with title 'xcdb' if it exists
|
||||
if (project.title === 'xcdb') {
|
||||
@@ -20,21 +28,32 @@ async function createXcdb(context: NcContext) {
|
||||
|
||||
const project = await api.project.create({
|
||||
title: 'xcdb',
|
||||
fk_workspace_id: context?.workspace?.id,
|
||||
type: 'database',
|
||||
...(isEE()
|
||||
? {
|
||||
fk_workspace_id: context?.workspace?.id,
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
return project;
|
||||
}
|
||||
|
||||
async function deleteXcdb(token?: string) {
|
||||
async function deleteXcdb(context: NcContext) {
|
||||
api = new Api({
|
||||
baseURL: `http://localhost:8080/`,
|
||||
headers: {
|
||||
'xc-auth': token,
|
||||
'xc-auth': context.token,
|
||||
},
|
||||
});
|
||||
|
||||
const projectList = await api.project.list();
|
||||
let projectList;
|
||||
|
||||
if (isEE() && context.workspace?.id) {
|
||||
projectList = await api['workspaceProject'].list(context.workspace.id);
|
||||
} else {
|
||||
projectList = await api.project.list();
|
||||
}
|
||||
|
||||
for (const project of projectList.list) {
|
||||
// delete project with title 'xcdb' if it exists
|
||||
if (project.title === 'xcdb') {
|
||||
|
||||
Reference in New Issue
Block a user