Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4851 add hardlimit for show more button content in text presentation #2537

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import type { IDatabaseResultSet } from '../../DatabaseDataModel/IDatabaseResult
import { QuotaPlaceholder } from '../QuotaPlaceholder';
import { MAX_BLOB_PREVIEW_SIZE } from './MAX_BLOB_PREVIEW_SIZE';

const MAX_TEXT_CONTENT_SIZE = 1 * 1048576;

interface Props {
resultIndex: number;
model: IDatabaseDataModel<any, IDatabaseResultSet>;
Expand All @@ -44,9 +46,8 @@ export const TextValueTruncatedMessage = observer<Props>(function TextValueTrunc
return null;
}
const isTextColumn = formatAction.isText(elementKey);

const valueSize =
isResultSetContentValue(contentValue) && isNotNullDefined(contentValue.contentLength) ? bytesToSize(contentValue.contentLength) : undefined;
const valueSize = isResultSetContentValue(contentValue) && isNotNullDefined(contentValue.contentLength) ? contentValue.contentLength : undefined;
const canShowMore = valueSize ? valueSize <= MAX_TEXT_CONTENT_SIZE : true;

async function pasteFullText() {
try {
Expand All @@ -58,10 +59,11 @@ export const TextValueTruncatedMessage = observer<Props>(function TextValueTrunc

return (
<QuotaPlaceholder model={model} resultIndex={resultIndex} elementKey={elementKey} keepSize>
{isTextColumn && (
{isTextColumn && canShowMore && (
<Container keepSize>
<Button disabled={model.isLoading()} onClick={pasteFullText}>
{`${translate('ui_show_more')} (${valueSize})`}
{translate('ui_show_more')}
{valueSize ? ` (${bytesToSize(valueSize)})` : ''}
</Button>
</Container>
)}
Expand Down
Loading