Skip to content

Commit

Permalink
Merge branch 'devel' into CB-3952-navigator-forbidden-symbols-can-be-…
Browse files Browse the repository at this point in the history
…used-for-rename-folder
  • Loading branch information
yagudin10 authored Jan 3, 2024
2 parents 534c465 + 0f25367 commit 28f2888
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { IResultSetBinaryFileValue } from './IResultSetBinaryFileValue';
import type { IResultSetContentValue } from './IResultSetContentValue';

export function isResultSetBinaryFileValue(value: IResultSetContentValue): value is IResultSetBinaryFileValue {
return value.contentType === 'application/octet-stream' && Boolean(value?.binary);
export function isResultSetBinaryFileValue(value: any): value is IResultSetBinaryFileValue {
return value?.contentType === 'application/octet-stream' && Boolean(value?.binary);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { isResultSetContentValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetContentValue';
import { isNotNullDefined } from '@cloudbeaver/core-utils';

import { isResultSetBinaryFileValue } from '../../DatabaseDataModel/Actions/ResultSet/isResultSetBinaryFileValue';
import { ResultSetEditAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetEditAction';
import { ResultSetFormatAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetFormatAction';
import { ResultSetSelectAction } from '../../DatabaseDataModel/Actions/ResultSet/ResultSetSelectAction';
Expand All @@ -25,16 +27,19 @@ export function useTextValue({ model, resultIndex, currentContentType }: IUseTex
const selection = model.source.getAction(resultIndex, ResultSetSelectAction);
const focusCell = selection.getFocusedElement();
const firstSelectedCell = selection.elements?.[0] ?? focusCell;
const autoFormat = !!firstSelectedCell && !editor.isElementEdited(firstSelectedCell);
const formatter = useAutoFormat();

if (!autoFormat) {
return;
if (!isNotNullDefined(firstSelectedCell)) {
return '';
}

if (editor.isElementEdited(firstSelectedCell)) {
return format.getText(firstSelectedCell);
}

const blob = format.get(firstSelectedCell);

if (isResultSetContentValue(blob)) {
if (isResultSetBinaryFileValue(blob)) {
const value = formatter.formatBlob(currentContentType, blob);

if (value) {
Expand Down

0 comments on commit 28f2888

Please sign in to comment.