Skip to content

Commit

Permalink
CB-4124 add upload/download context actions
Browse files Browse the repository at this point in the history
  • Loading branch information
devnaumov committed Oct 25, 2023
1 parent 54f2811 commit fa7dfb1
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default [
['ui_close_all_to_the_left', 'Close all to the Left'],
['ui_or', 'Or'],
['ui_download', 'Download'],
['ui_download_file', 'Download file'],
['ui_upload', 'Upload'],
['ui_import', 'Import'],
['ui_view', 'View'],
Expand All @@ -103,6 +104,7 @@ export default [
['ui_upload_file', 'Upload file'],
['ui_upload_files', 'Upload files'],
['ui_upload_files_duplicate_error', 'Files with the same name already exist'],
['ui_upload_file_fail', 'Failed to upload file'],

['root_permission_denied', "You don't have permissions"],
['root_permission_no_permission', "You don't have permission for this action"],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default [
['ui_close_all_to_the_left', 'Close all to the Left'],
['ui_or', 'Or'],
['ui_download', 'Download'],
['ui_download_file', 'Download file'],
['ui_upload', 'Upload'],
['ui_import', 'Import'],
['ui_view', 'View'],
Expand All @@ -87,6 +88,7 @@ export default [
['ui_upload_file', 'Upload file'],
['ui_upload_files', 'Upload files'],
['ui_upload_files_duplicate_error', 'Files with the same name already exist'],
['ui_upload_file_fail', 'Failed to upload file'],

['root_permission_denied', 'Non hai i permessi'],
['app_root_session_expire_warning_title', 'La sessione sta per scadere'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default [
['ui_close_all_to_the_left', 'Закрыть все слева'],
['ui_or', 'Или'],
['ui_download', 'Cкачать'],
['ui_download_file', 'Скачать файл'],
['ui_upload', 'Загрузить'],
['ui_import', 'Импортировать'],
['ui_view', 'Смотреть'],
Expand All @@ -99,6 +100,7 @@ export default [
['ui_upload_file', 'Загрузить файл'],
['ui_upload_files', 'Загрузить файлы'],
['ui_upload_files_duplicate_error', 'Файлы с такими именами уже существуют'],
['ui_upload_file_fail', 'Не удалось загрузить файл'],

['root_permission_denied', 'Отказано в доступе'],
['root_permission_no_permission', 'У вас нет разрешения на это действие'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default [
['ui_close_all_to_the_left', 'Close all to the Left'],
['ui_or', 'Or'],
['ui_download', 'Download'],
['ui_download_file', 'Download file'],
['ui_upload', 'Upload'],
['ui_import', 'Import'],
['ui_view', 'View'],
Expand All @@ -100,6 +101,7 @@ export default [
['ui_upload_file', 'Upload file'],
['ui_upload_files', 'Upload files'],
['ui_upload_files_duplicate_error', 'Files with the same name already exist'],
['ui_upload_file_fail', 'Failed to upload file'],

['root_permission_denied', '您没有权限'],
['root_permission_no_permission', '您没有权限执行此操作'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2023 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 { GlobalConstants } from '@cloudbeaver/core-utils';

import type { CustomGraphQLClient, UploadProgressEvent } from '../CustomGraphQLClient';

export interface IUploadFileSystemEntityExtension {
uploadFileSystemEntity: (
parentURI: string,
projectId: string,
files: FileList,
onUploadProgress?: (event: UploadProgressEvent) => void,
) => Promise<void>;
}

export function uploadFileSystemEntityExtension(client: CustomGraphQLClient): IUploadFileSystemEntityExtension {
return {
uploadFileSystemEntity(
parentURI: string,
projectId: string,
files: FileList,
onUploadProgress?: (event: UploadProgressEvent) => void,
): Promise<void> {
return client.uploadFiles(GlobalConstants.absoluteServiceUrl('fs-data'), files, undefined, { parentURI, projectId }, onUploadProgress);
},
};
}
2 changes: 2 additions & 0 deletions webapp/packages/core-sdk/src/GraphQLService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CustomGraphQLClient } from './CustomGraphQLClient';
import { EnvironmentService } from './EnvironmentService';
import { uploadBlobResultSetExtension } from './Extensions/uploadBlobResultSetExtension';
import { uploadDriverLibraryExtension } from './Extensions/uploadDriverLibraryExtension';
import { uploadFileSystemEntityExtension } from './Extensions/uploadFileSystemEntityExtension';
import type { IResponseInterceptor } from './IResponseInterceptor';
import { getSdk } from './sdk';

Expand All @@ -21,6 +22,7 @@ function extendedSDK(client: CustomGraphQLClient) {
...sdk,
...uploadDriverLibraryExtension(client),
...uploadBlobResultSetExtension(client),
...uploadFileSystemEntityExtension(client),
};
}

Expand Down
13 changes: 13 additions & 0 deletions webapp/packages/core-view/src/Action/Actions/ACTION_DOWNLOAD.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2023 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 { createAction } from '../createAction';

export const ACTION_DOWNLOAD = createAction('download', {
label: 'ui_download',
icon: '/icons/export.svg',
});
13 changes: 13 additions & 0 deletions webapp/packages/core-view/src/Action/Actions/ACTION_UPLOAD.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2023 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 { createAction } from '../createAction';

export const ACTION_UPLOAD = createAction('upload', {
label: 'ui_upload',
icon: '/icons/import.svg',
});
2 changes: 2 additions & 0 deletions webapp/packages/core-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export * from './Action/Actions/ACTION_SETTINGS';
export * from './Action/Actions/ACTION_UNDO';
export * from './Action/Actions/ACTION_ZOOM_IN';
export * from './Action/Actions/ACTION_ZOOM_OUT';
export * from './Action/Actions/ACTION_DOWNLOAD';
export * from './Action/Actions/ACTION_UPLOAD';
export * from './Action/KeyBinding/Bindings/KEY_BINDING_OPEN_IN_TAB';
export * from './Action/KeyBinding/Bindings/KEY_BINDING_REDO';
export * from './Action/KeyBinding/Bindings/KEY_BINDING_UNDO';
Expand Down

0 comments on commit fa7dfb1

Please sign in to comment.