mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
feat: CB-2212 add resultIndex parameter to isReadonly method
This commit is contained in:
+3
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export const DataGridTable = observer<IDataPresentationProps<any, IDatabaseResul
|
||||
const focusSyncRef = useRef<CellPosition | null>(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);
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ export const TableColumnHeader = observer<HeaderRendererProps<any>>(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
|
||||
);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ export const TableIndexColumnHeader = observer<HeaderRendererProps<any>>(functio
|
||||
|
||||
const readonly = getComputed(() => (
|
||||
tableDataContext.isReadOnly()
|
||||
|| dataGridContext.model.isReadonly()
|
||||
|| dataGridContext.model.isReadonly(dataGridContext.resultIndex)
|
||||
));
|
||||
|
||||
function handleClick(event: React.MouseEvent<HTMLButtonElement>) {
|
||||
|
||||
@@ -47,8 +47,8 @@ export class ContainerDataSource extends DatabaseDataSource<IDataContainerOption
|
||||
});
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
return super.isReadonly() || this.getResult(0)?.data?.hasRowIdentifier === false;
|
||||
isReadonly(resultIndex: number): boolean {
|
||||
return super.isReadonly(resultIndex) || this.getResult(resultIndex)?.data?.hasRowIdentifier === false;
|
||||
}
|
||||
|
||||
isDisabled(resultIndex: number): boolean {
|
||||
|
||||
@@ -58,8 +58,8 @@ implements IDatabaseDataModel<TOptions, TResult> {
|
||||
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<TOptions, TResult> {
|
||||
return this.source.getResult(index);
|
||||
}
|
||||
|
||||
setName(name: string | null){
|
||||
setName(name: string | null) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ implements IDatabaseDataModel<TOptions, TResult> {
|
||||
async requestOptionsChange(): Promise<boolean> {
|
||||
const contexts = await this.onOptionsChange.execute();
|
||||
|
||||
return ExecutorInterrupter.isInterrupted(contexts) === false;
|
||||
return !ExecutorInterrupter.isInterrupted(contexts);
|
||||
}
|
||||
|
||||
async save(): Promise<void> {
|
||||
|
||||
@@ -177,7 +177,7 @@ implements IDatabaseDataSource<TOptions, TResult> {
|
||||
return this;
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
isReadonly(resultIndex: number): boolean {
|
||||
return this.access === DatabaseDataAccessMode.Readonly
|
||||
|| this.results.length > 1
|
||||
|| !this.executionContext?.context
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface IDatabaseDataModel<TOptions = any, TResult extends IDatabaseDat
|
||||
readonly onRequest: IExecutor<IRequestEventData<TOptions, TResult>>;
|
||||
|
||||
setName: (name: string | null) => this;
|
||||
isReadonly: () => boolean;
|
||||
isReadonly: (resultIndex: number) => boolean;
|
||||
isDisabled: (resultIndex: number) => boolean;
|
||||
isLoading: () => boolean;
|
||||
isDataAvailable: (offset: number, count: number) => boolean;
|
||||
|
||||
@@ -43,7 +43,7 @@ export interface IDatabaseDataSource<TOptions, TResult extends IDatabaseDataResu
|
||||
readonly canCancel: boolean;
|
||||
readonly serviceInjector: IServiceInjector;
|
||||
|
||||
isReadonly: () => boolean;
|
||||
isReadonly: (resultIndex: number) => boolean;
|
||||
isLoading: () => boolean;
|
||||
isDisabled: (resultIndex: number) => boolean;
|
||||
|
||||
|
||||
+6
-6
@@ -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 (
|
||||
|
||||
+4
-2
@@ -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<IDataValuePane
|
||||
|
||||
const column = view.getColumn(firstSelectedCell.column);
|
||||
const nullable = column?.required === false;
|
||||
const readonly = model.isReadonly() || model.isDisabled(resultIndex) || format.isReadOnly(firstSelectedCell);
|
||||
const readonly = model.isReadonly(resultIndex)
|
||||
|| model.isDisabled(resultIndex)
|
||||
|| format.isReadOnly(firstSelectedCell);
|
||||
|
||||
return styled(styles)(
|
||||
<container>
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ export const TextValuePresentation: TabContainerPanelComponent<IDataValuePanelPr
|
||||
}
|
||||
}
|
||||
|
||||
readonly = model.isReadonly() || model.isDisabled(resultIndex) || readonly;
|
||||
readonly = model.isReadonly(resultIndex) || model.isDisabled(resultIndex) || readonly;
|
||||
|
||||
if (contentType !== state.lastContentType) {
|
||||
state.setDefaultContentType(contentType);
|
||||
|
||||
@@ -109,7 +109,7 @@ export class MenuBootstrap extends Bootstrap {
|
||||
return context.contextType === TableFooterMenuService.nodeContextType;
|
||||
},
|
||||
isHidden(context) {
|
||||
return context.data.model.isReadonly()
|
||||
return context.data.model.isReadonly(context.data.resultIndex)
|
||||
|| context.data.model.source.getResult(context.data.resultIndex)?.dataFormat !== ResultDataFormat.Resultset;
|
||||
},
|
||||
isDisabled(context) {
|
||||
|
||||
@@ -51,8 +51,8 @@ export class QueryDataSource extends DatabaseDataSource<IDataQueryOptions, IData
|
||||
});
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
return super.isReadonly() || this.getResult(0)?.data?.hasRowIdentifier === false;
|
||||
isReadonly(resultIndex: number): boolean {
|
||||
return super.isReadonly(resultIndex) || this.getResult(resultIndex)?.data?.hasRowIdentifier === false;
|
||||
}
|
||||
|
||||
isDisabled(resultIndex: number): boolean {
|
||||
|
||||
Reference in New Issue
Block a user