|
|
@ -1,6 +1,6 @@ |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { type UserType, ViewTypes } from 'nocodb-sdk'; |
|
|
|
import { type UserType, ViewTypes } from 'nocodb-sdk'; |
|
|
|
import { Base } from '~/models'; |
|
|
|
import { BaseUser } from '~/models'; |
|
|
|
import { TablesService } from '~/services/tables.service'; |
|
|
|
import { TablesService } from '~/services/tables.service'; |
|
|
|
import { deserializeJSON } from '~/utils/serialize'; |
|
|
|
import { deserializeJSON } from '~/utils/serialize'; |
|
|
|
|
|
|
|
|
|
|
@ -20,30 +20,9 @@ export class CommandPaletteService { |
|
|
|
async commandPalette(param: { body: any; user: UserType }) { |
|
|
|
async commandPalette(param: { body: any; user: UserType }) { |
|
|
|
const cmdData = []; |
|
|
|
const cmdData = []; |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { scope } = param.body; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scope === 'root') { |
|
|
|
|
|
|
|
const bases = await Base.list({ user: param.user }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const base of bases) { |
|
|
|
|
|
|
|
cmdData.push({ |
|
|
|
|
|
|
|
id: `p-${base.id}`, |
|
|
|
|
|
|
|
title: base.title, |
|
|
|
|
|
|
|
icon: 'project', |
|
|
|
|
|
|
|
iconColor: deserializeJSON(base.meta)?.iconColor, |
|
|
|
|
|
|
|
section: 'Bases', |
|
|
|
|
|
|
|
scopePayload: { |
|
|
|
|
|
|
|
scope: `p-${base.id}`, |
|
|
|
|
|
|
|
data: { |
|
|
|
|
|
|
|
base_id: base.id, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (scope.startsWith('p-')) { |
|
|
|
|
|
|
|
const allBases = []; |
|
|
|
const allBases = []; |
|
|
|
|
|
|
|
|
|
|
|
const bases = await Base.list({ user: param.user }); |
|
|
|
const bases = await BaseUser.getProjectsList(param.user.id, param); |
|
|
|
|
|
|
|
|
|
|
|
allBases.push(...bases); |
|
|
|
allBases.push(...bases); |
|
|
|
|
|
|
|
|
|
|
@ -108,7 +87,6 @@ export class CommandPaletteService { |
|
|
|
|
|
|
|
|
|
|
|
cmdData.push(...tableList); |
|
|
|
cmdData.push(...tableList); |
|
|
|
cmdData.push(...vwList); |
|
|
|
cmdData.push(...vwList); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
console.log(e); |
|
|
|
return []; |
|
|
|
return []; |
|
|
|