From d5df008e890d1eaec2f79cb54c22ca6fae7675b6 Mon Sep 17 00:00:00 2001 From: "s.teleshev" Date: Thu, 8 Feb 2024 10:52:46 +0100 Subject: [PATCH] Revert "CB-4570 fix: show quota placeholder correctly" This reverts commit d86b35e47ac11053c332d977d2af4e0b13827eff. --- .../ResultSet/IResultSetDataContentAction.ts | 3 +- .../ResultSet/ResultSetDataContentAction.ts | 19 +++------- .../ImageValue/ImageValuePresentation.tsx | 35 ++++++++++--------- .../QuotaPlaceholder.tsx | 4 +++ .../TextValue/TextValuePresentation.tsx | 22 ++++++------ 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts index a584941cf6..95e2c1591d 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/IResultSetDataContentAction.ts @@ -9,8 +9,7 @@ import type { IResultSetElementKey } from './IResultSetDataKey'; export interface IResultSetDataContentAction { activeElement: IResultSetElementKey | null; - isImageTruncated: (element: IResultSetElementKey) => boolean; - isTextTruncated: (element: IResultSetElementKey) => boolean; + isContentTruncated: (element: IResultSetElementKey) => boolean; isDownloadable: (element: IResultSetElementKey) => boolean; getFileDataUrl: (element: IResultSetElementKey) => Promise; resolveFileDataUrl: (element: IResultSetElementKey) => Promise; diff --git a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts index c57c4417ee..4f6e40462a 100644 --- a/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts +++ b/webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetDataContentAction.ts @@ -79,26 +79,15 @@ export class ResultSetDataContentAction extends DatabaseDataAction limit; - } - - isTextTruncated(elementKey: IResultSetElementKey) { + isContentTruncated(elementKey: IResultSetElementKey) { const limit = this.getLimitInfo(elementKey).limit; const content = this.format.get(elementKey); const cachedFullText = this.retrieveFileFullTextFromCache(elementKey); const isLoadedFullText = Boolean(cachedFullText) && this.format.isText(elementKey); + const cachedImage = elementKey ? this.retrieveFileDataUrlFromCache(elementKey) : ''; + const isLoadedFullImage = Boolean(cachedImage) && this.format.isBinary(elementKey); - if (!isNotNullDefined(limit) || !isResultSetContentValue(content) || isLoadedFullText) { + if (!isNotNullDefined(limit) || !isResultSetContentValue(content) || isLoadedFullText || isLoadedFullImage) { return false; } diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx index 73b443bf18..6f8d1def8f 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/ImageValue/ImageValuePresentation.tsx @@ -154,7 +154,11 @@ export const ImageValuePresentation: TabContainerPanelComponent {data.shouldShowImage && } - {data.truncated ? ( - - {isDownloadable && ( - - )} - - ) : null} + + {isDownloadable && ( + + )} + diff --git a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx index 88c39b8b8a..ff1615b7ab 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/QuotaPlaceholder.tsx @@ -38,6 +38,10 @@ export const QuotaPlaceholder: React.FC> = observ const { contentAction } = useResultSetActions({ model, resultIndex }); const limitInfo = elementKey ? contentAction.getLimitInfo(elementKey) : null; + if (!elementKey || (elementKey && !contentAction.isContentTruncated(elementKey))) { + return null; + } + return ( 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 739402f509..85f7223680 100644 --- a/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx +++ b/webapp/packages/plugin-data-viewer/src/ValuePanelPresentation/TextValue/TextValuePresentation.tsx @@ -125,7 +125,7 @@ export const TextValuePresentation: TabContainerPanelComponent getTypeExtension(contentType!) ?? [], [contentType]); const extensions = useCodemirrorExtensions(undefined, typeExtension); @@ -185,17 +185,15 @@ export const TextValuePresentation: TabContainerPanelComponent - {firstSelectedCell && contentAction.isTextTruncated(firstSelectedCell) ? ( - - {shouldShowPasteButton && ( - - - - )} - - ) : null} + + {shouldShowPasteButton && ( + + + + )} + {canSave && (