From ccd864470c19b69987fb23c73cfeaa127a2c7c31 Mon Sep 17 00:00:00 2001 From: Konstantin Vasilev Date: Mon, 15 Aug 2022 15:20:15 +0300 Subject: [PATCH] feat: CB-2212 add resultIndex parameter to isReadonly method --- .../DataGridContextMenuCellEditingService.ts | 6 +++--- .../src/DataGrid/DataGridTable.tsx | 2 +- .../DataGrid/TableColumnHeader/TableColumnHeader.tsx | 2 +- .../TableColumnHeader/TableIndexColumnHeader.tsx | 2 +- .../plugin-data-viewer/src/ContainerDataSource.ts | 4 ++-- .../src/DatabaseDataModel/DatabaseDataModel.ts | 8 ++++---- .../src/DatabaseDataModel/DatabaseDataSource.ts | 2 +- .../src/DatabaseDataModel/IDatabaseDataModel.ts | 2 +- .../src/DatabaseDataModel/IDatabaseDataSource.ts | 2 +- .../TableFooterMenu/TableFooterMenuService.ts | 12 ++++++------ .../BooleanValue/BooleanValuePresentation.tsx | 6 ++++-- .../TextValue/TextValuePresentation.tsx | 2 +- .../packages/plugin-sql-editor/src/MenuBootstrap.ts | 2 +- .../plugin-sql-editor/src/QueryDataSource.ts | 4 ++-- 14 files changed, 29 insertions(+), 27 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 9418389770..4524dd341c 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 @@ -37,7 +37,7 @@ export class DataGridContextMenuCellEditingService { }, isHidden(context) { return context.data.model.isDisabled(context.data.resultIndex) - || context.data.model.isReadonly(); + || context.data.model.isReadonly(context.data.resultIndex); }, } ); @@ -149,7 +149,7 @@ export class DataGridContextMenuCellEditingService { isHidden(context) { const editor = context.data.model.source.getAction(context.data.resultIndex, ResultSetEditAction); - if (context.data.model.isReadonly() || !editor.hasFeature('delete')) { + if (context.data.model.isReadonly(context.data.resultIndex) || !editor.hasFeature('delete')) { return true; } @@ -178,7 +178,7 @@ export class DataGridContextMenuCellEditingService { isHidden(context) { const editor = context.data.model.source.getAction(context.data.resultIndex, ResultSetEditAction); - if (context.data.model.isReadonly() || !editor.hasFeature('delete')) { + if (context.data.model.isReadonly(context.data.resultIndex) || !editor.hasFeature('delete')) { return true; } diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx index c5d7e9abad..ab81704011 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx @@ -71,7 +71,7 @@ export const DataGridTable = observer(null); const editingContext = useEditing({ - readonly: model.isReadonly() || model.isDisabled(resultIndex), + readonly: model.isReadonly(resultIndex) || model.isDisabled(resultIndex), onEdit: (position, code, key) => { const column = tableData.getColumn(position.idx); const row = tableData.getRow(position.rowIdx); diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableColumnHeader.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableColumnHeader.tsx index 2ba913558b..f09f40ce14 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableColumnHeader.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableColumnHeader.tsx @@ -70,7 +70,7 @@ export const TableColumnHeader = observer>(function Tab const resultIndex = dataGridContext.resultIndex; const model = dataGridContext.model; - const dataReadonly = getComputed(() => tableDataContext.isReadOnly() || model.isReadonly()); + const dataReadonly = getComputed(() => tableDataContext.isReadOnly() || model.isReadonly(resultIndex)); const sortingDisabled = getComputed( () => !tableDataContext.constraints.supported || !model.source.executionContext?.context ); diff --git a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableIndexColumnHeader.tsx b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableIndexColumnHeader.tsx index 9d0c9ed56c..748269ef47 100644 --- a/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableIndexColumnHeader.tsx +++ b/webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/TableColumnHeader/TableIndexColumnHeader.tsx @@ -45,7 +45,7 @@ export const TableIndexColumnHeader = observer>(functio const readonly = getComputed(() => ( tableDataContext.isReadOnly() - || dataGridContext.model.isReadonly() + || dataGridContext.model.isReadonly(dataGridContext.resultIndex) )); function handleClick(event: React.MouseEvent) { diff --git a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts index 6c7badfee1..00bab0a085 100644 --- a/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/ContainerDataSource.ts @@ -47,8 +47,8 @@ export class ContainerDataSource extends DatabaseDataSource { return this.source.isDisabled(resultIndex); } - isReadonly(): boolean { - return this.source.isReadonly(); + isReadonly(resultIndex: number): boolean { + return this.source.isReadonly(resultIndex); } isDataAvailable(offset: number, count: number): boolean { @@ -74,7 +74,7 @@ implements IDatabaseDataModel { return this.source.getResult(index); } - setName(name: string | null){ + setName(name: string | null) { this.name = name; return this; } @@ -117,7 +117,7 @@ implements IDatabaseDataModel { async requestOptionsChange(): Promise { const contexts = await this.onOptionsChange.execute(); - return ExecutorInterrupter.isInterrupted(contexts) === false; + return !ExecutorInterrupter.isInterrupted(contexts); } async save(): Promise { diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts index 178f4504b4..edb4488bd3 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/DatabaseDataSource.ts @@ -177,7 +177,7 @@ implements IDatabaseDataSource { return this; } - isReadonly(): boolean { + isReadonly(resultIndex: number): boolean { return this.access === DatabaseDataAccessMode.Readonly || this.results.length > 1 || !this.executionContext?.context diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts index f60a808787..b5b6e7b3c9 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataModel.ts @@ -29,7 +29,7 @@ export interface IDatabaseDataModel>; setName: (name: string | null) => this; - isReadonly: () => boolean; + isReadonly: (resultIndex: number) => boolean; isDisabled: (resultIndex: number) => boolean; isLoading: () => boolean; isDataAvailable: (offset: number, count: number) => boolean; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts index 8ae2c01413..e289068544 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/IDatabaseDataSource.ts @@ -43,7 +43,7 @@ export interface IDatabaseDataSource boolean; + isReadonly: (resultIndex: number) => boolean; isLoading: () => boolean; isDisabled: (resultIndex: number) => boolean; diff --git a/webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts b/webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts index 0164aab3eb..9363f89ed0 100644 --- a/webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts +++ b/webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts @@ -40,7 +40,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - if (context.data.model.isReadonly()) { + if (context.data.model.isReadonly(context.data.resultIndex)) { return true; } @@ -85,7 +85,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - if (context.data.model.isReadonly()) { + if (context.data.model.isReadonly(context.data.resultIndex)) { return true; } @@ -133,7 +133,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - if (context.data.model.isReadonly()) { + if (context.data.model.isReadonly(context.data.resultIndex)) { return true; } @@ -190,7 +190,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - if (context.data.model.isReadonly()) { + if (context.data.model.isReadonly(context.data.resultIndex)) { return true; } @@ -251,7 +251,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - return context.data.model.isReadonly(); + return context.data.model.isReadonly(context.data.resultIndex); }, isDisabled(context) { if ( @@ -282,7 +282,7 @@ export class TableFooterMenuService { return context.contextType === TableFooterMenuService.nodeContextType; }, isHidden(context) { - return context.data.model.isReadonly(); + return context.data.model.isReadonly(context.data.resultIndex); }, isDisabled(context) { if ( diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/BooleanValue/BooleanValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/BooleanValue/BooleanValuePresentation.tsx index 45f1ac35fc..e987c4fc68 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/BooleanValue/BooleanValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/BooleanValue/BooleanValuePresentation.tsx @@ -9,9 +9,9 @@ import { observer } from 'mobx-react-lite'; import styled, { css } from 'reshadow'; -import type { TabContainerPanelComponent } from '@cloudbeaver/core-ui'; import { Radio, TextPlaceholder } from '@cloudbeaver/core-blocks'; import { useTranslate } from '@cloudbeaver/core-localization'; +import type { TabContainerPanelComponent } from '@cloudbeaver/core-ui'; import { ResultSetEditAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetEditAction'; import { ResultSetFormatAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction'; @@ -65,7 +65,9 @@ export const BooleanValuePresentation: TabContainerPanelComponent diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx index 24b1055d90..cb13757ff8 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx @@ -147,7 +147,7 @@ export const TextValuePresentation: TabContainerPanelComponent