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) {
if (connection.readOnly) {
return false;
}

const isAdmin = this.sessionPermissionsResource.has(EAdminPermission.admin);
const disabled = this.dataViewerSettingsService.settings.getValue('disableEdit');
return !disabled && !connection.readOnly;

return isAdmin || !disabled;
}
}
4 changes: 2 additions & 2 deletions webapp/packages/plugin-data-viewer/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ 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'],
['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
4 changes: 2 additions & 2 deletions webapp/packages/plugin-data-viewer/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ 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'],
['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
4 changes: 2 additions & 2 deletions webapp/packages/plugin-data-viewer/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ 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_disable_data_copy_description', 'Отключить копирование данных для пользователей без прав администратора'],
['settings_data_editor_fetch_min_name', 'Минимальный размер выборки'],
['settings_data_editor_fetch_min_description', 'Минимальное количество строк для выборки'],
['settings_data_editor_fetch_max_name', 'Максимальный размер выборки'],
Expand Down
4 changes: 2 additions & 2 deletions webapp/packages/plugin-data-viewer/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ 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'],
['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