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-4700 allow administrators to copy data #2389

Merged
merged 11 commits into from
Feb 26, 2024
18 changes: 16 additions & 2 deletions webapp/packages/plugin-data-viewer/src/DataViewerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@
*/
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 isAdmin = this.sessionPermissionsResource.has(EAdminPermission.admin);
const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit');
return !disabled && !connection.readOnly;

if (disabled) {
return isAdmin;
}

return !connection.readOnly;
Wroud marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 1 addition & 1 deletion webapp/packages/plugin-data-viewer/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/plugin-data-viewer/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/plugin-data-viewer/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'Максимальный размер выборки'],
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/plugin-data-viewer/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Loading