From e57b3bdc5962e5ab10106ee67f868a402c6f8812 Mon Sep 17 00:00:00 2001 From: Maksim Sitnikov Date: Tue, 21 Nov 2023 12:03:13 +0300 Subject: [PATCH] Add ability to move content from one tenant to another (#25) * Add ability to move content between tenants * fixes --- src/components/error-response-presenter.ts | 18 ++++++++++++++++++ src/const/us-error-constants.ts | 2 ++ src/services/entry/actions/copy-to-workbook.ts | 2 +- src/types/models/dls.ts | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/error-response-presenter.ts b/src/components/error-response-presenter.ts index 9aa9904b..4c679783 100644 --- a/src/components/error-response-presenter.ts +++ b/src/components/error-response-presenter.ts @@ -617,6 +617,24 @@ export default (error: AppError | DBError) => { }, }; } + case US_ERRORS.MOVE_TENANT_CONTENT_DENIED: { + return { + code: 403, + response: { + code, + message: message ?? 'Move tenant content denied', + }, + }; + } + case US_ERRORS.MOVE_TENANT_CONTENT_ERROR: { + return { + code: 500, + response: { + code, + message: message ?? 'Move tenant content error', + }, + }; + } default: return { code: 500, diff --git a/src/const/us-error-constants.ts b/src/const/us-error-constants.ts index 8ed8fbc9..50ebbbe2 100644 --- a/src/const/us-error-constants.ts +++ b/src/const/us-error-constants.ts @@ -88,6 +88,8 @@ const US_ERRORS = { ENTRY_IS_NOT_IN_WORKBOOK: 'ENTRY_IS_NOT_IN_WORKBOOK', UNKNOWN_OPERATION_TYPE: 'UNKNOWN_OPERATION_TYPE', IAM_OPERATION_NOT_EXISTS: 'IAM_OPERATION_NOT_EXISTS', + MOVE_TENANT_CONTENT_DENIED: 'MOVE_TENANT_CONTENT_DENIED', + MOVE_TENANT_CONTENT_ERROR: 'MOVE_TENANT_CONTENT_ERROR', }; export const ERROR_BY_DLS_STATUS_CODE: {[key: number]: string} = { diff --git a/src/services/entry/actions/copy-to-workbook.ts b/src/services/entry/actions/copy-to-workbook.ts index 78abab82..d6684db1 100644 --- a/src/services/entry/actions/copy-to-workbook.ts +++ b/src/services/entry/actions/copy-to-workbook.ts @@ -68,7 +68,7 @@ export const copyToWorkbook = async (ctx: CTX, params: Params) => { logInfo(ctx, 'COPY_ENTRY_TO_WORKBOOK_CALL', { entryIds: entryIds.map((entryId) => Utils.encodeId(entryId)), - destinationWorkbookId, + destinationWorkbookId: Utils.encodeId(destinationWorkbookId), tenantIdOverride, }); diff --git a/src/types/models/dls.ts b/src/types/models/dls.ts index 733cccea..82ea9b22 100644 --- a/src/types/models/dls.ts +++ b/src/types/models/dls.ts @@ -8,7 +8,7 @@ export enum DlsActions { Edit = 'edit', SetPermissions = 'set_permissions', } -enum DlsPermissions { +export enum DlsPermissions { Execute = 'acl_execute', Read = 'acl_view', Write = 'acl_edit',