|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
|
import { type UserType, ViewTypes } from 'nocodb-sdk'; |
|
|
|
|
import { Base } from '~/models'; |
|
|
|
|
import { BaseUser } from '~/models'; |
|
|
|
|
import { TablesService } from '~/services/tables.service'; |
|
|
|
|
import { deserializeJSON } from '~/utils/serialize'; |
|
|
|
|
|
|
|
|
@ -20,30 +20,9 @@ export class CommandPaletteService {
|
|
|
|
|
async commandPalette(param: { body: any; user: UserType }) { |
|
|
|
|
const cmdData = []; |
|
|
|
|
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 bases = await Base.list({ user: param.user }); |
|
|
|
|
const bases = await BaseUser.getProjectsList(param.user.id, param); |
|
|
|
|
|
|
|
|
|
allBases.push(...bases); |
|
|
|
|
|
|
|
|
@ -108,7 +87,6 @@ export class CommandPaletteService {
|
|
|
|
|
|
|
|
|
|
cmdData.push(...tableList); |
|
|
|
|
cmdData.push(...vwList); |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e); |
|
|
|
|
return []; |
|
|
|
|