Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4961 Control files downloading ability #2744

Merged
merged 13 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions webapp/packages/core-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@cloudbeaver/core-executor": "^0",
"@cloudbeaver/core-utils": "^0",
"axios": "^1",
"graphql": "^16",
"graphql-request": "^6",
"mobx": "^6"
},
Expand Down

This file was deleted.

20 changes: 5 additions & 15 deletions webapp/packages/plugin-data-export/src/DataExportMenuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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 {
Expand All @@ -20,24 +19,22 @@
DATA_CONTEXT_DV_PRESENTATION,
DATA_VIEWER_DATA_MODEL_ACTIONS_MENU,
DataViewerPresentationType,
DataViewerService,
IDatabaseDataSource,
IDataContainerOptions,
} 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,
) {}

register(): void {
Expand All @@ -46,7 +43,7 @@
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];
Expand All @@ -60,6 +57,7 @@
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.canExportData,

Check warning on line 60 in webapp/packages/plugin-data-export/src/DataExportMenuService.ts

View check run for this annotation

Jenkins-CI-integration / CheckStyle TypeScript Report

webapp/packages/plugin-data-export/src/DataExportMenuService.ts#L60

context is defined but never used. (@typescript-eslint/no-unused-vars)

Check warning on line 60 in webapp/packages/plugin-data-export/src/DataExportMenuService.ts

View check run for this annotation

Jenkins-CI-integration / CheckStyle TypeScript Report

webapp/packages/plugin-data-export/src/DataExportMenuService.ts#L60

action is defined but never used. (@typescript-eslint/no-unused-vars)
actions: [ACTION_EXPORT],
isDisabled(context) {
const model = context.get(DATA_CONTEXT_DV_DDM)!;
Expand Down Expand Up @@ -118,7 +116,7 @@
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],
});
Expand All @@ -141,12 +139,4 @@
},
});
}

private isExportDisabled() {
if (this.sessionPermissionsResource.has(EAdminPermission.admin)) {
return false;
}

return this.dataExportSettingsService.disabled;
}
}

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion webapp/packages/plugin-data-export/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -17,6 +23,7 @@ export class DataGridContextMenuSaveContentService {
constructor(
private readonly dataGridContextMenuService: DataGridContextMenuService,
private readonly notificationService: NotificationService,
private readonly dataViewerService: DataViewerService,
) {}

register(): void {
Expand All @@ -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.canExportData;
},
isDisabled: context => {
const content = context.data.model.source.getAction(context.data.resultIndex, ResultSetDataContentAction);
Expand Down
4 changes: 4 additions & 0 deletions webapp/packages/plugin-data-viewer/src/DataViewerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class DataViewerService {
return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableCopyData;
}

get canExportData() {
return this.sessionPermissionsResource.has(EAdminPermission.admin) || !this.dataViewerSettingsService.disableExportData;
}

constructor(
private readonly dataViewerSettingsService: DataViewerSettingsService,
private readonly sessionPermissionsResource: SessionPermissionsResource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const testValueNew = false;

const deprecatedSettings = {
'core.app.dataViewer.disableEdit': testValueDeprecated,
'plugin.data-export.disabled': testValueDeprecated,
};

const newSettings = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +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),
});

export type DataViewerSettings = schema.infer<typeof defaultSettings>;
Expand All @@ -45,6 +46,10 @@ export class DataViewerSettingsService extends Dependency {
return this.settings.getValue('plugin.data-viewer.disableCopyData');
}

get disableExportData(): boolean {
return this.settings.getValue('plugin.data-export.disabled');
}
Wroud marked this conversation as resolved.
Show resolved Hide resolved

get maxFetchSize(): number {
return this.settings.getValue('plugin.data-viewer.fetchMax');
}
Expand Down Expand Up @@ -147,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',
Wroud marked this conversation as resolved.
Show resolved Hide resolved
access: {
scope: ['server'],
},
},
];

if (!this.serverSettingsManagerService.providedSettings.has('resultset.maxrows')) {
Expand Down
Loading
Loading