From 645fe9c56533faefb787d8b837f5be89bab1fb5a Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 23 Oct 2024 16:09:35 +0200 Subject: [PATCH 1/5] CB-5368 move context menu service --- .../DataGridContextMenuCellEditingService.ts | 41 ++++++++--------- .../DataGridContextMenuFilterService.ts | 46 +++++++++---------- .../DataGridContextMenuOrderService.ts | 25 +++++----- .../DataGridContextMenuSaveContentService.ts | 13 +++--- .../src/DataGrid/Formatters/Menu/CellMenu.tsx | 15 ++++-- .../src/SpreadsheetBootstrap.ts | 9 ++-- .../src/manifest.ts | 1 - .../src/DataViewerContextMenuService.ts} | 17 ++++--- .../packages/plugin-data-viewer/src/index.ts | 1 + .../plugin-data-viewer/src/manifest.ts | 1 + 10 files changed, 88 insertions(+), 81 deletions(-) rename webapp/packages/{plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts => plugin-data-viewer/src/DataViewerContextMenuService.ts} (75%) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts index 3a39b9bfd5..6cea084a23 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts @@ -8,6 +8,7 @@ import { injectable } from '@cloudbeaver/core-di'; import { DatabaseEditChangeType, + DataViewerContextMenuService, isBooleanValuePresentationAvailable, isResultSetDataSource, ResultSetDataContentAction, @@ -18,39 +19,37 @@ import { ResultSetViewAction, } from '@cloudbeaver/plugin-data-viewer'; -import { DataGridContextMenuService } from './DataGridContextMenuService.js'; - @injectable() export class DataGridContextMenuCellEditingService { private static readonly menuEditingToken = 'menuEditing'; - constructor(private readonly dataGridContextMenuService: DataGridContextMenuService) {} + constructor(private readonly dataViewerContextMenuService: DataViewerContextMenuService) {} getMenuEditingToken(): string { return DataGridContextMenuCellEditingService.menuEditingToken; } register(): void { - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: this.getMenuEditingToken(), order: 4, title: 'data_grid_table_editing', icon: 'edit', isPanel: true, isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext; + return context.contextType === DataViewerContextMenuService.cellContext; }, isHidden(context) { return context.data.model.isDisabled(context.data.resultIndex) || context.data.model.isReadonly(context.data.resultIndex); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'open_inline_editor', order: 0, title: 'data_grid_table_editing_open_inline_editor', icon: 'edit', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -72,12 +71,12 @@ export class DataGridContextMenuCellEditingService { context.data.spreadsheetActions.edit(context.data.key); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'set_to_null', order: 1, title: 'data_grid_table_editing_set_to_null', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const { key, model, resultIndex } = context.data; @@ -93,13 +92,13 @@ export class DataGridContextMenuCellEditingService { source.getAction(context.data.resultIndex, ResultSetEditAction).set(context.data.key, null); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_add', order: 5, icon: '/icons/data_add_sm.svg', title: 'data_grid_table_editing_row_add', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -112,13 +111,13 @@ export class DataGridContextMenuCellEditingService { editor.addRow(context.data.key.row); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_add_copy', order: 5.5, icon: '/icons/data_add_copy_sm.svg', title: 'data_grid_table_editing_row_add_copy', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -131,13 +130,13 @@ export class DataGridContextMenuCellEditingService { editor.duplicateRow(context.data.key.row); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_delete', order: 6, icon: '/icons/data_delete_sm.svg', title: 'data_grid_table_editing_row_delete', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -156,13 +155,13 @@ export class DataGridContextMenuCellEditingService { editor.deleteRow(context.data.key.row); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_delete_selected', order: 6.1, icon: '/icons/data_delete_sm.svg', title: 'data_viewer_action_edit_delete', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -188,13 +187,13 @@ export class DataGridContextMenuCellEditingService { editor.delete(...selectedElements); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_revert', order: 7, icon: '/icons/data_revert_sm.svg', title: 'data_grid_table_editing_row_revert', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -207,13 +206,13 @@ export class DataGridContextMenuCellEditingService { editor.revert(context.data.key); }, }); - this.dataGridContextMenuService.add(this.getMenuEditingToken(), { + this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { id: 'row_revert_selected', order: 7.1, icon: '/icons/data_revert_sm.svg', title: 'data_viewer_action_edit_revert', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts index 33401a6b79..8e54cd2f11 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts @@ -18,7 +18,9 @@ import { ClipboardService } from '@cloudbeaver/core-ui'; import { replaceMiddle } from '@cloudbeaver/core-utils'; import { DatabaseDataConstraintAction, + DataViewerContextMenuService, type IDatabaseDataModel, + type IDataGridCellMenuContext, type IResultSetColumnKey, IS_NOT_NULL_ID, IS_NULL_ID, @@ -31,8 +33,6 @@ import { wrapOperationArgument, } from '@cloudbeaver/plugin-data-viewer'; -import { DataGridContextMenuService, type IDataGridCellMenuContext } from '../DataGridContextMenuService.js'; - const FilterCustomValueDialog = importLazyComponent(() => import('./FilterCustomValueDialog.js').then(m => m.FilterCustomValueDialog)); @injectable() @@ -40,11 +40,11 @@ export class DataGridContextMenuFilterService { private static readonly menuFilterToken = 'menuFilter'; constructor( - private readonly dataGridContextMenuService: DataGridContextMenuService, + private readonly dataViewerContextMenuService: DataViewerContextMenuService, private readonly commonDialogService: CommonDialogService, private readonly clipboardService: ClipboardService, ) { - this.dataGridContextMenuService.onRootMenuOpen.addHandler(this.getClipboardValue.bind(this)); + this.dataViewerContextMenuService.onRootMenuOpen.addHandler(this.getClipboardValue.bind(this)); } getMenuFilterToken(): string { @@ -120,14 +120,14 @@ export class DataGridContextMenuFilterService { } register(): void { - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: this.getMenuFilterToken(), order: 2, title: 'data_grid_table_filter', icon: 'filter', isPanel: true, isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { if (context.data.model.isDisabled(context.data.resultIndex)) { @@ -139,13 +139,13 @@ export class DataGridContextMenuFilterService { return !constraints.supported; }, }); - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: 'deleteFiltersAndOrders', order: 3, title: 'data_grid_table_delete_filters_and_orders', icon: 'erase', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { if (context.data.model.isDisabled(context.data.resultIndex)) { @@ -166,13 +166,13 @@ export class DataGridContextMenuFilterService { }); }, }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'clipboardValue', order: 0, title: 'ui_clipboard', icon: 'filter-clipboard', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { if (!this.clipboardService.clipboardAvailable || this.clipboardService.state === 'denied') { @@ -188,7 +188,7 @@ export class DataGridContextMenuFilterService { panel: new ComputedContextMenuModel({ id: 'clipboardValuePanel', menuItemsGetter: context => { - if (context.contextType !== DataGridContextMenuService.cellContext) { + if (context.contextType !== DataViewerContextMenuService.cellContext) { return []; } @@ -214,13 +214,13 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'cellValue', order: 1, title: 'data_grid_table_filter_cell_value', icon: 'filter', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -244,13 +244,13 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'customValue', order: 2, title: 'data_grid_table_filter_custom_value', icon: 'filter-custom', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -309,12 +309,12 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'isNullValue', order: 3, icon: 'filter', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -338,12 +338,12 @@ export class DataGridContextMenuFilterService { ); }, }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'isNotNullValue', order: 4, icon: 'filter', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -367,12 +367,12 @@ export class DataGridContextMenuFilterService { ); }, }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'deleteFilter', order: 5, icon: 'filter-reset', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -406,13 +406,13 @@ export class DataGridContextMenuFilterService { }); }, }); - this.dataGridContextMenuService.add(this.getMenuFilterToken(), { + this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { id: 'deleteAllFilters', order: 6, icon: 'filter-reset-all', title: 'data_grid_table_filter_reset_all_filters', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex } = context.data; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts index 2c5bac60e0..37c9b2e2ba 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts @@ -8,6 +8,7 @@ import { injectable } from '@cloudbeaver/core-di'; import { DatabaseDataConstraintAction, + DataViewerContextMenuService, EOrder, type IDatabaseDataModel, type IDatabaseDataOptions, @@ -19,13 +20,11 @@ import { ResultSetDataSource, } from '@cloudbeaver/plugin-data-viewer'; -import { DataGridContextMenuService } from './DataGridContextMenuService.js'; - @injectable() export class DataGridContextMenuOrderService { private static readonly menuOrderToken = 'menuOrder'; - constructor(private readonly dataGridContextMenuService: DataGridContextMenuService) {} + constructor(private readonly dataViewerContextMenuService: DataViewerContextMenuService) {} getMenuOrderToken(): string { return DataGridContextMenuOrderService.menuOrderToken; @@ -50,14 +49,14 @@ export class DataGridContextMenuOrderService { } register(): void { - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: this.getMenuOrderToken(), order: 1, title: 'data_grid_table_order', icon: 'order-arrow-unknown', isPanel: true, isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -65,12 +64,12 @@ export class DataGridContextMenuOrderService { return !constraints.supported || context.data.model.isDisabled(context.data.resultIndex); }, }); - this.dataGridContextMenuService.add(this.getMenuOrderToken(), { + this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { id: 'asc', type: 'radio', title: 'ASC', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -86,12 +85,12 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === EOrder.asc; }, }); - this.dataGridContextMenuService.add(this.getMenuOrderToken(), { + this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { id: 'desc', type: 'radio', title: 'DESC', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -107,12 +106,12 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === EOrder.desc; }, }); - this.dataGridContextMenuService.add(this.getMenuOrderToken(), { + this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { id: 'disableOrder', type: 'radio', title: 'data_grid_table_disable_order', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -128,11 +127,11 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === null; }, }); - this.dataGridContextMenuService.add(this.getMenuOrderToken(), { + this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { id: 'disableOrders', title: 'data_grid_table_disable_all_orders', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; 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 25d8c630d3..436b272503 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 @@ -10,6 +10,7 @@ import { injectable } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; import { createResultSetBlobValue, + DataViewerContextMenuService, DataViewerService, isResultSetDataSource, ResultSetDataContentAction, @@ -18,24 +19,22 @@ import { ResultSetFormatAction, } from '@cloudbeaver/plugin-data-viewer'; -import { DataGridContextMenuService } from './DataGridContextMenuService.js'; - @injectable() export class DataGridContextMenuSaveContentService { constructor( - private readonly dataGridContextMenuService: DataGridContextMenuService, + private readonly dataViewerContextMenuService: DataViewerContextMenuService, private readonly notificationService: NotificationService, private readonly dataViewerService: DataViewerService, ) {} register(): void { - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: 'menuContentDownload', order: 4, title: 'ui_download', icon: '/icons/export.svg', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, onClick: async context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -59,13 +58,13 @@ export class DataGridContextMenuSaveContentService { return context.data.model.isLoading() || content.isLoading(context.data.key); }, }); - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: 'menuContentUpload', order: 5, title: 'ui_upload', icon: '/icons/import.svg', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, onClick: async context => { selectFiles(files => { diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx index bf0e70927c..86c2548ed2 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx @@ -10,9 +10,14 @@ import { observer } from 'mobx-react-lite'; import { Icon, MenuPanelItemAndTriggerStyles, MenuTrigger, s, SContext, type StyleRegistry, useS } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { EventContext, EventStopPropagationFlag } from '@cloudbeaver/core-events'; -import type { IDatabaseDataModel, IDataPresentationActions, IDataTableActions, IResultSetElementKey } from '@cloudbeaver/plugin-data-viewer'; +import { + DataViewerContextMenuService, + type IDatabaseDataModel, + type IDataPresentationActions, + type IDataTableActions, + type IResultSetElementKey, +} from '@cloudbeaver/plugin-data-viewer'; -import { DataGridContextMenuService } from '../../DataGridContextMenu/DataGridContextMenuService.js'; import styles from './CellMenu.module.css'; interface Props { @@ -49,16 +54,16 @@ export const CellMenu = observer(function CellMenu({ onStateSwitch, }) { const style = useS(styles); - const dataGridContextMenuService = useService(DataGridContextMenuService); + const dataViewerContextMenuService = useService(DataViewerContextMenuService); - const panel = dataGridContextMenuService.constructMenuWithContext(model, actions, spreadsheetActions, resultIndex, cellKey, simple); + const panel = dataViewerContextMenuService.constructMenuWithContext(model, actions, spreadsheetActions, resultIndex, cellKey, simple); if (!panel.menuItems.length || panel.menuItems.every(item => item.isHidden)) { return null; } function handleClick() { - dataGridContextMenuService.openMenu(model, actions, spreadsheetActions, resultIndex, cellKey, simple); + dataViewerContextMenuService.openMenu(model, actions, spreadsheetActions, resultIndex, cellKey, simple); onClick?.(); } diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts index 415d03a409..48ed86592d 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts @@ -9,13 +9,12 @@ import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { ExceptionsCatcherService } from '@cloudbeaver/core-events'; import { ResultDataFormat } from '@cloudbeaver/core-sdk'; -import { DataPresentationService } from '@cloudbeaver/plugin-data-viewer'; +import { DataPresentationService, DataViewerContextMenuService } from '@cloudbeaver/plugin-data-viewer'; import { DataGridContextMenuCellEditingService } from './DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.js'; import { DataGridContextMenuFilterService } from './DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.js'; import { DataGridContextMenuOrderService } from './DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.js'; import { DataGridContextMenuSaveContentService } from './DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.js'; -import { DataGridContextMenuService } from './DataGrid/DataGridContextMenu/DataGridContextMenuService.js'; import { DataGridSettingsService } from './DataGridSettingsService.js'; const SpreadsheetGrid = importLazyComponent(() => import('./SpreadsheetGrid.js').then(m => m.SpreadsheetGrid)); @@ -28,7 +27,7 @@ export class SpreadsheetBootstrap extends Bootstrap { private readonly dataGridContextMenuSortingService: DataGridContextMenuOrderService, private readonly dataGridContextMenuFilterService: DataGridContextMenuFilterService, private readonly dataGridContextMenuCellEditingService: DataGridContextMenuCellEditingService, - private readonly dataGridContextMenuService: DataGridContextMenuService, + private readonly dataViewerContextMenuService: DataViewerContextMenuService, private readonly dataGridContextMenuSaveContentService: DataGridContextMenuSaveContentService, exceptionsCatcherService: ExceptionsCatcherService, ) { @@ -50,10 +49,10 @@ export class SpreadsheetBootstrap extends Bootstrap { this.dataGridContextMenuCellEditingService.register(); this.dataGridContextMenuSaveContentService.register(); - this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { + this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: 'view_value_panel', isPresent(context) { - return context.contextType === DataGridContextMenuService.cellContext; + return context.contextType === DataViewerContextMenuService.cellContext; }, isHidden(context) { return context.data.actions.valuePresentationId === 'value-text-presentation' || context.data.simple; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts index c82f27c91b..ea9f300dc3 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts @@ -13,7 +13,6 @@ export const dataSpreadsheetNewManifest: PluginManifest = { () => import('./SpreadsheetBootstrap.js').then(m => m.SpreadsheetBootstrap), () => import('./DataGridSettingsService.js').then(m => m.DataGridSettingsService), () => import('./LocaleService.js').then(m => m.LocaleService), - () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuService.js').then(m => m.DataGridContextMenuService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.js').then(m => m.DataGridContextMenuOrderService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.js').then( diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts similarity index 75% rename from webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts rename to webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts index a1673bbc2b..1962b20380 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts @@ -8,7 +8,11 @@ import { injectable } from '@cloudbeaver/core-di'; import { ContextMenuService, type IContextMenuItem, type IMenuPanel } from '@cloudbeaver/core-dialogs'; import { Executor, type IExecutor } from '@cloudbeaver/core-executor'; -import type { IDatabaseDataModel, IDataPresentationActions, IDataTableActions, IResultSetElementKey } from '@cloudbeaver/plugin-data-viewer'; + +import type { IResultSetElementKey } from './DatabaseDataModel/Actions/ResultSet/IResultSetDataKey.js'; +import type { IDatabaseDataModel } from './DatabaseDataModel/IDatabaseDataModel.js'; +import type { IDataPresentationActions } from './TableViewer/IDataPresentationActions.js'; +import type { IDataTableActions } from './TableViewer/IDataTableActions.js'; export interface IDataGridCellMenuContext { model: IDatabaseDataModel; @@ -20,17 +24,18 @@ export interface IDataGridCellMenuContext { } @injectable() -export class DataGridContextMenuService { +export class DataViewerContextMenuService { onRootMenuOpen: IExecutor; - static cellContext = 'data-grid-cell-context-menu'; - private static readonly menuToken = 'dataGridCell'; + + static cellContext = 'data-viewer-cell-context-menu'; + private static readonly menuToken = 'data-viewer-context-menu'; constructor(private readonly contextMenuService: ContextMenuService) { this.onRootMenuOpen = new Executor(); } getMenuToken(): string { - return DataGridContextMenuService.menuToken; + return DataViewerContextMenuService.menuToken; } constructMenuWithContext( @@ -44,7 +49,7 @@ export class DataGridContextMenuService { return this.contextMenuService.createContextMenu( { menuId: this.getMenuToken(), - contextType: DataGridContextMenuService.cellContext, + contextType: DataViewerContextMenuService.cellContext, data: { model, actions, spreadsheetActions, resultIndex, key, simple }, }, this.getMenuToken(), diff --git a/webapp/packages/plugin-data-viewer/src/index.ts b/webapp/packages/plugin-data-viewer/src/index.ts index 6694d88dc1..385d37491c 100644 --- a/webapp/packages/plugin-data-viewer/src/index.ts +++ b/webapp/packages/plugin-data-viewer/src/index.ts @@ -68,6 +68,7 @@ export * from './DatabaseDataModel/IDatabaseResultSet.js'; export * from './DatabaseDataModel/Order.js'; export * from './DataViewerService.js'; export * from './useDataViewerModel.js'; +export * from './DataViewerContextMenuService.js'; // All Services and Components that is provided by this plugin should be exported here export * from './TableViewer/TableViewerStorageService.js'; diff --git a/webapp/packages/plugin-data-viewer/src/manifest.ts b/webapp/packages/plugin-data-viewer/src/manifest.ts index f53e56ec9c..ef278fc0a3 100644 --- a/webapp/packages/plugin-data-viewer/src/manifest.ts +++ b/webapp/packages/plugin-data-viewer/src/manifest.ts @@ -33,6 +33,7 @@ export const dataViewerManifest: PluginManifest = { () => import('./DataViewerService.js').then(m => m.DataViewerService), () => import('./ResultSet/ResultSetTableFooterMenuService.js').then(m => m.ResultSetTableFooterMenuService), () => import('./TableViewer/DataViewerViewService.js').then(m => m.DataViewerViewService), + () => import('./DataViewerContextMenuService.js').then(m => m.DataViewerContextMenuService), () => import('./TableViewer/TableFooter/TableFooterMenu/FetchSizeAction/TableFetchSizeActionBootstrap.js').then(m => m.TableFetchSizeActionBootstrap), ], From 3ae20b10e415df1579903a6295a15f2ff65e68b0 Mon Sep 17 00:00:00 2001 From: naumov Date: Wed, 23 Oct 2024 20:33:36 +0200 Subject: [PATCH 2/5] CB-5368 naming --- .../DataGridContextMenuFilterService.ts | 14 +++++++------- .../src/DataViewerContextMenuService.ts | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts index 8e54cd2f11..cd5cc5558f 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts @@ -20,7 +20,7 @@ import { DatabaseDataConstraintAction, DataViewerContextMenuService, type IDatabaseDataModel, - type IDataGridCellMenuContext, + type IDataViewerContextMenu, type IResultSetColumnKey, IS_NOT_NULL_ID, IS_NULL_ID, @@ -82,11 +82,11 @@ export class DataGridContextMenuFilterService { } private getGeneralizedMenuItems( - context: IMenuContext, + context: IMenuContext, value: any | (() => any), icon: string, - isHidden?: (context: IMenuContext) => boolean, - ): Array> { + isHidden?: (context: IMenuContext) => boolean, + ): Array> { const { model, resultIndex, key } = context.data; const source = model.source as unknown as ResultSetDataSource; const data = source.getAction(resultIndex, ResultSetDataAction); @@ -185,7 +185,7 @@ export class DataGridContextMenuFilterService { return supportedOperations.length === 0; }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'clipboardValuePanel', menuItemsGetter: context => { if (context.contextType !== DataViewerContextMenuService.cellContext) { @@ -232,7 +232,7 @@ export class DataGridContextMenuFilterService { return value === undefined || supportedOperations.length === 0 || format.isNull(key); }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'cellValuePanel', menuItemsGetter: context => { const { model, resultIndex, key } = context.data; @@ -261,7 +261,7 @@ export class DataGridContextMenuFilterService { return cellValue === undefined || supportedOperations.length === 0; }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'customValuePanel', menuItemsGetter: context => { const { model, resultIndex, key } = context.data; diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts b/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts index 1962b20380..0169d849c0 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts +++ b/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts @@ -14,7 +14,7 @@ import type { IDatabaseDataModel } from './DatabaseDataModel/IDatabaseDataModel. import type { IDataPresentationActions } from './TableViewer/IDataPresentationActions.js'; import type { IDataTableActions } from './TableViewer/IDataTableActions.js'; -export interface IDataGridCellMenuContext { +export interface IDataViewerContextMenu { model: IDatabaseDataModel; actions: IDataTableActions; spreadsheetActions: IDataPresentationActions; @@ -25,7 +25,7 @@ export interface IDataGridCellMenuContext { @injectable() export class DataViewerContextMenuService { - onRootMenuOpen: IExecutor; + onRootMenuOpen: IExecutor; static cellContext = 'data-viewer-cell-context-menu'; private static readonly menuToken = 'data-viewer-context-menu'; @@ -46,7 +46,7 @@ export class DataViewerContextMenuService { key: IResultSetElementKey, simple: boolean, ): IMenuPanel { - return this.contextMenuService.createContextMenu( + return this.contextMenuService.createContextMenu( { menuId: this.getMenuToken(), contextType: DataViewerContextMenuService.cellContext, @@ -67,7 +67,7 @@ export class DataViewerContextMenuService { this.onRootMenuOpen.execute({ model, actions, spreadsheetActions, resultIndex, key, simple }); } - add(panelId: string, menuItem: IContextMenuItem): void { + add(panelId: string, menuItem: IContextMenuItem): void { this.contextMenuService.addMenuItem(panelId, menuItem); } } From 3fea7e1720c9256bba83002edbd751815c75583c Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 24 Oct 2024 14:54:22 +0200 Subject: [PATCH 3/5] CB-5368 revert class move --- .../DataGridContextMenuCellEditingService.ts | 23 +++++------ .../DataGridContextMenuFilterService.ts | 38 +++++++++---------- .../DataGridContextMenuOrderService.ts | 15 ++++---- .../DataGridContextMenuSaveContentService.ts | 9 +++-- .../DataGridContextMenuService.ts} | 24 +++++------- .../src/DataGrid/Formatters/Menu/CellMenu.tsx | 4 +- .../src/SpreadsheetBootstrap.ts | 7 ++-- .../src/manifest.ts | 1 + .../packages/plugin-data-viewer/src/index.ts | 1 - .../plugin-data-viewer/src/manifest.ts | 1 - 10 files changed, 61 insertions(+), 62 deletions(-) rename webapp/packages/{plugin-data-viewer/src/DataViewerContextMenuService.ts => plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts} (64%) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts index 6cea084a23..60eb92ae40 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts @@ -8,7 +8,6 @@ import { injectable } from '@cloudbeaver/core-di'; import { DatabaseEditChangeType, - DataViewerContextMenuService, isBooleanValuePresentationAvailable, isResultSetDataSource, ResultSetDataContentAction, @@ -19,11 +18,13 @@ import { ResultSetViewAction, } from '@cloudbeaver/plugin-data-viewer'; +import { DataGridContextMenuService } from './DataGridContextMenuService.js'; + @injectable() export class DataGridContextMenuCellEditingService { private static readonly menuEditingToken = 'menuEditing'; - constructor(private readonly dataViewerContextMenuService: DataViewerContextMenuService) {} + constructor(private readonly dataViewerContextMenuService: DataGridContextMenuService) {} getMenuEditingToken(): string { return DataGridContextMenuCellEditingService.menuEditingToken; @@ -37,7 +38,7 @@ export class DataGridContextMenuCellEditingService { icon: 'edit', isPanel: true, isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext; + return context.contextType === DataGridContextMenuService.cellContext; }, isHidden(context) { return context.data.model.isDisabled(context.data.resultIndex) || context.data.model.isReadonly(context.data.resultIndex); @@ -49,7 +50,7 @@ export class DataGridContextMenuCellEditingService { title: 'data_grid_table_editing_open_inline_editor', icon: 'edit', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -76,7 +77,7 @@ export class DataGridContextMenuCellEditingService { order: 1, title: 'data_grid_table_editing_set_to_null', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const { key, model, resultIndex } = context.data; @@ -98,7 +99,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_add_sm.svg', title: 'data_grid_table_editing_row_add', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -117,7 +118,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_add_copy_sm.svg', title: 'data_grid_table_editing_row_add_copy', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -136,7 +137,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_delete_sm.svg', title: 'data_grid_table_editing_row_delete', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -161,7 +162,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_delete_sm.svg', title: 'data_viewer_action_edit_delete', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -193,7 +194,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_revert_sm.svg', title: 'data_grid_table_editing_row_revert', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -212,7 +213,7 @@ export class DataGridContextMenuCellEditingService { icon: '/icons/data_revert_sm.svg', title: 'data_viewer_action_edit_revert', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts index cd5cc5558f..135d731297 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts @@ -18,9 +18,7 @@ import { ClipboardService } from '@cloudbeaver/core-ui'; import { replaceMiddle } from '@cloudbeaver/core-utils'; import { DatabaseDataConstraintAction, - DataViewerContextMenuService, type IDatabaseDataModel, - type IDataViewerContextMenu, type IResultSetColumnKey, IS_NOT_NULL_ID, IS_NULL_ID, @@ -33,6 +31,8 @@ import { wrapOperationArgument, } from '@cloudbeaver/plugin-data-viewer'; +import { DataGridContextMenuService, type IDataGridCellMenuContext } from '../DataGridContextMenuService.js'; + const FilterCustomValueDialog = importLazyComponent(() => import('./FilterCustomValueDialog.js').then(m => m.FilterCustomValueDialog)); @injectable() @@ -40,7 +40,7 @@ export class DataGridContextMenuFilterService { private static readonly menuFilterToken = 'menuFilter'; constructor( - private readonly dataViewerContextMenuService: DataViewerContextMenuService, + private readonly dataViewerContextMenuService: DataGridContextMenuService, private readonly commonDialogService: CommonDialogService, private readonly clipboardService: ClipboardService, ) { @@ -82,11 +82,11 @@ export class DataGridContextMenuFilterService { } private getGeneralizedMenuItems( - context: IMenuContext, + context: IMenuContext, value: any | (() => any), icon: string, - isHidden?: (context: IMenuContext) => boolean, - ): Array> { + isHidden?: (context: IMenuContext) => boolean, + ): Array> { const { model, resultIndex, key } = context.data; const source = model.source as unknown as ResultSetDataSource; const data = source.getAction(resultIndex, ResultSetDataAction); @@ -127,7 +127,7 @@ export class DataGridContextMenuFilterService { icon: 'filter', isPanel: true, isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { if (context.data.model.isDisabled(context.data.resultIndex)) { @@ -145,7 +145,7 @@ export class DataGridContextMenuFilterService { title: 'data_grid_table_delete_filters_and_orders', icon: 'erase', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { if (context.data.model.isDisabled(context.data.resultIndex)) { @@ -172,7 +172,7 @@ export class DataGridContextMenuFilterService { title: 'ui_clipboard', icon: 'filter-clipboard', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { if (!this.clipboardService.clipboardAvailable || this.clipboardService.state === 'denied') { @@ -185,10 +185,10 @@ export class DataGridContextMenuFilterService { return supportedOperations.length === 0; }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'clipboardValuePanel', menuItemsGetter: context => { - if (context.contextType !== DataViewerContextMenuService.cellContext) { + if (context.contextType !== DataGridContextMenuService.cellContext) { return []; } @@ -220,7 +220,7 @@ export class DataGridContextMenuFilterService { title: 'data_grid_table_filter_cell_value', icon: 'filter', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -232,7 +232,7 @@ export class DataGridContextMenuFilterService { return value === undefined || supportedOperations.length === 0 || format.isNull(key); }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'cellValuePanel', menuItemsGetter: context => { const { model, resultIndex, key } = context.data; @@ -250,7 +250,7 @@ export class DataGridContextMenuFilterService { title: 'data_grid_table_filter_custom_value', icon: 'filter-custom', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -261,7 +261,7 @@ export class DataGridContextMenuFilterService { return cellValue === undefined || supportedOperations.length === 0; }, - panel: new ComputedContextMenuModel({ + panel: new ComputedContextMenuModel({ id: 'customValuePanel', menuItemsGetter: context => { const { model, resultIndex, key } = context.data; @@ -314,7 +314,7 @@ export class DataGridContextMenuFilterService { order: 3, icon: 'filter', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -343,7 +343,7 @@ export class DataGridContextMenuFilterService { order: 4, icon: 'filter', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -372,7 +372,7 @@ export class DataGridContextMenuFilterService { order: 5, icon: 'filter-reset', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex, key } = context.data; @@ -412,7 +412,7 @@ export class DataGridContextMenuFilterService { icon: 'filter-reset-all', title: 'data_grid_table_filter_reset_all_filters', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const { model, resultIndex } = context.data; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts index 37c9b2e2ba..dc83683103 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts @@ -8,7 +8,6 @@ import { injectable } from '@cloudbeaver/core-di'; import { DatabaseDataConstraintAction, - DataViewerContextMenuService, EOrder, type IDatabaseDataModel, type IDatabaseDataOptions, @@ -20,11 +19,13 @@ import { ResultSetDataSource, } from '@cloudbeaver/plugin-data-viewer'; +import { DataGridContextMenuService } from './DataGridContextMenuService.js'; + @injectable() export class DataGridContextMenuOrderService { private static readonly menuOrderToken = 'menuOrder'; - constructor(private readonly dataViewerContextMenuService: DataViewerContextMenuService) {} + constructor(private readonly dataViewerContextMenuService: DataGridContextMenuService) {} getMenuOrderToken(): string { return DataGridContextMenuOrderService.menuOrderToken; @@ -56,7 +57,7 @@ export class DataGridContextMenuOrderService { icon: 'order-arrow-unknown', isPanel: true, isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden(context) { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -69,7 +70,7 @@ export class DataGridContextMenuOrderService { type: 'radio', title: 'ASC', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -90,7 +91,7 @@ export class DataGridContextMenuOrderService { type: 'radio', title: 'DESC', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -111,7 +112,7 @@ export class DataGridContextMenuOrderService { type: 'radio', title: 'data_grid_table_disable_order', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isDisabled: context => context.data.model.isLoading(), onClick: async context => { @@ -131,7 +132,7 @@ export class DataGridContextMenuOrderService { id: 'disableOrders', title: 'data_grid_table_disable_all_orders', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, isHidden: context => { const source = context.data.model.source as unknown as ResultSetDataSource; 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 436b272503..afe584532b 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 @@ -10,7 +10,6 @@ import { injectable } from '@cloudbeaver/core-di'; import { NotificationService } from '@cloudbeaver/core-events'; import { createResultSetBlobValue, - DataViewerContextMenuService, DataViewerService, isResultSetDataSource, ResultSetDataContentAction, @@ -19,10 +18,12 @@ import { ResultSetFormatAction, } from '@cloudbeaver/plugin-data-viewer'; +import { DataGridContextMenuService } from './DataGridContextMenuService.js'; + @injectable() export class DataGridContextMenuSaveContentService { constructor( - private readonly dataViewerContextMenuService: DataViewerContextMenuService, + private readonly dataViewerContextMenuService: DataGridContextMenuService, private readonly notificationService: NotificationService, private readonly dataViewerService: DataViewerService, ) {} @@ -34,7 +35,7 @@ export class DataGridContextMenuSaveContentService { title: 'ui_download', icon: '/icons/export.svg', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, onClick: async context => { const source = context.data.model.source as unknown as ResultSetDataSource; @@ -64,7 +65,7 @@ export class DataGridContextMenuSaveContentService { title: 'ui_upload', icon: '/icons/import.svg', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); + return context.contextType === DataGridContextMenuService.cellContext && isResultSetDataSource(context.data.model.source); }, onClick: async context => { selectFiles(files => { diff --git a/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts similarity index 64% rename from webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts rename to webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts index 0169d849c0..856969fbd6 100644 --- a/webapp/packages/plugin-data-viewer/src/DataViewerContextMenuService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts @@ -8,13 +8,9 @@ import { injectable } from '@cloudbeaver/core-di'; import { ContextMenuService, type IContextMenuItem, type IMenuPanel } from '@cloudbeaver/core-dialogs'; import { Executor, type IExecutor } from '@cloudbeaver/core-executor'; +import type { IDatabaseDataModel, IDataPresentationActions, IDataTableActions, IResultSetElementKey } from '@cloudbeaver/plugin-data-viewer'; -import type { IResultSetElementKey } from './DatabaseDataModel/Actions/ResultSet/IResultSetDataKey.js'; -import type { IDatabaseDataModel } from './DatabaseDataModel/IDatabaseDataModel.js'; -import type { IDataPresentationActions } from './TableViewer/IDataPresentationActions.js'; -import type { IDataTableActions } from './TableViewer/IDataTableActions.js'; - -export interface IDataViewerContextMenu { +export interface IDataGridCellMenuContext { model: IDatabaseDataModel; actions: IDataTableActions; spreadsheetActions: IDataPresentationActions; @@ -24,18 +20,18 @@ export interface IDataViewerContextMenu { } @injectable() -export class DataViewerContextMenuService { - onRootMenuOpen: IExecutor; +export class DataGridContextMenuService { + onRootMenuOpen: IExecutor; - static cellContext = 'data-viewer-cell-context-menu'; - private static readonly menuToken = 'data-viewer-context-menu'; + static cellContext = 'data-grid-cell-context-menu'; + private static readonly menuToken = 'dataGridCell'; constructor(private readonly contextMenuService: ContextMenuService) { this.onRootMenuOpen = new Executor(); } getMenuToken(): string { - return DataViewerContextMenuService.menuToken; + return DataGridContextMenuService.menuToken; } constructMenuWithContext( @@ -46,10 +42,10 @@ export class DataViewerContextMenuService { key: IResultSetElementKey, simple: boolean, ): IMenuPanel { - return this.contextMenuService.createContextMenu( + return this.contextMenuService.createContextMenu( { menuId: this.getMenuToken(), - contextType: DataViewerContextMenuService.cellContext, + contextType: DataGridContextMenuService.cellContext, data: { model, actions, spreadsheetActions, resultIndex, key, simple }, }, this.getMenuToken(), @@ -67,7 +63,7 @@ export class DataViewerContextMenuService { this.onRootMenuOpen.execute({ model, actions, spreadsheetActions, resultIndex, key, simple }); } - add(panelId: string, menuItem: IContextMenuItem): void { + add(panelId: string, menuItem: IContextMenuItem): void { this.contextMenuService.addMenuItem(panelId, menuItem); } } diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx index 86c2548ed2..acbe300a4b 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx @@ -11,13 +11,13 @@ import { Icon, MenuPanelItemAndTriggerStyles, MenuTrigger, s, SContext, type Sty import { useService } from '@cloudbeaver/core-di'; import { EventContext, EventStopPropagationFlag } from '@cloudbeaver/core-events'; import { - DataViewerContextMenuService, type IDatabaseDataModel, type IDataPresentationActions, type IDataTableActions, type IResultSetElementKey, } from '@cloudbeaver/plugin-data-viewer'; +import { DataGridContextMenuService } from '../../DataGridContextMenu/DataGridContextMenuService.js'; import styles from './CellMenu.module.css'; interface Props { @@ -54,7 +54,7 @@ export const CellMenu = observer(function CellMenu({ onStateSwitch, }) { const style = useS(styles); - const dataViewerContextMenuService = useService(DataViewerContextMenuService); + const dataViewerContextMenuService = useService(DataGridContextMenuService); const panel = dataViewerContextMenuService.constructMenuWithContext(model, actions, spreadsheetActions, resultIndex, cellKey, simple); diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts index 48ed86592d..3dabe4963d 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts @@ -9,12 +9,13 @@ import { importLazyComponent } from '@cloudbeaver/core-blocks'; import { Bootstrap, injectable } from '@cloudbeaver/core-di'; import { ExceptionsCatcherService } from '@cloudbeaver/core-events'; import { ResultDataFormat } from '@cloudbeaver/core-sdk'; -import { DataPresentationService, DataViewerContextMenuService } from '@cloudbeaver/plugin-data-viewer'; +import { DataPresentationService } from '@cloudbeaver/plugin-data-viewer'; import { DataGridContextMenuCellEditingService } from './DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.js'; import { DataGridContextMenuFilterService } from './DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.js'; import { DataGridContextMenuOrderService } from './DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.js'; import { DataGridContextMenuSaveContentService } from './DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.js'; +import { DataGridContextMenuService } from './DataGrid/DataGridContextMenu/DataGridContextMenuService.js'; import { DataGridSettingsService } from './DataGridSettingsService.js'; const SpreadsheetGrid = importLazyComponent(() => import('./SpreadsheetGrid.js').then(m => m.SpreadsheetGrid)); @@ -27,7 +28,7 @@ export class SpreadsheetBootstrap extends Bootstrap { private readonly dataGridContextMenuSortingService: DataGridContextMenuOrderService, private readonly dataGridContextMenuFilterService: DataGridContextMenuFilterService, private readonly dataGridContextMenuCellEditingService: DataGridContextMenuCellEditingService, - private readonly dataViewerContextMenuService: DataViewerContextMenuService, + private readonly dataViewerContextMenuService: DataGridContextMenuService, private readonly dataGridContextMenuSaveContentService: DataGridContextMenuSaveContentService, exceptionsCatcherService: ExceptionsCatcherService, ) { @@ -52,7 +53,7 @@ export class SpreadsheetBootstrap extends Bootstrap { this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { id: 'view_value_panel', isPresent(context) { - return context.contextType === DataViewerContextMenuService.cellContext; + return context.contextType === DataGridContextMenuService.cellContext; }, isHidden(context) { return context.data.actions.valuePresentationId === 'value-text-presentation' || context.data.simple; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts index ea9f300dc3..8eee946fbd 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts @@ -20,5 +20,6 @@ export const dataSpreadsheetNewManifest: PluginManifest = { ), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.js').then(m => m.DataGridContextMenuCellEditingService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.js').then(m => m.DataGridContextMenuSaveContentService), + () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuService.js').then(m => m.DataGridContextMenuService), ], }; diff --git a/webapp/packages/plugin-data-viewer/src/index.ts b/webapp/packages/plugin-data-viewer/src/index.ts index 385d37491c..6694d88dc1 100644 --- a/webapp/packages/plugin-data-viewer/src/index.ts +++ b/webapp/packages/plugin-data-viewer/src/index.ts @@ -68,7 +68,6 @@ export * from './DatabaseDataModel/IDatabaseResultSet.js'; export * from './DatabaseDataModel/Order.js'; export * from './DataViewerService.js'; export * from './useDataViewerModel.js'; -export * from './DataViewerContextMenuService.js'; // All Services and Components that is provided by this plugin should be exported here export * from './TableViewer/TableViewerStorageService.js'; diff --git a/webapp/packages/plugin-data-viewer/src/manifest.ts b/webapp/packages/plugin-data-viewer/src/manifest.ts index ef278fc0a3..f53e56ec9c 100644 --- a/webapp/packages/plugin-data-viewer/src/manifest.ts +++ b/webapp/packages/plugin-data-viewer/src/manifest.ts @@ -33,7 +33,6 @@ export const dataViewerManifest: PluginManifest = { () => import('./DataViewerService.js').then(m => m.DataViewerService), () => import('./ResultSet/ResultSetTableFooterMenuService.js').then(m => m.ResultSetTableFooterMenuService), () => import('./TableViewer/DataViewerViewService.js').then(m => m.DataViewerViewService), - () => import('./DataViewerContextMenuService.js').then(m => m.DataViewerContextMenuService), () => import('./TableViewer/TableFooter/TableFooterMenu/FetchSizeAction/TableFetchSizeActionBootstrap.js').then(m => m.TableFetchSizeActionBootstrap), ], From 60bb795484224b9088eacf00ef7ad9bab3e31026 Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 24 Oct 2024 15:12:23 +0200 Subject: [PATCH 4/5] CB-5368 clean the code --- .../DataGridContextMenuCellEditingService.ts | 20 ++++++++--------- .../DataGridContextMenuFilterService.ts | 22 +++++++++---------- .../DataGridContextMenuOrderService.ts | 12 +++++----- .../DataGridContextMenuSaveContentService.ts | 6 ++--- .../src/DataGrid/Formatters/Menu/CellMenu.tsx | 6 ++--- .../src/SpreadsheetBootstrap.ts | 4 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts index 60eb92ae40..3a39b9bfd5 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.ts @@ -24,14 +24,14 @@ import { DataGridContextMenuService } from './DataGridContextMenuService.js'; export class DataGridContextMenuCellEditingService { private static readonly menuEditingToken = 'menuEditing'; - constructor(private readonly dataViewerContextMenuService: DataGridContextMenuService) {} + constructor(private readonly dataGridContextMenuService: DataGridContextMenuService) {} getMenuEditingToken(): string { return DataGridContextMenuCellEditingService.menuEditingToken; } register(): void { - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: this.getMenuEditingToken(), order: 4, title: 'data_grid_table_editing', @@ -44,7 +44,7 @@ export class DataGridContextMenuCellEditingService { return context.data.model.isDisabled(context.data.resultIndex) || context.data.model.isReadonly(context.data.resultIndex); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'open_inline_editor', order: 0, title: 'data_grid_table_editing_open_inline_editor', @@ -72,7 +72,7 @@ export class DataGridContextMenuCellEditingService { context.data.spreadsheetActions.edit(context.data.key); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'set_to_null', order: 1, title: 'data_grid_table_editing_set_to_null', @@ -93,7 +93,7 @@ export class DataGridContextMenuCellEditingService { source.getAction(context.data.resultIndex, ResultSetEditAction).set(context.data.key, null); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_add', order: 5, icon: '/icons/data_add_sm.svg', @@ -112,7 +112,7 @@ export class DataGridContextMenuCellEditingService { editor.addRow(context.data.key.row); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_add_copy', order: 5.5, icon: '/icons/data_add_copy_sm.svg', @@ -131,7 +131,7 @@ export class DataGridContextMenuCellEditingService { editor.duplicateRow(context.data.key.row); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_delete', order: 6, icon: '/icons/data_delete_sm.svg', @@ -156,7 +156,7 @@ export class DataGridContextMenuCellEditingService { editor.deleteRow(context.data.key.row); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_delete_selected', order: 6.1, icon: '/icons/data_delete_sm.svg', @@ -188,7 +188,7 @@ export class DataGridContextMenuCellEditingService { editor.delete(...selectedElements); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_revert', order: 7, icon: '/icons/data_revert_sm.svg', @@ -207,7 +207,7 @@ export class DataGridContextMenuCellEditingService { editor.revert(context.data.key); }, }); - this.dataViewerContextMenuService.add(this.getMenuEditingToken(), { + this.dataGridContextMenuService.add(this.getMenuEditingToken(), { id: 'row_revert_selected', order: 7.1, icon: '/icons/data_revert_sm.svg', diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts index 135d731297..33401a6b79 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.ts @@ -40,11 +40,11 @@ export class DataGridContextMenuFilterService { private static readonly menuFilterToken = 'menuFilter'; constructor( - private readonly dataViewerContextMenuService: DataGridContextMenuService, + private readonly dataGridContextMenuService: DataGridContextMenuService, private readonly commonDialogService: CommonDialogService, private readonly clipboardService: ClipboardService, ) { - this.dataViewerContextMenuService.onRootMenuOpen.addHandler(this.getClipboardValue.bind(this)); + this.dataGridContextMenuService.onRootMenuOpen.addHandler(this.getClipboardValue.bind(this)); } getMenuFilterToken(): string { @@ -120,7 +120,7 @@ export class DataGridContextMenuFilterService { } register(): void { - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: this.getMenuFilterToken(), order: 2, title: 'data_grid_table_filter', @@ -139,7 +139,7 @@ export class DataGridContextMenuFilterService { return !constraints.supported; }, }); - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: 'deleteFiltersAndOrders', order: 3, title: 'data_grid_table_delete_filters_and_orders', @@ -166,7 +166,7 @@ export class DataGridContextMenuFilterService { }); }, }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'clipboardValue', order: 0, title: 'ui_clipboard', @@ -214,7 +214,7 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'cellValue', order: 1, title: 'data_grid_table_filter_cell_value', @@ -244,7 +244,7 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'customValue', order: 2, title: 'data_grid_table_filter_custom_value', @@ -309,7 +309,7 @@ export class DataGridContextMenuFilterService { }, }), }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'isNullValue', order: 3, icon: 'filter', @@ -338,7 +338,7 @@ export class DataGridContextMenuFilterService { ); }, }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'isNotNullValue', order: 4, icon: 'filter', @@ -367,7 +367,7 @@ export class DataGridContextMenuFilterService { ); }, }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'deleteFilter', order: 5, icon: 'filter-reset', @@ -406,7 +406,7 @@ export class DataGridContextMenuFilterService { }); }, }); - this.dataViewerContextMenuService.add(this.getMenuFilterToken(), { + this.dataGridContextMenuService.add(this.getMenuFilterToken(), { id: 'deleteAllFilters', order: 6, icon: 'filter-reset-all', diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts index dc83683103..2c5bac60e0 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.ts @@ -25,7 +25,7 @@ import { DataGridContextMenuService } from './DataGridContextMenuService.js'; export class DataGridContextMenuOrderService { private static readonly menuOrderToken = 'menuOrder'; - constructor(private readonly dataViewerContextMenuService: DataGridContextMenuService) {} + constructor(private readonly dataGridContextMenuService: DataGridContextMenuService) {} getMenuOrderToken(): string { return DataGridContextMenuOrderService.menuOrderToken; @@ -50,7 +50,7 @@ export class DataGridContextMenuOrderService { } register(): void { - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: this.getMenuOrderToken(), order: 1, title: 'data_grid_table_order', @@ -65,7 +65,7 @@ export class DataGridContextMenuOrderService { return !constraints.supported || context.data.model.isDisabled(context.data.resultIndex); }, }); - this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { + this.dataGridContextMenuService.add(this.getMenuOrderToken(), { id: 'asc', type: 'radio', title: 'ASC', @@ -86,7 +86,7 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === EOrder.asc; }, }); - this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { + this.dataGridContextMenuService.add(this.getMenuOrderToken(), { id: 'desc', type: 'radio', title: 'DESC', @@ -107,7 +107,7 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === EOrder.desc; }, }); - this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { + this.dataGridContextMenuService.add(this.getMenuOrderToken(), { id: 'disableOrder', type: 'radio', title: 'data_grid_table_disable_order', @@ -128,7 +128,7 @@ export class DataGridContextMenuOrderService { return !!resultColumn && constraints.getOrder(resultColumn.position) === null; }, }); - this.dataViewerContextMenuService.add(this.getMenuOrderToken(), { + this.dataGridContextMenuService.add(this.getMenuOrderToken(), { id: 'disableOrders', title: 'data_grid_table_disable_all_orders', isPresent(context) { 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 afe584532b..25d8c630d3 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 @@ -23,13 +23,13 @@ import { DataGridContextMenuService } from './DataGridContextMenuService.js'; @injectable() export class DataGridContextMenuSaveContentService { constructor( - private readonly dataViewerContextMenuService: DataGridContextMenuService, + private readonly dataGridContextMenuService: DataGridContextMenuService, private readonly notificationService: NotificationService, private readonly dataViewerService: DataViewerService, ) {} register(): void { - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: 'menuContentDownload', order: 4, title: 'ui_download', @@ -59,7 +59,7 @@ export class DataGridContextMenuSaveContentService { return context.data.model.isLoading() || content.isLoading(context.data.key); }, }); - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: 'menuContentUpload', order: 5, title: 'ui_upload', diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx index acbe300a4b..695c2205a9 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx @@ -54,16 +54,16 @@ export const CellMenu = observer(function CellMenu({ onStateSwitch, }) { const style = useS(styles); - const dataViewerContextMenuService = useService(DataGridContextMenuService); + const dataGridContextMenuService = useService(DataGridContextMenuService); - const panel = dataViewerContextMenuService.constructMenuWithContext(model, actions, spreadsheetActions, resultIndex, cellKey, simple); + const panel = dataGridContextMenuService.constructMenuWithContext(model, actions, spreadsheetActions, resultIndex, cellKey, simple); if (!panel.menuItems.length || panel.menuItems.every(item => item.isHidden)) { return null; } function handleClick() { - dataViewerContextMenuService.openMenu(model, actions, spreadsheetActions, resultIndex, cellKey, simple); + dataGridContextMenuService.openMenu(model, actions, spreadsheetActions, resultIndex, cellKey, simple); onClick?.(); } diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts index 3dabe4963d..415d03a409 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/SpreadsheetBootstrap.ts @@ -28,7 +28,7 @@ export class SpreadsheetBootstrap extends Bootstrap { private readonly dataGridContextMenuSortingService: DataGridContextMenuOrderService, private readonly dataGridContextMenuFilterService: DataGridContextMenuFilterService, private readonly dataGridContextMenuCellEditingService: DataGridContextMenuCellEditingService, - private readonly dataViewerContextMenuService: DataGridContextMenuService, + private readonly dataGridContextMenuService: DataGridContextMenuService, private readonly dataGridContextMenuSaveContentService: DataGridContextMenuSaveContentService, exceptionsCatcherService: ExceptionsCatcherService, ) { @@ -50,7 +50,7 @@ export class SpreadsheetBootstrap extends Bootstrap { this.dataGridContextMenuCellEditingService.register(); this.dataGridContextMenuSaveContentService.register(); - this.dataViewerContextMenuService.add(this.dataViewerContextMenuService.getMenuToken(), { + this.dataGridContextMenuService.add(this.dataGridContextMenuService.getMenuToken(), { id: 'view_value_panel', isPresent(context) { return context.contextType === DataGridContextMenuService.cellContext; From e9978c0cedb76d92ebd9f47114d796494ed1e1b4 Mon Sep 17 00:00:00 2001 From: naumov Date: Thu, 24 Oct 2024 15:14:15 +0200 Subject: [PATCH 5/5] CB-5368 import changes --- .../DataGridContextMenu/DataGridContextMenuService.ts | 1 - .../src/DataGrid/Formatters/Menu/CellMenu.tsx | 7 +------ .../packages/plugin-data-spreadsheet-new/src/manifest.ts | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts index 856969fbd6..a1673bbc2b 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridContextMenu/DataGridContextMenuService.ts @@ -22,7 +22,6 @@ export interface IDataGridCellMenuContext { @injectable() export class DataGridContextMenuService { onRootMenuOpen: IExecutor; - static cellContext = 'data-grid-cell-context-menu'; private static readonly menuToken = 'dataGridCell'; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx index 695c2205a9..bf0e70927c 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/Formatters/Menu/CellMenu.tsx @@ -10,12 +10,7 @@ import { observer } from 'mobx-react-lite'; import { Icon, MenuPanelItemAndTriggerStyles, MenuTrigger, s, SContext, type StyleRegistry, useS } from '@cloudbeaver/core-blocks'; import { useService } from '@cloudbeaver/core-di'; import { EventContext, EventStopPropagationFlag } from '@cloudbeaver/core-events'; -import { - type IDatabaseDataModel, - type IDataPresentationActions, - type IDataTableActions, - type IResultSetElementKey, -} from '@cloudbeaver/plugin-data-viewer'; +import type { IDatabaseDataModel, IDataPresentationActions, IDataTableActions, IResultSetElementKey } from '@cloudbeaver/plugin-data-viewer'; import { DataGridContextMenuService } from '../../DataGridContextMenu/DataGridContextMenuService.js'; import styles from './CellMenu.module.css'; diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts index 8eee946fbd..c82f27c91b 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts +++ b/webapp/packages/plugin-data-spreadsheet-new/src/manifest.ts @@ -13,6 +13,7 @@ export const dataSpreadsheetNewManifest: PluginManifest = { () => import('./SpreadsheetBootstrap.js').then(m => m.SpreadsheetBootstrap), () => import('./DataGridSettingsService.js').then(m => m.DataGridSettingsService), () => import('./LocaleService.js').then(m => m.LocaleService), + () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuService.js').then(m => m.DataGridContextMenuService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuOrderService.js').then(m => m.DataGridContextMenuOrderService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuFilter/DataGridContextMenuFilterService.js').then( @@ -20,6 +21,5 @@ export const dataSpreadsheetNewManifest: PluginManifest = { ), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuCellEditingService.js').then(m => m.DataGridContextMenuCellEditingService), () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuSaveContentService.js').then(m => m.DataGridContextMenuSaveContentService), - () => import('./DataGrid/DataGridContextMenu/DataGridContextMenuService.js').then(m => m.DataGridContextMenuService), ], };