Browse Source

refactor: merge develop

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5805/head
Raju Udava 1 year ago
parent
commit
f54f1a2b3d
  1. 6
      lerna.json
  2. 1
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 7
      packages/nc-gui/composables/useMultiSelect/index.ts
  4. 2
      packages/nocodb/src/db/BaseModelSqlv2.ts
  5. 12
      packages/nocodb/src/models/Model.ts
  6. 10
      packages/nocodb/src/models/Project.ts
  7. 29
      packages/nocodb/src/models/View.ts
  8. 1
      packages/nocodb/src/modules/datas/helpers.ts
  9. 2
      packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts
  10. 2
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts
  11. 65
      renovate.json

6
lerna.json

@ -1,6 +1,10 @@
{
"packages": [
"packages/*"
"packages/nc-cli",
"packages/nc-gui",
"packages/nc-plugin",
"packages/nocodb",
"packages/nocodb-sdk"
],
"version": "independent"
}

1
packages/nc-gui/components/smartsheet/Grid.vue

@ -232,7 +232,6 @@ const {
if (e.key === ' ') {
if (isCellActive.value && !editEnabled && hasEditPermission) {
e.preventDefault()
clearSelectedRange()
const row = data.value[activeCell.row]
expandForm(row)
return true

7
packages/nc-gui/composables/useMultiSelect/index.ts

@ -24,6 +24,7 @@ import {
useI18n,
useMetas,
useProject,
useUIPermission,
} from '#imports'
const MAIN_MOUSE_PRESSED = 0
@ -73,6 +74,9 @@ export function useMultiSelect(
() => !(activeCell.row === null || activeCell.col === null || isNaN(activeCell.row) || isNaN(activeCell.col)),
)
const { isUIAllowed } = useUIPermission()
const hasEditPermission = $computed(() => isUIAllowed('xcDatatableEditable'))
function makeActive(row: number, col: number) {
if (activeCell.row === row && activeCell.col === col) {
return
@ -343,6 +347,9 @@ export function useMultiSelect(
// paste - ctrl/cmd + v
case 86:
try {
// if edit permission is not there, return
if (!hasEditPermission) return
// handle belongs to column
if (
columnObj.uidt === UITypes.LinkToAnotherRecord &&

2
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -172,7 +172,7 @@ class BaseModelSqlv2 {
data.__proto__ = proto;
}
return data ? await nocoExecute(ast, data, {}, query) : {};
return data ? await nocoExecute(ast, data, {}, query) : null;
}
public async exist(id?: any): Promise<any> {

12
packages/nocodb/src/models/Model.ts

@ -570,13 +570,25 @@ export default class Model implements TableType {
// get existing cache
const key = `${CacheScope.MODEL}:${tableId}`;
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
let oldModel = { ...o };
// update alias
if (o) {
o.title = title;
o.table_name = table_name;
// set cache
await NocoCache.set(key, o);
} else {
oldModel = await this.get(tableId);
}
// delete alias cache
await NocoCache.del(
`${CacheScope.MODEL}:${oldModel.project_id}:${oldModel.base_id}:${oldModel.title}`,
);
await NocoCache.del(
`${CacheScope.MODEL}:${oldModel.project_id}:${oldModel.title}`,
);
// set meta
return await ncMeta.metaUpdate(
null,

10
packages/nocodb/src/models/Project.ts

@ -8,6 +8,7 @@ import {
import { extractProps } from '../helpers/extractProps';
import NocoCache from '../cache/NocoCache';
import Base from './/Base';
import { ProjectUser } from './index';
import type { BoolType, MetaType, ProjectType } from 'nocodb-sdk';
import type { DB_TYPES } from './/Base';
@ -276,6 +277,15 @@ export default class Project implements ProjectType {
// Todo: Remove the project entry from the connection pool in NcConnectionMgrv2
static async delete(projectId, ncMeta = Noco.ncMeta): Promise<any> {
const users = await ProjectUser.getUsersList({
project_id: projectId,
offset: 0,
limit: 1000,
});
for (const user of users) {
await ProjectUser.delete(projectId, user.id);
}
const bases = await Base.list({ projectId });
for (const base of bases) {
await base.delete(ncMeta);

29
packages/nocodb/src/models/View.ts

@ -1,3 +1,4 @@
import { title } from 'process';
import { isSystemColumn, UITypes, ViewTypes } from 'nocodb-sdk';
import Noco from '../Noco';
import {
@ -165,13 +166,19 @@ export default class View implements ViewType {
],
},
);
view.meta = parseMetaProp(view);
// todo: cache - titleOrId can be viewId so we need a different scope here
await NocoCache.set(
`${CacheScope.VIEW}:${fk_model_id}:${titleOrId}`,
view.id,
);
await NocoCache.set(`${CacheScope.VIEW}:${fk_model_id}:${view.id}`, view);
if (view) {
await NocoCache.set(
`${CacheScope.VIEW}:${fk_model_id}:${view.id}`,
view,
);
view.meta = parseMetaProp(view);
// todo: cache - titleOrId can be viewId so we need a different scope here
await NocoCache.set(
`${CacheScope.VIEW}:${fk_model_id}:${titleOrId}`,
view.id,
);
}
return view && new View(view);
}
return viewId && this.get(viewId?.id || viewId);
@ -952,6 +959,7 @@ export default class View implements ViewType {
// get existing cache
const key = `${CacheScope.VIEW}:${viewId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
let oldView = { ...o };
if (o) {
// update data
o = {
@ -963,8 +971,15 @@ export default class View implements ViewType {
}
// set cache
await NocoCache.set(key, o);
} else {
oldView = await this.get(viewId);
}
// reset alias cache
await NocoCache.del(
`${CacheScope.VIEW}:${oldView.fk_model_id}:${oldView.title}`,
);
// if meta data defined then stringify it
if ('meta' in updateObj) {
updateObj.meta = stringifyMetaProp(updateObj);

1
packages/nocodb/src/modules/datas/helpers.ts

@ -43,6 +43,7 @@ export async function getViewAndModelByAliasOrId(param: {
fk_model_id: model.id,
}));
if (!model) NcError.notFound('Table not found');
if (param.viewName && !view) NcError.notFound('View not found');
return { model, view };
}

2
packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts

@ -282,7 +282,7 @@ function baseModelSqlTests() {
const deletedRow = await baseModelSql.readByPk(rowIdToDeleted);
expect(deletedRow).to.be.an('object').that.is.empty;
expect(deletedRow).to.be.null;
console.log('Delete record', await Audit.projectAuditList(project.id, {}));
const rowDeletedAudit = (await Audit.projectAuditList(project.id, {})).find(

2
packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

@ -780,7 +780,7 @@ function viewRowTests() {
.send({
title: 'Test',
})
.expect(400);
.expect(404);
};
it('Create table row grid wrong grid id', async function () {

65
renovate.json

@ -0,0 +1,65 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
":dependencyDashboard",
":onlyNpm",
":prConcurrentLimit20",
":autodetectPinVersions",
":label(renovate)",
":rebaseStalePrs",
":semanticPrefixFixDepsChoreOthers",
":separatePatchReleases",
"group:monorepos",
"group:recommended"
],
"baseBranches": [
"develop"
],
"vulnerabilityAlerts": {
"commitMessagePrefix": "chore(renovate): Security update"
},
"schedule": "at any time",
"rangeStrategy": "bump",
"packageRules": [
{
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["major"],
"reviewersFromCodeOwners": true,
"commitMessagePrefix": "chore(renovate):",
"groupName": "major"
},
{
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["minor"],
"commitMessagePrefix": "chore(renovate):",
"groupName": "minor"
},
{
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["patch"],
"commitMessagePrefix": "chore(renovate):",
"groupName": "patch"
},
{
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["pin", "digest"],
"commitMessagePrefix": "chore(renovate):",
"groupName": "pin"
}
],
"ignorePaths": [
"**/node_modules/**",
"**/nc-cli/**",
"**/nc-lib-gui/**",
"**/nc-plugin/**",
"**/nocodb-legacy/**",
"**/test/**",
"**/tests/**",
"**/workflows/**",
"**/charts/**"
],
"assignees": [
"wingkwong"
]
}
Loading…
Cancel
Save