From 50195ec8a6766540174d814e009df1e0d1cfb8fa Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Wed, 26 Jun 2024 17:00:56 +0200 Subject: [PATCH 01/10] CB-4961 adds "disable download" setting to data viewer --- .../src/DataExportMenuService.ts | 3 +++ .../plugin-data-viewer/src/DataViewerService.ts | 4 ++++ .../src/DataViewerSettingsService.ts | 16 ++++++++++++++++ .../ResultSet/ResultSetDataContentAction.ts | 4 +++- .../ImageValue/useValuePanelImageValue.ts | 6 ++++-- .../plugin-data-viewer/src/locales/de.ts | 2 ++ .../plugin-data-viewer/src/locales/en.ts | 2 ++ .../plugin-data-viewer/src/locales/fr.ts | 2 ++ .../plugin-data-viewer/src/locales/it.ts | 2 ++ .../plugin-data-viewer/src/locales/ru.ts | 2 ++ .../plugin-data-viewer/src/locales/zh.ts | 2 ++ 11 files changed, 42 insertions(+), 3 deletions(-) diff --git a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts index a488fb5c6e..d7a3759e2e 100644 --- a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts +++ b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts @@ -20,6 +20,7 @@ import { DATA_CONTEXT_DV_PRESENTATION, DATA_VIEWER_DATA_MODEL_ACTIONS_MENU, DataViewerPresentationType, + DataViewerService, IDatabaseDataSource, IDataContainerOptions, } from '@cloudbeaver/plugin-data-viewer'; @@ -38,6 +39,7 @@ export class DataExportMenuService { private readonly menuService: MenuService, private readonly sessionPermissionsResource: SessionPermissionsResource, private readonly localizationService: LocalizationService, + private readonly dataViewerService: DataViewerService, ) {} register(): void { @@ -60,6 +62,7 @@ export class DataExportMenuService { id: 'data-export-base-handler', menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU], contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX], + isHidden: (context, action) => !this.dataViewerService.canDownload, actions: [ACTION_EXPORT], isDisabled(context) { const model = context.get(DATA_CONTEXT_DV_DDM)!; diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts index 0a93eeb119..d7ea7ac9fd 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts @@ -17,6 +17,10 @@ export class DataViewerService { return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableCopyData; } + get canDownload() { + return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableDownload; + } + constructor( private readonly dataViewerSettingsService: DataViewerSettingsService, private readonly sessionPermissionsResource: SessionPermissionsResource, diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts index 89881ba7e6..d2757cf9a1 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts @@ -28,6 +28,7 @@ const DEFAULT_FETCH_SIZE = 200; const defaultSettings = schema.object({ 'plugin.data-viewer.disableEdit': schemaExtra.stringedBoolean().default(false), 'plugin.data-viewer.disableCopyData': schemaExtra.stringedBoolean().default(false), + 'plugin.data-viewer.disableDownload': schemaExtra.stringedBoolean().default(false), 'plugin.data-viewer.fetchMin': schema.coerce.number().min(FETCH_MIN).default(DEFAULT_FETCH_SIZE), 'plugin.data-viewer.fetchMax': schema.coerce.number().min(FETCH_MIN).default(FETCH_MAX), 'resultset.maxrows': schema.coerce.number().min(FETCH_MIN).max(FETCH_MAX).default(DEFAULT_FETCH_SIZE), @@ -45,6 +46,10 @@ export class DataViewerSettingsService extends Dependency { return this.settings.getValue('plugin.data-viewer.disableCopyData'); } + get disableDownload(): boolean { + return this.settings.getValue('plugin.data-viewer.disableDownload'); + } + get maxFetchSize(): number { return this.settings.getValue('plugin.data-viewer.fetchMax'); } @@ -73,6 +78,7 @@ export class DataViewerSettingsService extends Dependency { createSettingsAliasResolver(this.settingsResolverService, this.settings, { 'plugin.data-viewer.disableEdit': 'core.app.dataViewer.disableEdit', 'plugin.data-viewer.disableCopyData': 'core.app.dataViewer.disableCopyData', + 'plugin.data-viewer.disableDownload': 'core.app.dataViewer.disableDownload', 'plugin.data-viewer.fetchMin': 'core.app.dataViewer.fetchMin', 'plugin.data-viewer.fetchMax': 'core.app.dataViewer.fetchMax', 'resultset.maxrows': 'core.app.dataViewer.fetchDefault', @@ -127,6 +133,16 @@ export class DataViewerSettingsService extends Dependency { description: 'settings_data_editor_disable_data_copy_description', group: DATA_EDITOR_SETTINGS_GROUP, }, + { + key: 'plugin.data-viewer.disableDownload', + access: { + scope: ['server'], + }, + type: ESettingsValueType.Checkbox, + name: 'settings_data_editor_disable_data_download_name', + description: 'settings_data_editor_disable_data_download_description', + group: DATA_EDITOR_SETTINGS_GROUP, + }, { key: 'plugin.data-viewer.fetchMin', access: { diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts index 4d425571d8..15d4ca9b6f 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts @@ -11,6 +11,7 @@ import { QuotasService } from '@cloudbeaver/core-root'; import { GraphQLService, ResultDataFormat } from '@cloudbeaver/core-sdk'; import { bytesToSize, download, downloadFromURL, GlobalConstants, isNotNullDefined } from '@cloudbeaver/core-utils'; +import { DataViewerService } from '../../../DataViewerService'; import { DatabaseDataAction } from '../../DatabaseDataAction'; import type { IDatabaseDataSource } from '../../IDatabaseDataSource'; import type { IDatabaseResultSet } from '../../IDatabaseResultSet'; @@ -42,6 +43,7 @@ export class ResultSetDataContentAction extends DatabaseDataAction; @@ -32,6 +33,7 @@ interface Props { export function useValuePanelImageValue({ model, resultIndex }: Props) { const notificationService = useService(NotificationService); + const dataViewerService = useService(DataViewerService); const selectAction = model.source.getAction(resultIndex, ResultSetSelectAction); const formatAction = model.source.getAction(resultIndex, ResultSetFormatAction); const contentAction = model.source.getAction(resultIndex, ResultSetDataContentAction); @@ -92,7 +94,7 @@ export function useValuePanelImageValue({ model, resultIndex }: Props) { return this.contentAction.isDownloadable(this.selectedCell); } - return this.staticSrc && !this.truncated; + return this.staticSrc && !this.truncated && this.dataViewerService.canDownload; }, get canUpload() { if (!this.selectedCell) { @@ -158,6 +160,6 @@ export function useValuePanelImageValue({ model, resultIndex }: Props) { upload: action.bound, loadFullImage: action.bound, }, - { model, resultIndex, notificationService, selectAction, formatAction, contentAction, editAction }, + { model, resultIndex, notificationService, selectAction, formatAction, contentAction, editAction, dataViewerService }, ); } diff --git a/webapp/packages/plugin-data-viewer/src/locales/de.ts b/webapp/packages/plugin-data-viewer/src/locales/de.ts index 4815fcebe4..e55007425c 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/de.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/de.ts @@ -41,6 +41,8 @@ export default [ ['settings_data_editor_disable_edit_description', 'Deaktivieren Sie die Bearbeitung von Daten in Data Viewer für Nicht-Admin-Benutzer'], ['settings_data_editor_disable_data_copy_name', 'Kopie deaktivieren'], ['settings_data_editor_disable_data_copy_description', 'Deaktivieren Sie das Kopieren von Daten in Data Viewer für Nicht-Admin-Benutzer'], + ['settings_data_editor_disable_data_download_name', 'Disable Download'], + ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimale fetch size'], ['settings_data_editor_fetch_min_description', 'Mindestanzahl von Zeilen zum Abrufen'], ['settings_data_editor_fetch_max_name', 'Maximale fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index 0cdc7815a6..620756e124 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -64,6 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], + ['settings_data_editor_disable_data_download_description', 'Disable downloading 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/fr.ts b/webapp/packages/plugin-data-viewer/src/locales/fr.ts index 571d40f4bf..b4733ec499 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/fr.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/fr.ts @@ -62,6 +62,8 @@ export default [ ['settings_data_editor_disable_edit_name', "Désactiver l'édition"], ['settings_data_editor_disable_edit_description', "Désactiver l'édition des données dans le Data Viewer pour les utilisateurs non administrateurs"], ['settings_data_editor_disable_data_copy_name', 'Désactiver la copie'], + ['settings_data_editor_disable_data_download_name', 'Disable Download'], + ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], [ 'settings_data_editor_disable_data_copy_description', 'Désactiver la copie des données dans le Data Viewer pour les utilisateurs non administrateurs', diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index 47ba104bf3..94136f244b 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -57,6 +57,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], + ['settings_data_editor_disable_data_download_description', 'Disable downloading 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 8aa7cad446..e30cf6fbad 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -58,6 +58,8 @@ export default [ ['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_download_name', 'Отключить скачивание данных'], + ['settings_data_editor_disable_data_download_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 3e81a500b5..9783e8ae69 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -64,6 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], + ['settings_data_editor_disable_data_download_description', 'Disable downloading 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 4fa116e18beead7e052ddfc7d6f79e294cabe10e Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 27 Jun 2024 11:20:39 +0200 Subject: [PATCH 02/10] CB-4691 removes unneeded alias for new disable download setting --- .../packages/plugin-data-viewer/src/DataViewerSettingsService.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts index d2757cf9a1..6c3add48d0 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts @@ -78,7 +78,6 @@ export class DataViewerSettingsService extends Dependency { createSettingsAliasResolver(this.settingsResolverService, this.settings, { 'plugin.data-viewer.disableEdit': 'core.app.dataViewer.disableEdit', 'plugin.data-viewer.disableCopyData': 'core.app.dataViewer.disableCopyData', - 'plugin.data-viewer.disableDownload': 'core.app.dataViewer.disableDownload', 'plugin.data-viewer.fetchMin': 'core.app.dataViewer.fetchMin', 'plugin.data-viewer.fetchMax': 'core.app.dataViewer.fetchMax', 'resultset.maxrows': 'core.app.dataViewer.fetchDefault', From 973626e063dbd82178c4a1f9c0f8b7855f228312 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 27 Jun 2024 21:09:33 +0200 Subject: [PATCH 03/10] CB-4691 pr fixes --- .../DataGridContextMenuSaveContentService.ts | 12 ++++++++++-- .../Actions/ResultSet/ResultSetDataContentAction.ts | 4 +--- .../ImageValue/ImageValuePresentation.tsx | 5 ++--- .../ImageValue/useValuePanelImageValue.ts | 6 +++++- .../TextValue/TextValuePresentation.tsx | 4 +++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts index f0296277a1..6df770a12e 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts @@ -8,7 +8,13 @@ import { selectFiles } from '@cloudbeaver/core-browser'; import { injectable } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; -import { createResultSetBlobValue, ResultSetDataContentAction, ResultSetEditAction, ResultSetFormatAction } from '@cloudbeaver/plugin-data-viewer'; +import { + createResultSetBlobValue, + DataViewerService, + ResultSetDataContentAction, + ResultSetEditAction, + ResultSetFormatAction, +} from '@cloudbeaver/plugin-data-viewer'; import { DataGridContextMenuService } from './DataGridContextMenuService'; @@ -17,6 +23,7 @@ export class DataGridContextMenuSaveContentService { constructor( private readonly dataGridContextMenuService: DataGridContextMenuService, private readonly notificationService: NotificationService, + private readonly dataViewerService: DataViewerService, ) {} register(): void { @@ -38,7 +45,8 @@ export class DataGridContextMenuSaveContentService { }, isHidden: context => { const content = context.data.model.source.getAction(context.data.resultIndex, ResultSetDataContentAction); - return !content.isDownloadable(context.data.key); + + return !content.isDownloadable(context.data.key) || !this.dataViewerService.canDownload; }, isDisabled: context => { const content = context.data.model.source.getAction(context.data.resultIndex, ResultSetDataContentAction); diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts index 15d4ca9b6f..4d425571d8 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts @@ -11,7 +11,6 @@ import { QuotasService } from '@cloudbeaver/core-root'; import { GraphQLService, ResultDataFormat } from '@cloudbeaver/core-sdk'; import { bytesToSize, download, downloadFromURL, GlobalConstants, isNotNullDefined } from '@cloudbeaver/core-utils'; -import { DataViewerService } from '../../../DataViewerService'; import { DatabaseDataAction } from '../../DatabaseDataAction'; import type { IDatabaseDataSource } from '../../IDatabaseDataSource'; import type { IDatabaseResultSet } from '../../IDatabaseResultSet'; @@ -43,7 +42,6 @@ export class ResultSetDataContentAction extends DatabaseDataAction throttle(() => data.download(), 1000, false), []); const srcGetter = suspense.observedValue( 'src', @@ -64,7 +63,7 @@ export const ImageValuePresentation: TabContainerPanelComponent} {isTruncatedMessageDisplay && ( - {isDownloadable && ( + {data.canSave && ( diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts index c9179bc6ea..ba9942b705 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts @@ -90,11 +90,15 @@ export function useValuePanelImageValue({ model, resultIndex }: Props) { return this.contentAction.retrieveBlobFromCache(this.selectedCell); }, get canSave() { + if (!this.dataViewerService.canDownload) { + return false; + } + if (this.truncated && this.selectedCell) { return this.contentAction.isDownloadable(this.selectedCell); } - return this.staticSrc && !this.truncated && this.dataViewerService.canDownload; + return this.staticSrc && !this.truncated; }, get canUpload() { if (!this.selectedCell) { diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx index 8ee7861d22..663f546eb0 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx @@ -18,6 +18,7 @@ import { ResultSetEditAction } from '../../DatabaseDataModel/Actions/ResultSet/R import { ResultSetFormatAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction'; import { ResultSetSelectAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetSelectAction'; import type { IDatabaseResultSet } from '../../DatabaseDataModel/IDatabaseResultSet'; +import { DataViewerService } from '../../DataViewerService'; import type { IDataValuePanelProps } from '../../TableViewer/ValuePanel/DataValuePanelService'; import { getDefaultLineWrapping } from './getDefaultLineWrapping'; import { isTextValueReadonly } from './isTextValueReadonly'; @@ -36,6 +37,7 @@ export const TextValuePresentation: TabContainerPanelComponent Date: Thu, 27 Jun 2024 21:14:29 +0200 Subject: [PATCH 04/10] CB-4961 reverts image value presentation canSave logic --- .../ImageValue/ImageValuePresentation.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx index 725091879a..e32b393f31 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx @@ -43,7 +43,8 @@ export const ImageValuePresentation: TabContainerPanelComponent throttle(() => data.download(), 1000, false), []); const srcGetter = suspense.observedValue( 'src', @@ -63,7 +64,7 @@ export const ImageValuePresentation: TabContainerPanelComponent} {isTruncatedMessageDisplay && ( - {data.canSave && ( + {isDownloadable && ( From ceb4eee0367d84882293ae2820b9f349ee9f8009 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 27 Jun 2024 21:25:25 +0200 Subject: [PATCH 05/10] CB-4961 disables download from image context menu --- .../ImageValue/ImageValuePresentation.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx index e32b393f31..4a669ed484 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx @@ -57,11 +57,23 @@ export const ImageValuePresentation: TabContainerPanelComponent) { + if (!data.canSave) { + event.preventDefault(); + } + } + return ( - {data.src && } + {data.src && ( + + )} {isTruncatedMessageDisplay && ( {isDownloadable && ( @@ -99,14 +111,15 @@ export const ImageValuePresentation: TabContainerPanelComponent string | null; + onContextMenu?: (event: React.MouseEvent) => void; } -export const ImageRenderer = observer(function ImageRenderer({ srcGetter, className }) { +export const ImageRenderer = observer(function ImageRenderer({ srcGetter, className, onContextMenu }) { const src = srcGetter(); if (!src) { return null; } - return ; + return ; }); From ff5ba3975ced667df68f150ed4aa7f9e365ca30e Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Fri, 28 Jun 2024 08:51:24 +0200 Subject: [PATCH 06/10] CB-4691 fixes unit tests --- .../plugin-data-export/src/DataExportSettingsService.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts b/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts index b8bbf3fcfb..0dc75efae3 100644 --- a/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts +++ b/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts @@ -35,6 +35,7 @@ import { import { coreStorageManifest } from '@cloudbeaver/core-storage'; import { coreUIManifest } from '@cloudbeaver/core-ui'; import { coreViewManifest } from '@cloudbeaver/core-view'; +import { dataViewerManifest } from '@cloudbeaver/plugin-data-viewer'; import { datasourceContextSwitchPluginManifest } from '@cloudbeaver/plugin-datasource-context-switch'; import { navigationTabsPlugin } from '@cloudbeaver/plugin-navigation-tabs'; import { navigationTreePlugin } from '@cloudbeaver/plugin-navigation-tree'; @@ -60,6 +61,7 @@ const app = createApp( coreProjectsManifest, coreUIManifest, coreRoutingManifest, + dataViewerManifest, coreAdministrationManifest, coreConnectionsManifest, coreDialogsManifest, From 5d63d1bbf7b686996ddf056cc56ebe9bb77d27ab Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Fri, 28 Jun 2024 12:57:02 +0200 Subject: [PATCH 07/10] CB-4691 change new setting to existing one --- webapp/packages/core-blocks/package.json | 3 + webapp/packages/core-blocks/tsconfig.json | 9 ++ webapp/packages/core-sdk/package.json | 1 + .../src/DATA_EXPORT_SETTINGS_GROUP.ts | 10 -- .../src/DataExportMenuService.ts | 19 +-- .../src/DataExportSettingsService.test.ts | 111 ------------------ .../src/DataExportSettingsService.ts | 58 --------- .../plugin-data-export/src/manifest.ts | 1 - .../DataGridContextMenuSaveContentService.ts | 2 +- .../src/DataViewerService.ts | 4 +- .../src/DataViewerSettingsService.test.ts | 1 + .../src/DataViewerSettingsService.ts | 26 ++-- .../ImageValue/useValuePanelImageValue.ts | 2 +- .../TextValue/TextValuePresentation.tsx | 2 +- 14 files changed, 35 insertions(+), 214 deletions(-) delete mode 100644 webapp/packages/plugin-data-export/src/DATA_EXPORT_SETTINGS_GROUP.ts delete mode 100644 webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts delete mode 100644 webapp/packages/plugin-data-export/src/DataExportSettingsService.ts diff --git a/webapp/packages/core-blocks/package.json b/webapp/packages/core-blocks/package.json index 3e25f782eb..d4e20c0be9 100644 --- a/webapp/packages/core-blocks/package.json +++ b/webapp/packages/core-blocks/package.json @@ -39,10 +39,13 @@ }, "peerDependencies": {}, "devDependencies": { + "@cloudbeaver/core-di": "^0", + "@cloudbeaver/core-dialogs": "^0", "@cloudbeaver/core-events": "^0", "@cloudbeaver/core-localization": "^0", "@cloudbeaver/core-settings": "^0", "@cloudbeaver/core-theming": "^0", + "@cloudbeaver/core-utils": "^0", "@cloudbeaver/tests-runner": "^0", "@testing-library/jest-dom": "^6", "@testing-library/react": "^16", diff --git a/webapp/packages/core-blocks/tsconfig.json b/webapp/packages/core-blocks/tsconfig.json index 49f13e45ee..034f1a392b 100644 --- a/webapp/packages/core-blocks/tsconfig.json +++ b/webapp/packages/core-blocks/tsconfig.json @@ -12,6 +12,12 @@ { "path": "../core-di/tsconfig.json" }, + { + "path": "../core-di/tsconfig.json" + }, + { + "path": "../core-dialogs/tsconfig.json" + }, { "path": "../core-dialogs/tsconfig.json" }, @@ -51,6 +57,9 @@ { "path": "../core-utils/tsconfig.json" }, + { + "path": "../core-utils/tsconfig.json" + }, { "path": "../tests-runner/tsconfig.json" } diff --git a/webapp/packages/core-sdk/package.json b/webapp/packages/core-sdk/package.json index a2e8b435b8..529d724252 100644 --- a/webapp/packages/core-sdk/package.json +++ b/webapp/packages/core-sdk/package.json @@ -25,6 +25,7 @@ "@cloudbeaver/core-executor": "^0", "@cloudbeaver/core-utils": "^0", "axios": "^1", + "graphql": "^16", "graphql-request": "^6", "mobx": "^6" }, diff --git a/webapp/packages/plugin-data-export/src/DATA_EXPORT_SETTINGS_GROUP.ts b/webapp/packages/plugin-data-export/src/DATA_EXPORT_SETTINGS_GROUP.ts deleted file mode 100644 index 991978c9df..0000000000 --- a/webapp/packages/plugin-data-export/src/DATA_EXPORT_SETTINGS_GROUP.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0. - * you may not use this file except in compliance with the License. - */ -import { ROOT_SETTINGS_GROUP } from '@cloudbeaver/core-settings'; - -export const DATA_EXPORT_SETTINGS_GROUP = ROOT_SETTINGS_GROUP.createSubGroup('plugin_data_export_data_export_settings_group'); diff --git a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts index d7a3759e2e..f42885a63b 100644 --- a/webapp/packages/plugin-data-export/src/DataExportMenuService.ts +++ b/webapp/packages/plugin-data-export/src/DataExportMenuService.ts @@ -11,7 +11,6 @@ import { injectable } from '@cloudbeaver/core-di'; import { CommonDialogService } from '@cloudbeaver/core-dialogs'; import { LocalizationService } from '@cloudbeaver/core-localization'; import { DATA_CONTEXT_NAV_NODE, EObjectFeature } from '@cloudbeaver/core-navigation-tree'; -import { EAdminPermission, SessionPermissionsResource } from '@cloudbeaver/core-root'; import { withTimestamp } from '@cloudbeaver/core-utils'; import { ACTION_EXPORT, ActionService, menuExtractItems, MenuService } from '@cloudbeaver/core-view'; import { @@ -26,18 +25,14 @@ import { } from '@cloudbeaver/plugin-data-viewer'; import type { IDataQueryOptions } from '@cloudbeaver/plugin-sql-editor'; -import { DataExportSettingsService } from './DataExportSettingsService'; - const DataExportDialog = importLazyComponent(() => import('./Dialog/DataExportDialog').then(module => module.DataExportDialog)); @injectable() export class DataExportMenuService { constructor( private readonly commonDialogService: CommonDialogService, - private readonly dataExportSettingsService: DataExportSettingsService, private readonly actionService: ActionService, private readonly menuService: MenuService, - private readonly sessionPermissionsResource: SessionPermissionsResource, private readonly localizationService: LocalizationService, private readonly dataViewerService: DataViewerService, ) {} @@ -48,7 +43,7 @@ export class DataExportMenuService { contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX], isApplicable: context => { const presentation = context.get(DATA_CONTEXT_DV_PRESENTATION); - return !this.isExportDisabled() && (!presentation || presentation.type === DataViewerPresentationType.Data); + return this.dataViewerService.canExportData && (!presentation || presentation.type === DataViewerPresentationType.Data); }, getItems(context, items) { return [...items, ACTION_EXPORT]; @@ -62,7 +57,7 @@ export class DataExportMenuService { id: 'data-export-base-handler', menus: [DATA_VIEWER_DATA_MODEL_ACTIONS_MENU], contexts: [DATA_CONTEXT_DV_DDM, DATA_CONTEXT_DV_DDM_RESULT_INDEX], - isHidden: (context, action) => !this.dataViewerService.canDownload, + isHidden: (context, action) => !this.dataViewerService.canExportData, actions: [ACTION_EXPORT], isDisabled(context) { const model = context.get(DATA_CONTEXT_DV_DDM)!; @@ -121,7 +116,7 @@ export class DataExportMenuService { return false; } - return !this.isExportDisabled() && context.has(DATA_CONTEXT_CONNECTION); + return this.dataViewerService.canExportData && context.has(DATA_CONTEXT_CONNECTION); }, getItems: (context, items) => [...items, ACTION_EXPORT], }); @@ -144,12 +139,4 @@ export class DataExportMenuService { }, }); } - - private isExportDisabled() { - if (this.sessionPermissionsResource.has(EAdminPermission.admin)) { - return false; - } - - return this.dataExportSettingsService.disabled; - } } diff --git a/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts b/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts deleted file mode 100644 index 0dc75efae3..0000000000 --- a/webapp/packages/plugin-data-export/src/DataExportSettingsService.test.ts +++ /dev/null @@ -1,111 +0,0 @@ -/* - * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0. - * you may not use this file except in compliance with the License. - */ -import '@testing-library/jest-dom'; - -import { coreAdministrationManifest } from '@cloudbeaver/core-administration'; -import { coreAppManifest } from '@cloudbeaver/core-app'; -import { coreAuthenticationManifest } from '@cloudbeaver/core-authentication'; -import { mockAuthentication } from '@cloudbeaver/core-authentication/dist/__custom_mocks__/mockAuthentication'; -import { coreBrowserManifest } from '@cloudbeaver/core-browser'; -import { coreClientActivityManifest } from '@cloudbeaver/core-client-activity'; -import { coreConnectionsManifest } from '@cloudbeaver/core-connections'; -import { coreDialogsManifest } from '@cloudbeaver/core-dialogs'; -import { coreEventsManifest } from '@cloudbeaver/core-events'; -import { coreLocalizationManifest } from '@cloudbeaver/core-localization'; -import { coreNavigationTree } from '@cloudbeaver/core-navigation-tree'; -import { coreProjectsManifest } from '@cloudbeaver/core-projects'; -import { coreRootManifest, ServerConfigResource } from '@cloudbeaver/core-root'; -import { createGQLEndpoint } from '@cloudbeaver/core-root/dist/__custom_mocks__/createGQLEndpoint'; -import '@cloudbeaver/core-root/dist/__custom_mocks__/expectWebsocketClosedMessage'; -import { mockAppInit } from '@cloudbeaver/core-root/dist/__custom_mocks__/mockAppInit'; -import { mockGraphQL } from '@cloudbeaver/core-root/dist/__custom_mocks__/mockGraphQL'; -import { mockServerConfig } from '@cloudbeaver/core-root/dist/__custom_mocks__/resolvers/mockServerConfig'; -import { coreRoutingManifest } from '@cloudbeaver/core-routing'; -import { coreSDKManifest } from '@cloudbeaver/core-sdk'; -import { coreSettingsManifest } from '@cloudbeaver/core-settings'; -import { - expectDeprecatedSettingMessage, - expectNoDeprecatedSettingMessage, -} from '@cloudbeaver/core-settings/dist/__custom_mocks__/expectDeprecatedSettingMessage'; -import { coreStorageManifest } from '@cloudbeaver/core-storage'; -import { coreUIManifest } from '@cloudbeaver/core-ui'; -import { coreViewManifest } from '@cloudbeaver/core-view'; -import { dataViewerManifest } from '@cloudbeaver/plugin-data-viewer'; -import { datasourceContextSwitchPluginManifest } from '@cloudbeaver/plugin-datasource-context-switch'; -import { navigationTabsPlugin } from '@cloudbeaver/plugin-navigation-tabs'; -import { navigationTreePlugin } from '@cloudbeaver/plugin-navigation-tree'; -import { objectViewerManifest } from '@cloudbeaver/plugin-object-viewer'; -import { createApp } from '@cloudbeaver/tests-runner'; - -import { DataExportSettingsService } from './DataExportSettingsService'; -import { dataExportManifest } from './manifest'; - -const endpoint = createGQLEndpoint(); -const server = mockGraphQL(...mockAppInit(endpoint), ...mockAuthentication(endpoint)); -const app = createApp( - dataExportManifest, - coreLocalizationManifest, - coreEventsManifest, - coreRootManifest, - coreSDKManifest, - coreBrowserManifest, - coreSettingsManifest, - coreStorageManifest, - coreViewManifest, - coreAuthenticationManifest, - coreProjectsManifest, - coreUIManifest, - coreRoutingManifest, - dataViewerManifest, - coreAdministrationManifest, - coreConnectionsManifest, - coreDialogsManifest, - coreNavigationTree, - coreAppManifest, - datasourceContextSwitchPluginManifest, - navigationTreePlugin, - navigationTabsPlugin, - objectViewerManifest, - coreClientActivityManifest, -); - -const testValueA = true; -const testValueB = true; - -const deprecatedSettings = { - 'plugin_data_export.disabled': testValueB, -}; - -const newSettings = { - ...deprecatedSettings, - 'plugin.data-export.disabled': testValueA, -}; - -test('New settings override deprecated', async () => { - const settings = app.injector.getServiceByClass(DataExportSettingsService); - const config = app.injector.getServiceByClass(ServerConfigResource); - - server.use(endpoint.query('serverConfig', mockServerConfig(newSettings))); - - await config.refresh(); - - expect(settings.disabled).toBe(testValueA); - expectNoDeprecatedSettingMessage(); -}); - -test('Deprecated settings are used if new settings are not defined', async () => { - const settings = app.injector.getServiceByClass(DataExportSettingsService); - const config = app.injector.getServiceByClass(ServerConfigResource); - - server.use(endpoint.query('serverConfig', mockServerConfig(deprecatedSettings))); - - await config.refresh(); - - expect(settings.disabled).toBe(testValueB); - expectDeprecatedSettingMessage(); -}); diff --git a/webapp/packages/plugin-data-export/src/DataExportSettingsService.ts b/webapp/packages/plugin-data-export/src/DataExportSettingsService.ts deleted file mode 100644 index 5210503545..0000000000 --- a/webapp/packages/plugin-data-export/src/DataExportSettingsService.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0. - * you may not use this file except in compliance with the License. - */ -import { Dependency, injectable } from '@cloudbeaver/core-di'; -import { - createSettingsAliasResolver, - ROOT_SETTINGS_LAYER, - SettingsManagerService, - SettingsProvider, - SettingsProviderService, - SettingsResolverService, -} from '@cloudbeaver/core-settings'; -import { schema, schemaExtra } from '@cloudbeaver/core-utils'; - -const defaultSettings = schema.object({ - 'plugin.data-export.disabled': schemaExtra.stringedBoolean().default(false), -}); - -export type DataExportSettings = schema.infer; - -@injectable() -export class DataExportSettingsService extends Dependency { - get disabled(): boolean { - return this.settings.getValue('plugin.data-export.disabled'); - } - readonly settings: SettingsProvider; - - constructor( - private readonly settingsProviderService: SettingsProviderService, - private readonly settingsManagerService: SettingsManagerService, - private readonly settingsResolverService: SettingsResolverService, - ) { - super(); - this.settings = this.settingsProviderService.createSettings(defaultSettings); - this.settingsResolverService.addResolver( - ROOT_SETTINGS_LAYER, - /** @deprecated Use settings instead, will be removed in 23.0.0 */ - createSettingsAliasResolver(this.settingsResolverService, this.settings, { 'plugin.data-export.disabled': 'plugin_data_export.disabled' }), - ); - - this.registerSettings(); - } - - private registerSettings() { - this.settingsManagerService.registerSettings(this.settings, () => [ - // { - // group: DATA_EXPORT_SETTINGS_GROUP, - // key: 'disabled', - // type: ESettingsValueType.Checkbox, - // name: 'Disable data export', - // }, - ]); - } -} diff --git a/webapp/packages/plugin-data-export/src/manifest.ts b/webapp/packages/plugin-data-export/src/manifest.ts index 2c58f37f4f..c2a8e77884 100644 --- a/webapp/packages/plugin-data-export/src/manifest.ts +++ b/webapp/packages/plugin-data-export/src/manifest.ts @@ -15,7 +15,6 @@ export const dataExportManifest: PluginManifest = { providers: [ () => import('./Bootstrap').then(m => m.Bootstrap), () => import('./DataExportMenuService').then(m => m.DataExportMenuService), - () => import('./DataExportSettingsService').then(m => m.DataExportSettingsService), () => import('./DataExportService').then(m => m.DataExportService), () => import('./DataExportProcessService').then(m => m.DataExportProcessService), () => import('./DataTransferProcessorsResource').then(m => m.DataTransferProcessorsResource), diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts index 6df770a12e..70b61d8a7b 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.ts @@ -46,7 +46,7 @@ export class DataGridContextMenuSaveContentService { isHidden: context => { const content = context.data.model.source.getAction(context.data.resultIndex, ResultSetDataContentAction); - return !content.isDownloadable(context.data.key) || !this.dataViewerService.canDownload; + return !content.isDownloadable(context.data.key) || !this.dataViewerService.canExportData; }, isDisabled: context => { const content = context.data.model.source.getAction(context.data.resultIndex, ResultSetDataContentAction); diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts index d7ea7ac9fd..03f96962e3 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerService.ts @@ -17,8 +17,8 @@ export class DataViewerService { return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableCopyData; } - get canDownload() { - return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableDownload; + get canExportData() { + return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableExportData; } constructor( diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts index e93a0de0cc..29691df910 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts @@ -77,6 +77,7 @@ const testValueNew = false; const deprecatedSettings = { 'core.app.dataViewer.disableEdit': testValueDeprecated, + 'plugin.data-export.disabled': testValueDeprecated, }; const newSettings = { diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts index 6c3add48d0..cc14515d8a 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts @@ -28,10 +28,10 @@ const DEFAULT_FETCH_SIZE = 200; const defaultSettings = schema.object({ 'plugin.data-viewer.disableEdit': schemaExtra.stringedBoolean().default(false), 'plugin.data-viewer.disableCopyData': schemaExtra.stringedBoolean().default(false), - 'plugin.data-viewer.disableDownload': schemaExtra.stringedBoolean().default(false), 'plugin.data-viewer.fetchMin': schema.coerce.number().min(FETCH_MIN).default(DEFAULT_FETCH_SIZE), 'plugin.data-viewer.fetchMax': schema.coerce.number().min(FETCH_MIN).default(FETCH_MAX), 'resultset.maxrows': schema.coerce.number().min(FETCH_MIN).max(FETCH_MAX).default(DEFAULT_FETCH_SIZE), + 'plugin.data-export.disabled': schemaExtra.stringedBoolean().default(false), }); export type DataViewerSettings = schema.infer; @@ -46,8 +46,8 @@ export class DataViewerSettingsService extends Dependency { return this.settings.getValue('plugin.data-viewer.disableCopyData'); } - get disableDownload(): boolean { - return this.settings.getValue('plugin.data-viewer.disableDownload'); + get disableExportData(): boolean { + return this.settings.getValue('plugin.data-export.disabled'); } get maxFetchSize(): number { @@ -132,16 +132,6 @@ export class DataViewerSettingsService extends Dependency { description: 'settings_data_editor_disable_data_copy_description', group: DATA_EDITOR_SETTINGS_GROUP, }, - { - key: 'plugin.data-viewer.disableDownload', - access: { - scope: ['server'], - }, - type: ESettingsValueType.Checkbox, - name: 'settings_data_editor_disable_data_download_name', - description: 'settings_data_editor_disable_data_download_description', - group: DATA_EDITOR_SETTINGS_GROUP, - }, { key: 'plugin.data-viewer.fetchMin', access: { @@ -162,6 +152,16 @@ export class DataViewerSettingsService extends Dependency { description: 'settings_data_editor_fetch_max_description', group: DATA_EDITOR_SETTINGS_GROUP, }, + { + group: DATA_EDITOR_SETTINGS_GROUP, + key: 'plugin.data-export.disabled', + type: ESettingsValueType.Checkbox, + name: 'settings_data_editor_disable_data_download_name', + description: 'settings_data_editor_disable_data_download_description', + access: { + scope: ['server'], + }, + }, ]; if (!this.serverSettingsManagerService.providedSettings.has('resultset.maxrows')) { diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts index ba9942b705..1990675532 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/useValuePanelImageValue.ts @@ -90,7 +90,7 @@ export function useValuePanelImageValue({ model, resultIndex }: Props) { return this.contentAction.retrieveBlobFromCache(this.selectedCell); }, get canSave() { - if (!this.dataViewerService.canDownload) { + if (!this.dataViewerService.canExportData) { return false; } diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx index 663f546eb0..7cbe46a391 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx @@ -78,7 +78,7 @@ export const TextValuePresentation: TabContainerPanelComponent Date: Mon, 1 Jul 2024 13:44:08 +0200 Subject: [PATCH 08/10] CB-4691 renames disable download -> disable export --- webapp/packages/plugin-data-viewer/src/locales/de.ts | 4 ++-- webapp/packages/plugin-data-viewer/src/locales/en.ts | 4 ++-- webapp/packages/plugin-data-viewer/src/locales/fr.ts | 4 ++-- webapp/packages/plugin-data-viewer/src/locales/it.ts | 4 ++-- webapp/packages/plugin-data-viewer/src/locales/zh.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/locales/de.ts b/webapp/packages/plugin-data-viewer/src/locales/de.ts index e55007425c..a8c2a179e3 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/de.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/de.ts @@ -41,8 +41,8 @@ export default [ ['settings_data_editor_disable_edit_description', 'Deaktivieren Sie die Bearbeitung von Daten in Data Viewer für Nicht-Admin-Benutzer'], ['settings_data_editor_disable_data_copy_name', 'Kopie deaktivieren'], ['settings_data_editor_disable_data_copy_description', 'Deaktivieren Sie das Kopieren von Daten in Data Viewer für Nicht-Admin-Benutzer'], - ['settings_data_editor_disable_data_download_name', 'Disable Download'], - ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_download_name', 'Disable Export'], + ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimale fetch size'], ['settings_data_editor_fetch_min_description', 'Mindestanzahl von Zeilen zum Abrufen'], ['settings_data_editor_fetch_max_name', 'Maximale fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index 620756e124..cd20a7e5d6 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -64,8 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], - ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_download_name', 'Disable Export'], + ['settings_data_editor_disable_data_download_description', 'Disable exporting 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/fr.ts b/webapp/packages/plugin-data-viewer/src/locales/fr.ts index b4733ec499..01c4e7a129 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/fr.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/fr.ts @@ -62,8 +62,8 @@ export default [ ['settings_data_editor_disable_edit_name', "Désactiver l'édition"], ['settings_data_editor_disable_edit_description', "Désactiver l'édition des données dans le Data Viewer pour les utilisateurs non administrateurs"], ['settings_data_editor_disable_data_copy_name', 'Désactiver la copie'], - ['settings_data_editor_disable_data_download_name', 'Disable Download'], - ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_download_name', 'Disable Export'], + ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], [ 'settings_data_editor_disable_data_copy_description', 'Désactiver la copie des données dans le Data Viewer pour les utilisateurs non administrateurs', diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index 94136f244b..45d1fec78b 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -57,8 +57,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], - ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_download_name', 'Disable Export'], + ['settings_data_editor_disable_data_download_description', 'Disable exporting 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/zh.ts b/webapp/packages/plugin-data-viewer/src/locales/zh.ts index 9783e8ae69..51a5b9d1cf 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -64,8 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Download'], - ['settings_data_editor_disable_data_download_description', 'Disable downloading of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_download_name', 'Disable Export'], + ['settings_data_editor_disable_data_download_description', 'Disable exporting 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 0227482275838eb5f417d06804a76dbaa4a268c4 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 1 Jul 2024 16:40:41 +0200 Subject: [PATCH 09/10] CB-4691 pr fixes --- .../src/DataViewerSettingsService.ts | 15 ++++++++++----- .../ImageValue/ImageValuePresentation.tsx | 4 ++-- .../packages/plugin-data-viewer/src/locales/de.ts | 4 ++-- .../packages/plugin-data-viewer/src/locales/en.ts | 4 ++-- .../packages/plugin-data-viewer/src/locales/fr.ts | 4 ++-- .../packages/plugin-data-viewer/src/locales/it.ts | 4 ++-- .../packages/plugin-data-viewer/src/locales/ru.ts | 4 ++-- .../packages/plugin-data-viewer/src/locales/zh.ts | 4 ++-- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts index cc14515d8a..ecd33d456a 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.ts @@ -31,7 +31,7 @@ const defaultSettings = schema.object({ 'plugin.data-viewer.fetchMin': schema.coerce.number().min(FETCH_MIN).default(DEFAULT_FETCH_SIZE), 'plugin.data-viewer.fetchMax': schema.coerce.number().min(FETCH_MIN).default(FETCH_MAX), 'resultset.maxrows': schema.coerce.number().min(FETCH_MIN).max(FETCH_MAX).default(DEFAULT_FETCH_SIZE), - 'plugin.data-export.disabled': schemaExtra.stringedBoolean().default(false), + 'plugin.data-viewer.export.disabled': schemaExtra.stringedBoolean().default(false), }); export type DataViewerSettings = schema.infer; @@ -47,7 +47,7 @@ export class DataViewerSettingsService extends Dependency { } get disableExportData(): boolean { - return this.settings.getValue('plugin.data-export.disabled'); + return this.settings.getValue('plugin.data-viewer.export.disabled'); } get maxFetchSize(): number { @@ -80,12 +80,17 @@ export class DataViewerSettingsService extends Dependency { 'plugin.data-viewer.disableCopyData': 'core.app.dataViewer.disableCopyData', 'plugin.data-viewer.fetchMin': 'core.app.dataViewer.fetchMin', 'plugin.data-viewer.fetchMax': 'core.app.dataViewer.fetchMax', + 'plugin.data-viewer.export.disabled': 'plugin.data-export.disabled', 'resultset.maxrows': 'core.app.dataViewer.fetchDefault', }), /** @deprecated Use settings instead, will be removed in 25.0.0 */ createSettingsAliasResolver(this.settingsResolverService, this.settings, { 'resultset.maxrows': 'plugin.data-viewer.fetchDefault', }), + /** @deprecated Use settings instead, will be removed in 23.0.0 */ + createSettingsAliasResolver(this.settingsResolverService, this.settings, { + 'plugin.data-viewer.export.disabled': 'plugin_data_export.disabled', + }), ); this.registerSettings(); @@ -154,10 +159,10 @@ export class DataViewerSettingsService extends Dependency { }, { group: DATA_EDITOR_SETTINGS_GROUP, - key: 'plugin.data-export.disabled', + key: 'plugin.data-viewer.export.disabled', type: ESettingsValueType.Checkbox, - name: 'settings_data_editor_disable_data_download_name', - description: 'settings_data_editor_disable_data_download_description', + name: 'settings_data_editor_disable_data_export_name', + description: 'settings_data_editor_disable_data_export_description', access: { scope: ['server'], }, diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx index 4a669ed484..4e89471c42 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx @@ -57,7 +57,7 @@ export const ImageValuePresentation: TabContainerPanelComponent) { + function imageContextMenuHandler(event: React.MouseEvent) { if (!data.canSave) { event.preventDefault(); } @@ -71,7 +71,7 @@ export const ImageValuePresentation: TabContainerPanelComponent )} {isTruncatedMessageDisplay && ( diff --git a/webapp/packages/plugin-data-viewer/src/locales/de.ts b/webapp/packages/plugin-data-viewer/src/locales/de.ts index a8c2a179e3..f443d6cc3f 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/de.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/de.ts @@ -41,8 +41,8 @@ export default [ ['settings_data_editor_disable_edit_description', 'Deaktivieren Sie die Bearbeitung von Daten in Data Viewer für Nicht-Admin-Benutzer'], ['settings_data_editor_disable_data_copy_name', 'Kopie deaktivieren'], ['settings_data_editor_disable_data_copy_description', 'Deaktivieren Sie das Kopieren von Daten in Data Viewer für Nicht-Admin-Benutzer'], - ['settings_data_editor_disable_data_download_name', 'Disable Export'], - ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_export_name', 'Disable Export'], + ['settings_data_editor_disable_data_export_description', 'Disable exporting of data in Data Viewer for non-admin users'], ['settings_data_editor_fetch_min_name', 'Minimale fetch size'], ['settings_data_editor_fetch_min_description', 'Mindestanzahl von Zeilen zum Abrufen'], ['settings_data_editor_fetch_max_name', 'Maximale fetch size'], diff --git a/webapp/packages/plugin-data-viewer/src/locales/en.ts b/webapp/packages/plugin-data-viewer/src/locales/en.ts index cd20a7e5d6..9b0c003aa5 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/en.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/en.ts @@ -64,8 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Export'], - ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_export_name', 'Disable Export'], + ['settings_data_editor_disable_data_export_description', 'Disable exporting 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/fr.ts b/webapp/packages/plugin-data-viewer/src/locales/fr.ts index 01c4e7a129..6a6e6adce8 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/fr.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/fr.ts @@ -62,8 +62,8 @@ export default [ ['settings_data_editor_disable_edit_name', "Désactiver l'édition"], ['settings_data_editor_disable_edit_description', "Désactiver l'édition des données dans le Data Viewer pour les utilisateurs non administrateurs"], ['settings_data_editor_disable_data_copy_name', 'Désactiver la copie'], - ['settings_data_editor_disable_data_download_name', 'Disable Export'], - ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_export_name', 'Disable Export'], + ['settings_data_editor_disable_data_export_description', 'Disable exporting of data in Data Viewer for non-admin users'], [ 'settings_data_editor_disable_data_copy_description', 'Désactiver la copie des données dans le Data Viewer pour les utilisateurs non administrateurs', diff --git a/webapp/packages/plugin-data-viewer/src/locales/it.ts b/webapp/packages/plugin-data-viewer/src/locales/it.ts index 45d1fec78b..30a2185b31 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/it.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/it.ts @@ -57,8 +57,8 @@ export default [ ['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_disable_data_download_name', 'Disable Export'], - ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_export_name', 'Disable Export'], + ['settings_data_editor_disable_data_export_description', 'Disable exporting 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 e30cf6fbad..1738fcbf4d 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/ru.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/ru.ts @@ -58,8 +58,8 @@ export default [ ['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_download_name', 'Отключить скачивание данных'], - ['settings_data_editor_disable_data_download_description', 'Отключить скачивание данных для пользователей без прав администратора'], + ['settings_data_editor_disable_data_export_name', 'Отключить скачивание данных'], + ['settings_data_editor_disable_data_export_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 51a5b9d1cf..460c73036a 100644 --- a/webapp/packages/plugin-data-viewer/src/locales/zh.ts +++ b/webapp/packages/plugin-data-viewer/src/locales/zh.ts @@ -64,8 +64,8 @@ export default [ ['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_disable_data_download_name', 'Disable Export'], - ['settings_data_editor_disable_data_download_description', 'Disable exporting of data in Data Viewer for non-admin users'], + ['settings_data_editor_disable_data_export_name', 'Disable Export'], + ['settings_data_editor_disable_data_export_description', 'Disable exporting 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 a862388b295fd6fa7a7d22409fdef65918a37a22 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Mon, 1 Jul 2024 18:39:52 +0200 Subject: [PATCH 10/10] CB-4691 updates tests for new export setting --- .../src/DataViewerSettingsService.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts index 29691df910..6cefb37dd4 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerSettingsService.test.ts @@ -77,12 +77,14 @@ const testValueNew = false; const deprecatedSettings = { 'core.app.dataViewer.disableEdit': testValueDeprecated, - 'plugin.data-export.disabled': testValueDeprecated, + 'plugin.data-viewer.disabled': testValueDeprecated, + 'plugin_data_export.disabled': testValueDeprecated, }; const newSettings = { ...deprecatedSettings, 'plugin.data-viewer.disableEdit': testValueNew, + 'plugin.data-viewer.export.disabled': testValueNew, }; async function setupSettingsService(mockConfig: any = {}) { @@ -100,6 +102,8 @@ test('New settings override deprecated settings', async () => { const settingsService = await setupSettingsService(newSettings); expect(settingsService.disableEdit).toBe(testValueNew); + expect(settingsService.disableExportData).toBe(testValueNew); + expectNoDeprecatedSettingMessage(); }); @@ -107,6 +111,8 @@ test('Deprecated settings are used if new settings are not defined', async () => const settingsService = await setupSettingsService(deprecatedSettings); expect(settingsService.disableEdit).toBe(testValueDeprecated); + expect(settingsService.disableExportData).toBe(testValueDeprecated); + expectDeprecatedSettingMessage(); });