From 41d9f6a953c634ccafbf71d1e9367baaf28b749f Mon Sep 17 00:00:00 2001 From: naumov Date: Fri, 16 Feb 2024 14:08:20 +0100 Subject: [PATCH 1/4] CB-4700 allow administrators to copy data --- .../plugin-data-viewer/src/DataViewerService.ts | 10 +++++++++- webapp/packages/plugin-data-viewer/src/locales/en.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/it.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/ru.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/zh.ts | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts index 27b95e75c3..e36d6f32e3 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts @@ -7,16 +7,24 @@ */ import type { Connection } from '@cloudbeaver/core-connections'; import { injectable } from '@cloudbeaver/core-di'; +import { EAdminPermission, SessionPermissionsResource } from '@cloudbeaver/core-root'; import { DataViewerSettingsService } from './DataViewerSettingsService'; @injectable() export class DataViewerService { get canCopyData() { + if (this.sessionPermissionsResource.has(EAdminPermission.admin)) { + return true; + } + return !this.dataViewerSettingsService.settings.getValue('disableCopyData'); } - constructor(private readonly dataViewerSettingsService: DataViewerSettingsService) {} + constructor( + private readonly dataViewerSettingsService: DataViewerSettingsService, + private readonly sessionPermissionsResource: SessionPermissionsResource, + ) {} isDataEditable(connection: Connection) { const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit'); diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index 6831fdab89..cb3dc0fa47 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -52,7 +52,7 @@ export default [ ['settings_data_editor_disable_edit_name', 'Disable Edit'], ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], - ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer'], + ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], ['settings_data_editor_fetch_min_description', 'Minimum number of rows to fetch'], ['settings_data_editor_fetch_max_name', 'Maximum fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index 35306f85a3..639558f87b 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -45,7 +45,7 @@ export default [ ['settings_data_editor_disable_edit_name', 'Disable Edit'], ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], - ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer'], + ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], ['settings_data_editor_fetch_min_description', 'Minimum number of rows to fetch'], ['settings_data_editor_fetch_max_name', 'Maximum fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/ru.ts b/webapp/packages/plugin-data-viewer/src/locales/ru.ts index 05dd579c74..e1910e00ca 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -46,7 +46,7 @@ export default [ ['settings_data_editor_disable_edit_name', 'Отключить редактирование'], ['settings_data_editor_disable_edit_description', 'Отключить редактирование данных'], ['settings_data_editor_disable_data_copy_name', 'Отключить копирование'], - ['settings_data_editor_disable_data_copy_description', 'Отключить копирование данных'], + ['settings_data_editor_disable_data_copy_description', 'Отключить копирование данных для пользователей без прав администратора'], ['settings_data_editor_fetch_min_name', 'Минимальный размер выборки'], ['settings_data_editor_fetch_min_description', 'Минимальное количество строк для выборки'], ['settings_data_editor_fetch_max_name', 'Максимальный размер выборки'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/zh.ts b/webapp/packages/plugin-data-viewer/src/locales/zh.ts index 4c0bba6c65..d9cfbffd29 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -52,7 +52,7 @@ export default [ ['settings_data_editor_disable_edit_name', 'Disable Edit'], ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], - ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer'], + ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], ['settings_data_editor_fetch_min_description', 'Minimum number of rows to fetch'], ['settings_data_editor_fetch_max_name', 'Maximum fetch size'], From 11dedd7cf318789c89e62e97d793b7e63eaa8ac1 Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 21 Feb 2024 15:26:24 +0100 Subject: [PATCH 2/4] CB-4700 allow editing for admin --- .../packages/plugin-data-viewer/src/DataViewerService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts index e36d6f32e3..98d125ab8d 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts @@ -27,7 +27,13 @@ export class DataViewerService { ) {} isDataEditable(connection: Connection) { + const isAdmin = this.sessionPermissionsResource.has(EAdminPermission.admin); const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit'); - return !disabled && !connection.readOnly; + + if (disabled) { + return isAdmin; + } + + return !connection.readOnly; } } From c7cf17e77c0d9c8cad56ee6b35442242ddd82e43 Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 21 Feb 2024 15:49:51 +0100 Subject: [PATCH 3/4] CB-4700 change desc message --- webapp/packages/plugin-data-viewer/src/locales/en.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/it.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/ru.ts | 2 +- webapp/packages/plugin-data-viewer/src/locales/zh.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index cb3dc0fa47..afeb6a8def 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -50,7 +50,7 @@ export default [ ['data_viewer_model_not_loaded', 'Table model is not loaded'], ['settings_data_editor', 'Data Editor'], ['settings_data_editor_disable_edit_name', 'Disable Edit'], - ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], + ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer for non-admin users'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index 639558f87b..a35769e675 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -43,7 +43,7 @@ export default [ ['data_viewer_model_not_loaded', 'Table model is not loaded'], ['settings_data_editor', 'Data Editor'], ['settings_data_editor_disable_edit_name', 'Disable Edit'], - ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], + ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer for non-admin users'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/ru.ts b/webapp/packages/plugin-data-viewer/src/locales/ru.ts index e1910e00ca..307b45cd6b 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -44,7 +44,7 @@ export default [ ['data_viewer_model_not_loaded', 'Не удалось загрузить модель таблицы'], ['settings_data_editor', 'Редактор данных'], ['settings_data_editor_disable_edit_name', 'Отключить редактирование'], - ['settings_data_editor_disable_edit_description', 'Отключить редактирование данных'], + ['settings_data_editor_disable_edit_description', 'Отключить редактирование данных для пользователей без прав администратора'], ['settings_data_editor_disable_data_copy_name', 'Отключить копирование'], ['settings_data_editor_disable_data_copy_description', 'Отключить копирование данных для пользователей без прав администратора'], ['settings_data_editor_fetch_min_name', 'Минимальный размер выборки'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/zh.ts b/webapp/packages/plugin-data-viewer/src/locales/zh.ts index d9cfbffd29..d5bf26d577 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -50,7 +50,7 @@ export default [ ['data_viewer_model_not_loaded', 'Table model is not loaded'], ['settings_data_editor', 'Data Editor'], ['settings_data_editor_disable_edit_name', 'Disable Edit'], - ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer'], + ['settings_data_editor_disable_edit_description', 'Disable editing of data in Data Viewer for non-admin users'], ['settings_data_editor_disable_data_copy_name', 'Disable Copy'], ['settings_data_editor_disable_data_copy_description', 'Disable copying of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimum fetch size'], From 680bf926b4579e6001aa5dc485705017f6ba46ae Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 21 Feb 2024 16:03:18 +0100 Subject: [PATCH 4/4] CB-4700 change if logic --- .../plugin-data-viewer/src/DataViewerService.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts index 98d125ab8d..c72a5278c4 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts @@ -27,13 +27,13 @@ export class DataViewerService { ) {} isDataEditable(connection: Connection) { + if (connection.readOnly) { + return false; + } + const isAdmin = this.sessionPermissionsResource.has(EAdminPermission.admin); const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit'); - if (disabled) { - return isAdmin; - } - - return !connection.readOnly; + return isAdmin || !disabled; } }