Skip to content

Commit

Permalink
Fix/cb-3823/typescript-error (#2784)
Browse files Browse the repository at this point in the history
* CB-5134 fix: typescript error

* CB-5134 fix: typescript error
  • Loading branch information
Wroud authored Jul 16, 2024
1 parent b48684b commit 75fdc2b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DataImportBootstrap extends Bootstrap {
return action.info;
},
handler: async (context, action) => {
const model = context.get(DATA_CONTEXT_DV_DDM)!;
const model = context.get(DATA_CONTEXT_DV_DDM)! as any;
const resultIndex = context.get(DATA_CONTEXT_DV_DDM_RESULT_INDEX)!;

if (!isResultSetDataModel(model)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export class DVResultSetGroupingPluginBootstrap extends Bootstrap {
icon: '/icons/plugin_data_viewer_result_set_grouping_m.svg',
dataFormat: ResultDataFormat.Resultset,
hidden: (dataFormat, model, resultIndex) => {
const source = model.source;
if (!source.hasResult(resultIndex) || !isResultSetDataSource(source)) {
const source = model.source as any;
if (!isResultSetDataSource(source) || !source.hasResult(resultIndex)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import { useGroupingDataModel } from './useGroupingDataModel';
import { useGroupingDnDColumns } from './useGroupingDnDColumns';

export const DVResultSetGroupingPresentation: DataPresentationComponent = observer(function DVResultSetGroupingPresentation({
model: originalModel,
model: unknownModel,
resultIndex,
}) {
const originalModel = unknownModel as any;
if (!isResultSetDataModel(originalModel)) {
throw new Error('DVResultSetGroupingPresentation can only be used with ResultSetDataSource');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { s, useS, useTranslate } from '@cloudbeaver/core-blocks';

import type { IDatabaseDataModel } from '../DatabaseDataModel/IDatabaseDataModel';
import { IDatabaseResultSet } from '../DatabaseDataModel/IDatabaseResultSet';
import { isResultSetDataSource } from '../ResultSet/ResultSetDataSource';
import { isResultSetDataSource, ResultSetDataSource } from '../ResultSet/ResultSetDataSource';
import classes from './TableStatistics.module.css';

interface Props {
Expand All @@ -26,7 +26,7 @@ export const TableStatistics = observer<Props>(function TableStatistics({ model,
let updatedRows: number | null = null;

if (isResultSetDataSource(source)) {
const result = source.getResult(resultIndex) as IDatabaseResultSet | null;
const result = (source as ResultSetDataSource).getResult(resultIndex) as IDatabaseResultSet | null;
updatedRows = result?.updateRowCount ?? null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ export const TableViewer = observer<TableViewerProps, HTMLDivElement>(

const localActions = useObjectRef({
clearConstraints() {
if (!isResultSetDataModel<IDatabaseDataOptions>(dataModel)) {
const unknownModel = dataModel as any;
if (!isResultSetDataModel<IDatabaseDataOptions>(unknownModel)) {
return;
}

const constraints = dataModel?.source.tryGetAction(resultIndex, DatabaseDataConstraintAction);
const constraints = unknownModel?.source.tryGetAction(resultIndex, DatabaseDataConstraintAction);

if (constraints) {
constraints.deleteAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import styles from './ImageValuePresentation.module.css';
import { useValuePanelImageValue } from './useValuePanelImageValue';

export const ImageValuePresentation: TabContainerPanelComponent<IDataValuePanelProps> = observer(function ImageValuePresentation({
model,
model: unknownModel,
resultIndex,
}) {
const model = unknownModel as any;
if (!isResultSetDataModel(model)) {
throw new Error('ImageValuePresentation can be used only with ResultSetDataSource');
}
Expand Down
3 changes: 2 additions & 1 deletion webapp/packages/plugin-gis-viewer/src/GISViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { type IDataValuePanelProps, isResultSetDataModel } from '@cloudbeaver/pl

import { GISValuePresentation } from './GISValuePresentation';

export const GISViewer: TabContainerPanelComponent<IDataValuePanelProps> = function GISViewer({ model, resultIndex }) {
export const GISViewer: TabContainerPanelComponent<IDataValuePanelProps> = function GISViewer({ model: unknownModel, resultIndex }) {
const model = unknownModel as any;
if (!isResultSetDataModel(model)) {
throw new Error('GISViewer can only be used with ResultSetDataSource');
}
Expand Down

0 comments on commit 75fdc2b

Please sign in to comment.