π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: folders
Raju Udava5648cdd58e5d
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.jsonindex 93a2add813..767712e63d 100644--- a/packages/nc-gui/lang/en.json+++ b/packages/nc-gui/lang/en.json@@ -215,6 +215,7 @@"upgradeToUseRlsSubtitle": "Upgrade to the {plan} plan to define row-level security policies that control which rows users can access."},"general": {+ "none": "None","done": "Done","properties": "Properties","authorization": "Authorization",@@ -553,6 +554,8 @@"recordTemplates": "Record Templates","view": "View","views": "Views",+ "section": "Section",+ "sections": "Sections","sidebar": "Sidebar","viewType": {"grid": "Grid",@@ -1528,6 +1531,7 @@"clickToCopyViewID": "Click to copy View ID","clickToCopyExtensionID": "Click to copy Extension ID","viewMode": "View mode",+ "moveToSection": "Move to section","assignAsPersonalView": "Assign as personal view","reAssignView": "Re-assign personal view","reAssignThisView": "Re-assign this view",@@ -2602,6 +2606,7 @@"noTemplatesDesc": "Create a template to quickly add records with pre-filled values","nestedRecordConfigPlaceholder": "Configure the fields for the linked record","deleteTemplateConfirm": "Are you sure you want to delete this template? This action cannot be undone.",+ "sectionDeleteConfirmation": "Views in this section will be moved to the top level.","noEditableCellsToClear": "No editable cells to clear","defaultValSyncedCol": "Default values cannot be set for fields synced from external sources","uniqueConstraintTooltip": "Prevents duplicate non-empty values across records. Empty cells are allowed.",diff --git a/packages/nocodb-sdk/src/lib/enums.ts b/packages/nocodb-sdk/src/lib/enums.tsindex 7b7e116b6f..9fcff2c948 100644--- a/packages/nocodb-sdk/src/lib/enums.ts+++ b/packages/nocodb-sdk/src/lib/enums.ts@@ -279,6 +279,10 @@ export enum AppEvents {RLS_POLICY_CREATE = 'rls_policy.create',RLS_POLICY_UPDATE = 'rls_policy.update',RLS_POLICY_DELETE = 'rls_policy.delete',++ VIEW_SECTION_CREATE = 'viewSection.create',+ VIEW_SECTION_UPDATE = 'viewSection.update',+ VIEW_SECTION_DELETE = 'viewSection.delete',}export enum ClickhouseTables {diff --git a/packages/nocodb-sdk/src/lib/error-handler/nc-error-base.ts b/packages/nocodb-sdk/src/lib/error-handler/nc-error-base.tsindex 5eb475dbd9..a3e109f222 100644--- a/packages/nocodb-sdk/src/lib/error-handler/nc-error-base.ts+++ b/packages/nocodb-sdk/src/lib/error-handler/nc-error-base.ts@@ -98,6 +98,13 @@ export class NcErrorBase {});}+ viewSectionNotFound(id: string, args?: NcErrorArgs): never {+ throw this.errorCodex.generateError(NcErrorType.ERR_VIEW_SECTION_NOT_FOUND, {+ params: id,+ ...args,+ });+ }+apiClientNotFound(id: string, args?: NcErrorArgs): never {throw this.errorCodex.generateError(NcErrorType.ERR_API_CLIENT_NOT_FOUND, {params: id,diff --git a/packages/nocodb-sdk/src/lib/error-handler/preset-error-codex-map.ts b/packages/nocodb-sdk/src/lib/error-handler/preset-error-codex-map.tsindex 501158b07c..db1c28c654 100644--- a/packages/nocodb-sdk/src/lib/error-handler/preset-error-codex-map.ts+++ b/packages/nocodb-sdk/src/lib/error-handler/preset-error-codex-map.ts@@ -100,6 +100,10 @@ export const presetErrorCodexMap: Partial<message: (id: string) => `Widget '${id}' not found`,code: 404,},+ [NcErrorType.ERR_VIEW_SECTION_NOT_FOUND]: {+ message: (id: string) => `View section '${id}' not found`,+ code: 404,+ },[NcErrorType.ERR_DASHBOARD_NOT_FOUND]: {message: (id: string) => `Dashboard '${id}' not found`,code: 404,diff --git a/packages/nocodb-sdk/src/lib/globals.ts b/packages/nocodb-sdk/src/lib/globals.tsindex 8607c73448..71521262b4 100644--- a/packages/nocodb-sdk/src/lib/globals.ts+++ b/packages/nocodb-sdk/src/lib/globals.ts@@ -210,6 +210,7 @@ export enum NcErrorType {ERR_DASHBOARD_NOT_FOUND = 'ERR_DASHBOARD_NOT_FOUND',ERR_WORKFLOW_NOT_FOUND = 'ERR_WORKFLOW_NOT_FOUND',ERR_WIDGET_NOT_FOUND = 'ERR_WIDGET_NOT_FOUND',+ ERR_VIEW_SECTION_NOT_FOUND = 'ERR_VIEW_SECTION_NOT_FOUND',ERR_SHARED_DASHBOARD_PASSWORD_INVALID = 'ERR_SHARED_DASHBOARD_PASSWORD_INVALID',ERR_DUPLICATE_IN_ALIAS = 'ERR_DUPLICATE_IN_ALIAS',ERR_OUT_OF_SYNC = 'ERR_OUT_OF_SYNC',diff --git a/packages/nocodb/src/helpers/ncError.ts b/packages/nocodb/src/helpers/ncError.tsindex 6bc7db317f..99f405f45a 100644--- a/packages/nocodb/src/helpers/ncError.ts+++ b/packages/nocodb/src/helpers/ncError.ts@@ -57,6 +57,10 @@ export class NcError {return NcError._.dashboardNotFound(id, args);}+ static viewSectionNotFound(id: string, args?: NcErrorArgs): never {+ return NcError._.viewSectionNotFound(id, args);+ }+static sourceNotFound(id: string, args?: NcErrorArgs): never {return NcError._.sourceNotFound(id, args);}diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.tsindex 2b622ae35d..82da7dc409 100644--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts@@ -86,6 +86,7 @@ import * as nc_094_add_meta_to_filter_exp_v2 from '~/meta/migrations/v2/nc_094_aimport * as nc_096_deprecate_unused from '~/meta/migrations/v2/nc_096_deprecate_unused';import * as nc_097_unify_schema from '~/meta/migrations/v2/nc_097_unify_schema';import * as nc_098_default_workspace from '~/meta/migrations/v2/nc_098_default_workspace';+import * as nc_099_view_sections from '~/meta/migrations/v2/nc_099_view_sections';// Create a custom migration source classexport default class XcMigrationSourcev2 {@@ -181,6 +182,7 @@ export default class XcMigrationSourcev2 {'nc_096_deprecate_unused','nc_097_unify_schema','nc_098_default_workspace',+ 'nc_099_view_sections',]);}@@ -362,6 +364,8 @@ export default class XcMigrationSourcev2 {return nc_097_unify_schema;case 'nc_098_default_workspace':return nc_098_default_workspace;+ case 'nc_099_view_sections':+ return nc_099_view_sections;}}}diff --git a/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts b/packages/nocodb/src/meta/migrations/v0/nc_001_init.tsindex 5f30d2a243..6d5cc08a47 100644--- a/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts+++ b/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts@@ -1270,6 +1270,26 @@ const up = async (knex: Knex) => {table.timestamps(true, true);});+ await knex.schema.createTable(MetaTable.VIEW_SECTIONS, (table) => {+ table.string('id', 20).notNullable();++ table.string('fk_workspace_id', 20);+ table.string('base_id', 20);+ table.string('source_id', 20);++ table.string('fk_model_id', 20).notNullable();+ table.string('title', 255).notNullable();+ table.float('order');+ table.text('meta');++ table.string('created_by', 20);+ table.string('updated_by', 20);++ table.timestamps(true, true);++ table.primary(['base_id', 'id']);+ });+await knex.schema.createTable(MetaTable.VIEWS, (table) => {table.string('id', 20).notNullable();table.string('source_id', 20);@@ -1293,6 +1313,7 @@ const up = async (knex: Knex) => {table.string('expanded_record_mode', 255);table.string('fk_custom_url_id', 20);table.string('row_coloring_mode', 10);+ table.string('fk_view_section_id', 20);table.timestamps(true, true);table.primary(['base_id', 'id']);});@@ -1443,6 +1464,15 @@ const up = async (knex: Knex) => {table.index(['id'], 'nc_widgets_v2_oldpk_idx');});+ await knex.schema.alterTable(MetaTable.VIEW_SECTIONS, (table) => {+ table.index(+ ['base_id', 'fk_workspace_id'],+ 'nc_view_sections_context',+ );+ table.index('fk_model_id', 'nc_view_sections_model_idx');+ table.index(['id'], 'nc_view_sections_v2_oldpk_idx');+ });+await knex.schema.alterTable(MetaTable.PERMISSIONS, (table) => {table.index(['base_id', 'fk_workspace_id'], 'nc_permissions_context');table.index(['entity', 'entity_id', 'permission'], 'nc_permissions_entity');@@ -2138,6 +2168,7 @@ const down = async (knex: Knex) => {await knex.schema.dropTableIfExists(MetaTable.WORKSPACE_USER);await knex.schema.dropTableIfExists(MetaTable.WORKSPACE);await knex.schema.dropTableIfExists(MetaTable.NOTIFICATION);+ await knex.schema.dropTableIfExists(MetaTable.VIEW_SECTIONS);await knex.schema.dropTableIfExists(MetaTable.VIEWS);await knex.schema.dropTableIfExists(MetaTable.USERS);await knex.schema.dropTableIfExists(MetaTable.USER_REFRESH_TOKENS);diff --git a/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.ts b/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.tsnew file mode 100644index 0000000000..7f5fd27a1c--- /dev/null+++ b/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.ts@@ -0,0 +1,43 @@+import type { Knex } from 'knex';+import { MetaTable } from '~/utils/globals';++const up = async (knex: Knex) => {+ await knex.schema.createTable(MetaTable.VIEW_SECTIONS, (table) => {+ table.string('id', 20).primary().notNullable();++ table.string('fk_workspace_id', 20);+ table.string('base_id', 20);+ table.string('source_id', 20);+ table.string('fk_model_id', 20).notNullable();++ table.string('title', 255).notNullable();+ table.float('order');+ table.text('meta');++ table.string('created_by', 20);+ table.string('updated_by', 20);++ table.timestamps(true, true);++ table.index(['base_id', 'fk_workspace_id'], 'nc_view_sections_context');+ table.index('fk_model_id', 'nc_view_sections_model_idx');+ });++ if (!(await knex.schema.hasColumn(MetaTable.VIEWS, 'fk_view_section_id'))) {+ await knex.schema.alterTable(MetaTable.VIEWS, (table) => {+ table.string('fk_view_section_id', 20).nullable();+ });+ }+};++const down = async (knex: Knex) => {+ await knex.schema.dropTableIfExists(MetaTable.VIEW_SECTIONS);++ if (await knex.schema.hasColumn(MetaTable.VIEWS, 'fk_view_section_id')) {+ await knex.schema.alterTable(MetaTable.VIEWS, (table) => {+ table.dropColumn('fk_view_section_id');+ });+ }+};++export { up, down };diff --git a/packages/nocodb/src/middlewares/extract-ids/extract-ids.middleware.ts b/packages/nocodb/src/middlewares/extract-ids/extract-ids.middleware.tsindex e85b2e290e..2814f424f2 100644--- a/packages/nocodb/src/middlewares/extract-ids/extract-ids.middleware.ts+++ b/packages/nocodb/src/middlewares/extract-ids/extract-ids.middleware.ts@@ -44,6 +44,7 @@ import {Source,SyncSource,View,+ ViewSection,Widget,Workspace,} from '~/models';@@ -172,6 +173,7 @@ export class ExtractIdsMiddleware implements NestMiddleware, CanActivate {const filterId = params.filterId || query.filterId;const filterParentId = params.filterParentId || query.filterParentId;const widgetId = params.widgetId || query.widgetId;+ const sectionId = params.sectionId || query.sectionId;const sortId = params.sortId || query.sortId;const syncId = params.syncId || query.syncId;const extensionId = params.extensionId || query.extensionId;@@ -379,6 +381,14 @@ export class ExtractIdsMiddleware implements NestMiddleware, CanActivate {if (!widget) {NcError.genericNotFound('Widget', widgetId);}+ } else if (sectionId) {+ const section = await ViewSection.get(context, sectionId);++ if (!section) {+ NcError.viewSectionNotFound(sectionId);+ }++ req.ncSourceId = section.source_id;} else if (sortId) {const sort = await Sort.get(context, sortId);@@ -734,6 +744,19 @@ export class ExtractIdsMiddleware implements NestMiddleware, CanActivate {}req.ncBaseId = widget.base_id;+ } else if (params.sectionId) {+ const section = await ViewSection.get(context, params.sectionId);++ if (!section) {+ NcError.viewSectionNotFound(params.sectionId);+ }++ req.ncBaseId = section.base_id;+ req.ncSourceId = section.source_id;++ if (section.fk_model_id) {+ tableIdToCheck = section.fk_model_id;+ }} else if (params.sortId) {const sort = await Sort.get(context, params.sortId);diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.tsindex f604221be3..c454fbd3e8 100644--- a/packages/nocodb/src/models/View.ts+++ b/packages/nocodb/src/models/View.ts@@ -126,6 +126,7 @@ export default class View implements ViewType {show_system_fields?: boolean;meta?: any;fk_custom_url_id?: string;+ fk_view_section_id?: string;constructor(data: View) {Object.assign(this, data);@@ -1572,6 +1573,7 @@ export default class View implements ViewType {expanded_record_mode?: ExpandedFormModeType;attachment_mode_column_id?: string;fk_custom_url_id?: string;+ fk_view_section_id?: string | null;row_coloring_mode?: ROW_COLORING_MODE;},includeCreatedByAndUpdateBy = false,@@ -1588,6 +1590,7 @@ export default class View implements ViewType {'uuid','row_coloring_mode',...(isEE ? ['fk_custom_url_id'] : []),+ ...(isEE ? ['fk_view_section_id'] : []),...(includeCreatedByAndUpdateBy ? ['owned_by', 'created_by'] : []),...(isEE ? ['expanded_record_mode', 'attachment_mode_column_id'] : []),]);diff --git a/packages/nocodb/src/models/ViewSection.ts b/packages/nocodb/src/models/ViewSection.tsnew file mode 100644index 0000000000..6cb9a55cab--- /dev/null+++ b/packages/nocodb/src/models/ViewSection.ts@@ -0,0 +1,29 @@+export default class ViewSection {+ constructor(data: ViewSection) {+ Object.assign(this, data);+ }++ public static async get(..._args) {+ return null;+ }++ public static async list(..._args) {+ return [];+ }++ static async insert(..._args) {+ return null;+ }++ static async update(..._args) {+ return null;+ }++ static async delete(..._args) {+ return null;+ }++ static async deleteByModelId(..._args) {+ return true;+ }+}diff --git a/packages/nocodb/src/models/index.ts b/packages/nocodb/src/models/index.tsindex ff93c0bd19..88a5cb936d 100644--- a/packages/nocodb/src/models/index.ts+++ b/packages/nocodb/src/models/index.ts@@ -65,5 +65,6 @@ export { default as OAuthToken } from './OAuthToken';export { default as WorkspaceUser } from './WorkspaceUser';export { default as Workspace } from './Workspace';export { default as DependencyTracker } from './DependencyTracker';+export { default as ViewSection } from './ViewSection';export { default as Widget } from './Widget';export { default as Workflow } from './Workflow';diff --git a/packages/nocodb/src/utils/globals.ts b/packages/nocodb/src/utils/globals.tsindex 3169756b87..0a295b86c6 100644--- a/packages/nocodb/src/utils/globals.ts+++ b/packages/nocodb/src/utils/globals.ts@@ -117,6 +117,7 @@ export enum MetaTable {RECORD_TEMPLATES = 'nc_record_templates',RLS_POLICIES = 'nc_rls_policies',RLS_POLICY_SUBJECTS = 'nc_rls_policy_subjects',+ VIEW_SECTIONS = 'nc_view_sections_v2',}export const BaseRelatedMetaTables = [@@ -362,6 +363,7 @@ export enum CacheScope {SCIM_CONFIG = 'scimConfig',RECORD_TEMPLATE = 'recordTemplate',RLS_POLICY = 'rlsPolicy',+ VIEW_SECTION = 'viewSection',}export enum CacheGetType {