Browse Source

Merge pull request #5890 from nocodb/develop

pull/5891/head 0.109.1
github-actions[bot] 1 year ago committed by GitHub
parent
commit
5a17db9595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 26
      packages/nc-gui/composables/useUIPermission/index.ts
  3. 10
      packages/nc-gui/composables/useViewData.ts
  4. 52
      packages/nc-gui/package-lock.json
  5. 2
      packages/nc-gui/package.json
  6. 10
      packages/nc-gui/pages/index/index/index.vue
  7. 4
      packages/nocodb-sdk/package-lock.json
  8. 30
      packages/nocodb/package-lock.json
  9. 4
      packages/nocodb/package.json
  10. 3
      packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts
  11. 3
      packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts
  12. 10
      packages/nocodb/src/models/ProjectUser.ts
  13. 2
      packages/nocodb/src/services/datas.service.ts
  14. 8
      packages/nocodb/tests/unit/rest/tests/tableRow.test.ts
  15. 131
      packages/nocodb/tests/unit/rest/tests/viewRow.test.ts

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

@ -717,9 +717,9 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue?
index++
/** if new record save row and save the LTAR cells */
if (currentRow.rowMeta.new) {
const syncLTARRefs = rowRefs[index]!.syncLTARRefs
const syncLTARRefs = rowRefs?.[index]?.syncLTARRefs
const savedRow = await updateOrSaveRow(currentRow, '', {}, args)
await syncLTARRefs(savedRow, args)
await syncLTARRefs?.(savedRow, args)
currentRow.rowMeta.changed = false
continue
}
@ -740,6 +740,9 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue?
}
async function reloadViewDataHandler(shouldShowLoading: boolean | void) {
// save any unsaved data before reload
await saveOrUpdateRecords();
// set value if spinner should be hidden
showLoading.value = !!shouldShowLoading
await loadData()
@ -755,9 +758,21 @@ async function openNewRecordHandler() {
reloadViewDataHook?.on(reloadViewDataHandler)
openNewRecordFormHook?.on(openNewRecordHandler)
onBeforeUnmount(() => {
onBeforeUnmount(async () => {
/** save/update records before unmounting the component */
saveOrUpdateRecords()
const viewMetaValue = view.value
const dataValue = data.value
if (viewMetaValue) {
getMeta(viewMetaValue.fk_model_id).then((res) => {
const metaValue = res
if (!metaValue) return
saveOrUpdateRecords({
metaValue,
viewMetaValue,
data: dataValue,
})
})
}
// reset hooks
reloadViewDataHook?.off(reloadViewDataHandler)

26
packages/nc-gui/composables/useUIPermission/index.ts

@ -24,14 +24,32 @@ export const useUIPermission = createSharedComposable(() => {
const { previewAs } = useGlobal()
const { allRoles } = useRoles()
const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => {
const isUIAllowed = (
permission: Permission | string,
skipPreviewAs = false,
userRoles?: string | Record<string, boolean> | string[],
) => {
if (previewAs.value && !skipPreviewAs) {
return hasPermission(previewAs.value, true, permission)
}
return Object.entries(allRoles.value).some(([role, hasRole]) =>
hasPermission(role as Role | ProjectRole, hasRole, permission),
)
let roles: Record<string, boolean> = {}
if (!userRoles) {
roles = allRoles.value
} else if (Array.isArray(userRoles) || typeof userRoles === 'string') {
roles = (Array.isArray(userRoles) ? userRoles : userRoles.split(','))
// filter out any empty-string/null/undefined values
.filter(Boolean)
.reduce<Record<string, boolean>>((acc, role) => {
acc[role] = true
return acc
}, {})
} else if (typeof userRoles === 'object') {
roles = userRoles
}
return Object.entries(roles).some(([role, hasRole]) => hasPermission(role as Role | ProjectRole, hasRole, permission))
}
return { isUIAllowed }

10
packages/nc-gui/composables/useViewData.ts

@ -611,6 +611,11 @@ export function useViewData(
.map((c) => row.row[c.title!])
.join('___')
const deleted = await deleteRowById(id as string)
if (!deleted) {
return
}
if (!undo) {
addUndo({
redo: {
@ -648,11 +653,6 @@ export function useViewData(
scope: defineViewScope({ view: viewMeta.value }),
})
}
const deleted = await deleteRowById(id as string)
if (!deleted) {
return
}
}
formattedData.value.splice(rowIndex, 1)

52
packages/nc-gui/package-lock.json generated

@ -30,7 +30,7 @@
"leaflet.markercluster": "^1.5.3",
"locale-codes": "^1.3.1",
"monaco-editor": "^0.33.0",
"nocodb-sdk": "0.109.0",
"nocodb-sdk": "file:../nocodb-sdk",
"papaparse": "^5.3.2",
"pinia": "^2.0.33",
"qrcode": "^1.5.1",
@ -111,7 +111,6 @@
},
"../nocodb-sdk": {
"version": "0.109.0",
"extraneous": true,
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",
@ -8720,6 +8719,7 @@
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==",
"devOptional": true,
"funding": [
{
"type": "individual",
@ -12238,21 +12238,8 @@
}
},
"node_modules/nocodb-sdk": {
"version": "0.109.0",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.109.0.tgz",
"integrity": "sha512-5yKLiiDR0noHdhyOqqdF/+UWyTqU7em6QZouURRQSxC72qHU1KBrL1ig5JaIL0CX0pwlANq9hnQ0OzSH8J46fQ==",
"dependencies": {
"axios": "^0.21.1",
"jsep": "^1.3.6"
}
},
"node_modules/nocodb-sdk/node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dependencies": {
"follow-redirects": "^1.14.0"
}
"resolved": "../nocodb-sdk",
"link": true
},
"node_modules/node-abi": {
"version": "3.23.0",
@ -24729,7 +24716,8 @@
"follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA=="
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==",
"devOptional": true
},
"form-data": {
"version": "4.0.0",
@ -27279,22 +27267,22 @@
}
},
"nocodb-sdk": {
"version": "0.109.0",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.109.0.tgz",
"integrity": "sha512-5yKLiiDR0noHdhyOqqdF/+UWyTqU7em6QZouURRQSxC72qHU1KBrL1ig5JaIL0CX0pwlANq9hnQ0OzSH8J46fQ==",
"version": "file:../nocodb-sdk",
"requires": {
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"axios": "^0.21.1",
"jsep": "^1.3.6"
},
"dependencies": {
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"requires": {
"follow-redirects": "^1.14.0"
}
}
"cspell": "^4.1.0",
"eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^4.0.0",
"jsep": "^1.3.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
}
},
"node-abi": {

2
packages/nc-gui/package.json

@ -54,7 +54,7 @@
"leaflet.markercluster": "^1.5.3",
"locale-codes": "^1.3.1",
"monaco-editor": "^0.33.0",
"nocodb-sdk": "0.109.0",
"nocodb-sdk": "file:../nocodb-sdk",
"papaparse": "^5.3.2",
"pinia": "^2.0.33",
"qrcode": "^1.5.1",

10
packages/nc-gui/pages/index/index/index.vue

@ -247,9 +247,9 @@ const copyProjectMeta = async () => {
<a-table-column key="title" :title="$t('general.title')" data-index="title">
<template #default="{ text, record }">
<div class="flex items-center">
<div @click.stop>
<div @click.stop class="w-2">
<a-menu class="!border-0 !m-0 !p-0" trigger-sub-menu-action="click">
<template v-if="isUIAllowed('projectTheme')">
<template v-if="isUIAllowed('projectTheme') || isUIAllowed('projectTheme', true, record.roles)">
<a-sub-menu key="theme" popup-class-name="custom-color">
<template #title>
<div
@ -308,7 +308,7 @@ const copyProjectMeta = async () => {
<div v-if="record.status !== ProjectStatus.JOB" class="flex items-center gap-2">
<component
:is="iconMap.edit"
v-if="isUIAllowed('projectUpdate', true)"
v-if="isUIAllowed('projectUpdate', true) || isUIAllowed('projectUpdate', true, record.roles)"
v-e="['c:project:edit:rename']"
class="nc-action-btn"
@click.stop="navigateTo(`/${text}`)"
@ -316,14 +316,14 @@ const copyProjectMeta = async () => {
<component
:is="iconMap.delete"
v-if="isUIAllowed('projectDelete', true)"
v-if="isUIAllowed('projectDelete', true) || isUIAllowed('projectDelete', true, record.roles)"
class="nc-action-btn"
:data-testid="`delete-project-${record.title}`"
@click.stop="deleteProject(record)"
/>
<a-dropdown
v-if="isUIAllowed('duplicateProject', true)"
v-if="isUIAllowed('duplicateProject', true) || isUIAllowed('duplicateProject', true, record.roles)"
:trigger="['click']"
overlay-class-name="nc-dropdown-import-menu"
@click.stop

4
packages/nocodb-sdk/package-lock.json generated

@ -1,12 +1,12 @@
{
"name": "nocodb-sdk",
"version": "0.108.1",
"version": "0.109.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nocodb-sdk",
"version": "0.108.1",
"version": "0.109.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",

30
packages/nocodb/package-lock.json generated

@ -83,7 +83,7 @@
"nc-lib-gui": "0.109.0",
"nc-plugin": "^0.1.3",
"ncp": "^2.0.0",
"nocodb-sdk": "0.109.0",
"nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10",
"object-hash": "^3.0.0",
"os-locale": "^6.0.2",
@ -191,7 +191,6 @@
},
"../nocodb-sdk": {
"version": "0.109.0",
"extraneous": true,
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.1",
@ -13207,13 +13206,8 @@
}
},
"node_modules/nocodb-sdk": {
"version": "0.109.0",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.109.0.tgz",
"integrity": "sha512-5yKLiiDR0noHdhyOqqdF/+UWyTqU7em6QZouURRQSxC72qHU1KBrL1ig5JaIL0CX0pwlANq9hnQ0OzSH8J46fQ==",
"dependencies": {
"axios": "^0.21.1",
"jsep": "^1.3.6"
}
"resolved": "../nocodb-sdk",
"link": true
},
"node_modules/node-abort-controller": {
"version": "3.1.1",
@ -28485,12 +28479,22 @@
"integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg=="
},
"nocodb-sdk": {
"version": "0.109.0",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.109.0.tgz",
"integrity": "sha512-5yKLiiDR0noHdhyOqqdF/+UWyTqU7em6QZouURRQSxC72qHU1KBrL1ig5JaIL0CX0pwlANq9hnQ0OzSH8J46fQ==",
"version": "file:../nocodb-sdk",
"requires": {
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"axios": "^0.21.1",
"jsep": "^1.3.6"
"cspell": "^4.1.0",
"eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^4.0.0",
"jsep": "^1.3.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
}
},
"node-abort-controller": {

4
packages/nocodb/package.json

@ -116,7 +116,7 @@
"nc-lib-gui": "0.109.0",
"nc-plugin": "^0.1.3",
"ncp": "^2.0.0",
"nocodb-sdk": "0.109.0",
"nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10",
"object-hash": "^3.0.0",
"os-locale": "^6.0.2",
@ -203,4 +203,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}

3
packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts

@ -1118,8 +1118,9 @@ class MssqlClient extends KnexClient {
args.databaseName = this.connectionConfig.connection.database;
const response = await this.sqlClient.raw(
`SELECT v.name AS view_name,v.*,m.* FROM sys.views v INNER JOIN sys.schemas s ON s.schema_id = v.schema_id
`SELECT v.name AS view_name,v.*,m.* FROM sys.views v INNER JOIN sys.schemas s ON s.schema_id = v.schema_id AND schema_name(v.schema_id) = ?
INNER JOIN sys.sql_modules AS m ON m.object_id = v.object_id`,
[this.schema || 'dbo'],
);
result.data.list = response;

3
packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts

@ -1350,7 +1350,8 @@ class PGClient extends KnexClient {
const { rows } = await this.sqlClient.raw(
`select *
from INFORMATION_SCHEMA.views
WHERE table_schema = ANY (current_schemas(false));`,
WHERE table_schema = ?;`,
[this.schema],
);
for (let i = 0; i < rows.length; ++i) {

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

@ -236,6 +236,16 @@ export default class ProjectUser {
projectList = await ncMeta
.knex(MetaTable.PROJECT)
.select(`${MetaTable.PROJECT}.*`)
.select(`${MetaTable.PROJECT}.title`)
.select(`${MetaTable.PROJECT}.prefix`)
.select(`${MetaTable.PROJECT}.status`)
.select(`${MetaTable.PROJECT}.description`)
.select(`${MetaTable.PROJECT}.meta`)
.select(`${MetaTable.PROJECT}.color`)
.select(`${MetaTable.PROJECT}.is_meta`)
.select(`${MetaTable.PROJECT}.created_at`)
.select(`${MetaTable.PROJECT}.updated_at`)
.select(`${MetaTable.PROJECT_USERS}.roles`)
.innerJoin(MetaTable.PROJECT_USERS, function () {
this.on(
`${MetaTable.PROJECT_USERS}.project_id`,

2
packages/nocodb/src/services/datas.service.ts

@ -106,7 +106,7 @@ export class DatasService {
// todo: Should have error http status code
const message = await baseModel.hasLTARData(param.rowId, model);
if (message.length) {
return { message };
NcError.badRequest(message);
}
return await baseModel.delByPk(param.rowId, null, param.cookie);
}

8
packages/nocodb/tests/unit/rest/tests/tableRow.test.ts

@ -1425,7 +1425,7 @@ function tableTest() {
const response = await request(context.app)
.delete(`/api/v1/db/data/noco/${project.id}/${table.id}/${row['Id']}`)
.set('xc-auth', context.token)
.expect(200);
.expect(400);
const deleteRow = await getRow(context, { project, table, id: row['Id'] });
if (!deleteRow) {
@ -1433,11 +1433,9 @@ function tableTest() {
}
if (
!(response.body.message[0] as string).includes(
'is a LinkToAnotherRecord of',
)
!(response.body.msg as string).includes('is a LinkToAnotherRecord of')
) {
throw new Error('Should give ltar foreign key error');
throw new Error('Should give LTAR foreign key error');
}
});

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

@ -1,12 +1,11 @@
import 'mocha';
import { isString } from 'util';
import request from 'supertest';
import { UITypes, ViewTypes } from 'nocodb-sdk';
import { expect } from 'chai';
import init from '../../init';
import { createProject, createSakilaProject } from '../../factory/project';
import request from 'supertest';
import Project from '../../../../src/models/Project';
import Model from '../../../../src/models/Model';
import { createTable, getTable } from '../../factory/table';
import View from '../../../../src/models/View';
import { ColumnType, UITypes, ViewTypes } from 'nocodb-sdk';
import { createView } from '../../factory/view';
import {
createColumn,
@ -21,9 +20,11 @@ import {
getOneRow,
getRow,
} from '../../factory/row';
import { expect } from 'chai';
import { isPg } from '../../init/db';
import { isString } from 'util';
import type { ColumnType } from 'nocodb-sdk';
import type View from '../../../../src/models/View';
import type Model from '../../../../src/models/Model';
import type Project from '../../../../src/models/Project';
// Test case list
// 1. Get view row list g
@ -160,7 +161,7 @@ function viewRowTests() {
const testGetViewRowList = async (view: View) => {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.expect(200);
@ -179,7 +180,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
)
.set('xc-auth', context.token)
.expect(200);
@ -225,7 +226,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -244,7 +245,7 @@ function viewRowTests() {
requiredColumns.map((c: ColumnType) => ({
title: c.title,
uidt: c.uidt,
}))
})),
);
throw new Error('Wrong columns');
}
@ -271,7 +272,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
)
.set('xc-auth', context.token)
.query({
@ -287,7 +288,7 @@ function viewRowTests() {
expect(
Object.keys(response.body.find((e) => e.key === 'NC-17').value.list[0])
.sort()
.join(',')
.join(','),
).to.equal('FilmId,Title');
};
@ -297,14 +298,14 @@ function viewRowTests() {
const testDescSortedViewDataList = async (view: View) => {
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
(col) => col.title === 'FirstName',
);
const visibleColumns = [firstNameColumn];
const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'desc' }];
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -332,7 +333,7 @@ function viewRowTests() {
Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize;
const lastPageResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -375,7 +376,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
)
.set('xc-auth', context.token)
.query({
@ -390,7 +391,7 @@ function viewRowTests() {
expect(response.body).to.be.have.length(6);
expect(
response.body.find((e) => e.key === 'PG').value.list[0].Title
response.body.find((e) => e.key === 'PG').value.list[0].Title,
).to.equal('WORST BANGER');
};
@ -400,14 +401,14 @@ function viewRowTests() {
const testAscSortedViewDataList = async (view: View) => {
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
(col) => col.title === 'FirstName',
);
const visibleColumns = [firstNameColumn];
const sortInfo = [{ fk_column_id: firstNameColumn.id, direction: 'asc' }];
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -435,7 +436,7 @@ function viewRowTests() {
Math.trunc(pageInfo.totalRows / pageInfo.pageSize) * pageInfo.pageSize;
const lastPageResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -478,7 +479,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${filmTable.id}/views/${view.id}/group/${ratingColumn.id}`,
)
.set('xc-auth', context.token)
.query({
@ -493,7 +494,7 @@ function viewRowTests() {
expect(response.body).to.be.have.length(6);
expect(
response.body.find((e) => e.key === 'PG').value.list[0].Title
response.body.find((e) => e.key === 'PG').value.list[0].Title,
).to.equal('ACADEMY DINOSAUR');
};
@ -502,7 +503,7 @@ function viewRowTests() {
});
const testGetViewDataListWithRequiredColumnsAndFilter = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const rentalTable = await getTable({
project: sakilaProject,
@ -523,7 +524,7 @@ function viewRowTests() {
});
const paymentListColumn = (await rentalTable.getColumns()).find(
(c) => c.title === 'Payment List'
(c) => c.title === 'Payment List',
);
const nestedFilter = {
@ -549,7 +550,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -560,7 +561,7 @@ function viewRowTests() {
const ascResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -579,7 +580,7 @@ function viewRowTests() {
const descResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${rentalTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -606,7 +607,7 @@ function viewRowTests() {
});
const testGetNestedSortedFilteredTableDataListWithLookupColumn = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const view = await createView(context, {
title: 'View',
@ -624,11 +625,11 @@ function viewRowTests() {
});
const paymentListColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Payment List'
(c) => c.title === 'Payment List',
);
const activeColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Active'
(c) => c.title === 'Active',
);
const nestedFields = {
@ -681,7 +682,7 @@ function viewRowTests() {
const ascResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.query({
@ -703,7 +704,7 @@ function viewRowTests() {
}
const nestedRentalResponse = Object.keys(
ascResponse.body.list[0]['Rental List'][0]
ascResponse.body.list[0]['Rental List'][0],
);
if (
@ -719,7 +720,7 @@ function viewRowTests() {
it('Get nested sorted filtered table with nested fields data list with a rollup column in customer table view grid', async () => {
await testGetNestedSortedFilteredTableDataListWithLookupColumn(
ViewTypes.GRID
ViewTypes.GRID,
);
});
@ -774,7 +775,7 @@ function viewRowTests() {
await request(context.app)
.post(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${nonRelatedView.id}`,
)
.set('xc-auth', context.token)
.send({
@ -802,7 +803,7 @@ function viewRowTests() {
// todo: Test that all the columns needed to be shown in the view are returned
const testFindOneSortedDataWithRequiredColumns = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const view = await createView(context, {
title: 'View',
@ -810,13 +811,13 @@ function viewRowTests() {
type: viewType,
});
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
(col) => col.title === 'FirstName',
);
const visibleColumns = [firstNameColumn];
let response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
)
.set('xc-auth', context.token)
.query({
@ -837,7 +838,7 @@ function viewRowTests() {
response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
)
.set('xc-auth', context.token)
.query({
@ -870,7 +871,7 @@ function viewRowTests() {
});
const testFindOneSortedFilteredNestedFieldsDataWithRollup = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const rollupColumn = await createRollupColumn(context, {
project: sakilaProject,
@ -893,11 +894,11 @@ function viewRowTests() {
});
const paymentListColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Payment List'
(c) => c.title === 'Payment List',
);
const activeColumn = (await customerTable.getColumns()).find(
(c) => c.title === 'Active'
(c) => c.title === 'Active',
);
const nestedFields = {
@ -950,7 +951,7 @@ function viewRowTests() {
const ascResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/find-one`,
)
.set('xc-auth', context.token)
.query({
@ -995,7 +996,7 @@ function viewRowTests() {
type: viewType,
});
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
(col) => col.title === 'FirstName',
);
const rollupColumn = await createRollupColumn(context, {
@ -1012,7 +1013,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`,
)
.set('xc-auth', context.token)
.query({
@ -1049,7 +1050,7 @@ function viewRowTests() {
});
const firstNameColumn = customerColumns.find(
(col) => col.title === 'FirstName'
(col) => col.title === 'FirstName',
);
const rollupColumn = await createRollupColumn(context, {
@ -1066,7 +1067,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/groupby`,
)
.set('xc-auth', context.token)
.query({
@ -1105,7 +1106,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/count`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1136,7 +1137,7 @@ function viewRowTests() {
const listResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1145,7 +1146,7 @@ function viewRowTests() {
const readResponse = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1181,7 +1182,7 @@ function viewRowTests() {
const updateResponse = await request(context.app)
.patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
)
.set('xc-auth', context.token)
.send({
@ -1207,7 +1208,7 @@ function viewRowTests() {
});
const testUpdateViewRowWithValidationAndInvalidData = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const table = await createTable(context, project);
const emailColumn = await createColumn(context, table, {
@ -1228,7 +1229,7 @@ function viewRowTests() {
await request(context.app)
.patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
)
.set('xc-auth', context.token)
.send({
@ -1253,7 +1254,7 @@ function viewRowTests() {
// todo: Test with form view
const testUpdateViewRowWithValidationAndValidData = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const table = await createTable(context, project);
const emailColumn = await createColumn(context, table, {
@ -1273,7 +1274,7 @@ function viewRowTests() {
const response = await request(context.app)
.patch(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
)
.set('xc-auth', context.token)
.send({
@ -1314,7 +1315,7 @@ function viewRowTests() {
await request(context.app)
.delete(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1339,7 +1340,7 @@ function viewRowTests() {
});
const testDeleteViewRowWithForiegnKeyConstraint = async (
viewType: ViewTypes
viewType: ViewTypes,
) => {
const table = await createTable(context, project);
const relatedTable = await createTable(context, project, {
@ -1371,10 +1372,10 @@ function viewRowTests() {
const response = await request(context.app)
.delete(
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`
`/api/v1/db/data/noco/${project.id}/${table.id}/views/${view.id}/${row['Id']}`,
)
.set('xc-auth', context.token)
.expect(200);
.expect(400);
const deleteRow = await getRow(context, { project, table, id: row['Id'] });
if (!deleteRow) {
@ -1382,9 +1383,7 @@ function viewRowTests() {
}
if (
!(response.body.message[0] as string).includes(
'is a LinkToAnotherRecord of'
)
!(response.body.msg as string).includes('is a LinkToAnotherRecord of')
) {
throw new Error('Should give ltar foreign key error');
}
@ -1415,7 +1414,7 @@ function viewRowTests() {
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}/exist`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/${row['CustomerId']}/exist`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1445,7 +1444,7 @@ function viewRowTests() {
});
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/999999/exist`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/views/${view.id}/999999/exist`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1475,7 +1474,7 @@ function viewRowTests() {
});
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/csv`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/csv`,
)
.set('xc-auth', context.token)
.expect(200);
@ -1499,7 +1498,7 @@ function viewRowTests() {
});
const response = await request(context.app)
.get(
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/excel`
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.title}/views/${view.id}/export/excel`,
)
.set('xc-auth', context.token)
.expect(200);

Loading…
Cancel
Save