Browse Source

Merge branch 'develop' into nc-refactor/ds

pull/8510/head
Raju Udava 7 months ago
parent
commit
99524d4e17
  1. 22
      packages/nc-gui/components/virtual-cell/Lookup.vue
  2. 14
      packages/nc-gui/composables/useCommandPalette/index.ts
  3. 136
      packages/nocodb/src/services/command-palette.service.ts
  4. 1
      packages/nocodb/src/services/org-users.service.ts
  5. 1
      packages/nocodb/src/utils/acl.ts

22
packages/nc-gui/components/virtual-cell/Lookup.vue

@ -20,22 +20,12 @@ const rowHeight = inject(RowHeightInj, ref(1) as any)
provide(RowHeightInj, providedHeightRef) provide(RowHeightInj, providedHeightRef)
const relationColumn = computed( const relationColumn = computed(() =>
() => meta.value?.id
const relationColumn = computed( ? metas.value[meta.value?.id]?.columns?.find(
() => (c: ColumnType) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id,
meta.value?.id ? metas.value[meta.value?.id]?.columns?.find( )
(c: ColumnType) => c.id === (column.value?.colOptions as LookupType)?.fk_relation_column_id, : undefined,
) : undefined as
| (ColumnType & {
colOptions: LinkToAnotherRecordType | undefined
})
| undefined,
)
| (ColumnType & {
colOptions: LinkToAnotherRecordType | undefined
})
| undefined,
) )
watch( watch(

14
packages/nc-gui/composables/useCommandPalette/index.ts

@ -169,19 +169,11 @@ export const useCommandPalette = createSharedComposable(() => {
} }
} }
} else { } else {
if (route.value.path.startsWith('/account')) { if (activeScope.value.scope === 'root') return
if (activeScope.value.scope === 'account_settings') return
activeScope.value = { scope: 'account_settings', data: {} } activeScope.value = { scope: 'root', data: {} }
loadScope() loadScope()
} else {
if (activeScope.value.scope === 'root') return
activeScope.value = { scope: 'root', data: {} }
loadScope()
}
} }
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },

136
packages/nocodb/src/services/command-palette.service.ts

@ -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,95 +20,73 @@ 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; const allBases = [];
if (scope === 'root') { const bases = await BaseUser.getProjectsList(param.user.id, param);
const bases = await Base.list({ user: param.user });
for (const base of bases) { allBases.push(...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 });
allBases.push(...bases); const viewList = [];
const viewList = []; for (const base of bases) {
viewList.push(
for (const base of bases) { ...(
viewList.push( (await this.tablesService.xcVisibilityMetaGet(
...( base.id,
(await this.tablesService.xcVisibilityMetaGet( null,
base.id, false,
null, )) as any[]
false, ).filter((v) => {
)) as any[] return Object.keys(param.user.roles).some(
).filter((v) => { (role) => param.user.roles[role] && !v.disabled[role],
return Object.keys(param.user.roles).some( );
(role) => param.user.roles[role] && !v.disabled[role], }),
); );
}), }
);
}
const tableList = []; const tableList = [];
const vwList = []; const vwList = [];
for (const b of allBases) { for (const b of allBases) {
cmdData.push({ cmdData.push({
id: `p-${b.id}`, id: `p-${b.id}`,
title: b.title, title: b.title,
icon: 'project', icon: 'project',
iconColor: deserializeJSON(b.meta)?.iconColor, iconColor: deserializeJSON(b.meta)?.iconColor,
section: 'Bases', section: 'Bases',
}); });
} }
for (const v of viewList) { for (const v of viewList) {
if (!tableList.find((el) => el.id === `tbl-${v.fk_model_id}`)) { if (!tableList.find((el) => el.id === `tbl-${v.fk_model_id}`)) {
tableList.push({ tableList.push({
id: `tbl-${v.fk_model_id}`, id: `tbl-${v.fk_model_id}`,
title: v._ptn, title: v._ptn,
parent: `p-${v.base_id}`, parent: `p-${v.base_id}`,
icon: v?.table_meta?.icon || v.ptype, icon: v?.table_meta?.icon || v.ptype,
projectName: bases.find((el) => el.id === v.base_id)?.title,
section: 'Tables',
});
}
vwList.push({
id: `vw-${v.id}`,
title: `${v.title}`,
parent: `tbl-${v.fk_model_id}`,
icon: v?.meta?.icon || viewTypeAlias[v.type] || 'table',
projectName: bases.find((el) => el.id === v.base_id)?.title, projectName: bases.find((el) => el.id === v.base_id)?.title,
section: 'Views', section: 'Tables',
is_default: v?.is_default,
handler: {
type: 'navigate',
payload: `/nc/${v.base_id}/${v.fk_model_id}/${encodeURIComponent(
v.id,
)}`,
},
}); });
} }
vwList.push({
cmdData.push(...tableList); id: `vw-${v.id}`,
cmdData.push(...vwList); title: `${v.title}`,
parent: `tbl-${v.fk_model_id}`,
icon: v?.meta?.icon || viewTypeAlias[v.type] || 'table',
projectName: bases.find((el) => el.id === v.base_id)?.title,
section: 'Views',
is_default: v?.is_default,
handler: {
type: 'navigate',
payload: `/nc/${v.base_id}/${v.fk_model_id}/${encodeURIComponent(
v.id,
)}`,
},
});
} }
cmdData.push(...tableList);
cmdData.push(...vwList);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return []; return [];

1
packages/nocodb/src/services/org-users.service.ts

@ -52,7 +52,6 @@ export class OrgUsersService {
return await User.update(param.userId, { return await User.update(param.userId, {
...updateBody, ...updateBody,
token_version: randomTokenString(),
}); });
} }

1
packages/nocodb/src/utils/acl.ts

@ -276,6 +276,7 @@ const rolePermissions:
baseList: true, baseList: true,
testConnection: true, testConnection: true,
isPluginActive: true, isPluginActive: true,
commandPalette: true,
}, },
}, },
[OrgUserRoles.CREATOR]: { [OrgUserRoles.CREATOR]: {

Loading…
Cancel
Save