Skip to content

Commit 157dfca

Browse files
authored
[ES|QL] Small changes in history (#233504)
## Summary Small changes on the recent history component changes 1. Removes the KB info as it doesnt mean anything to the user 2. Removes the helptext on small screens <img width="564" height="628" alt="image" src="https://github.com/user-attachments/assets/86fba59a-aed3-4cbd-9fbf-dcacb14f9b01" /> ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
1 parent 08da8a2 commit 157dfca

File tree

3 files changed

+62
-39
lines changed

3 files changed

+62
-39
lines changed

src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.test.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,28 @@ describe('Starred and History queries components', () => {
279279
);
280280
expect(screen.getByTestId('ESQLEditor-queryHistory')).toBeInTheDocument();
281281
expect(screen.getByTestId('ESQLEditor-history-starred-queries-helpText')).toHaveTextContent(
282-
'Showing 3 queries (1KB used)'
282+
'Showing 3 queries'
283283
);
284284
});
285285

286+
it('should not render the history queries help text for small sized', () => {
287+
render(
288+
<KibanaContextProvider services={services}>
289+
<HistoryAndStarredQueriesTabs
290+
containerCSS={{}}
291+
containerWidth={1024}
292+
isSpaceReduced={true}
293+
onUpdateAndSubmit={jest.fn()}
294+
height={200}
295+
/>
296+
</KibanaContextProvider>
297+
);
298+
expect(screen.getByTestId('ESQLEditor-queryHistory')).toBeInTheDocument();
299+
expect(
300+
screen.queryByTestId('ESQLEditor-history-starred-queries-helpText')
301+
).not.toBeInTheDocument();
302+
});
303+
286304
it('should render the starred queries if the corresponding btn is clicked', () => {
287305
render(
288306
<KibanaContextProvider services={services}>
@@ -446,15 +464,15 @@ describe('Starred and History queries components', () => {
446464

447465
// Initially shows total count
448466
expect(screen.getByTestId('ESQLEditor-history-starred-queries-helpText')).toHaveTextContent(
449-
'Showing 3 queries (1KB used)'
467+
'Showing 3 queries'
450468
);
451469

452470
// Filter to show only 1 result
453471
fireEvent.change(searchInput, { target: { value: 'logs' } });
454472

455473
await waitFor(() => {
456474
expect(screen.getByTestId('ESQLEditor-history-starred-queries-helpText')).toHaveTextContent(
457-
'Showing 1 queries (1KB used)'
475+
'Showing 1 queries'
458476
);
459477
});
460478
});

src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.tsx

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,14 @@ export function QueryColumn({
465465
export function HistoryAndStarredQueriesTabs({
466466
containerCSS,
467467
containerWidth,
468+
isSpaceReduced,
468469
onUpdateAndSubmit,
469470
height,
470471
}: {
471472
containerCSS: Interpolation<Theme>;
472473
containerWidth: number;
473474
onUpdateAndSubmit: (qs: string) => void;
475+
isSpaceReduced?: boolean;
474476
height: number;
475477
}) {
476478
const kibana = useKibana<ESQLEditorDeps>();
@@ -650,41 +652,42 @@ export function HistoryAndStarredQueriesTabs({
650652
</EuiTabs>
651653
<EuiFlexItem grow={false}>
652654
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="s">
653-
<EuiText
654-
size="xs"
655-
color="subdued"
656-
data-test-subj="ESQLEditor-history-starred-queries-helpText"
657-
>
658-
<p>
659-
{selectedTabId === 'history-queries-tab'
660-
? (() => {
661-
const stats = getStorageStats();
662-
const displayCount = searchQuery.trim()
663-
? filteredHistoryItems.length
664-
: stats.queryCount;
665-
return i18n.translate('esqlEditor.history.historyItemsStorage', {
666-
defaultMessage: 'Showing {queryCount} queries ({storageSizeKB}KB used)',
667-
values: {
668-
queryCount: displayCount,
669-
storageSizeKB: stats.storageSizeKB,
670-
},
671-
});
672-
})()
673-
: (() => {
674-
const displayCount = starredSearchQuery.trim()
675-
? filteredStarredQueries.length
676-
: starredQueries.length;
677-
return i18n.translate('esqlEditor.history.starredItemslimit', {
678-
defaultMessage:
679-
'Showing {starredItemsCount} queries (max {starredItemsLimit})',
680-
values: {
681-
starredItemsLimit: ESQL_STARRED_QUERIES_LIMIT,
682-
starredItemsCount: displayCount ?? 0,
683-
},
684-
});
685-
})()}
686-
</p>
687-
</EuiText>
655+
{!isSpaceReduced && (
656+
<EuiText
657+
size="xs"
658+
color="subdued"
659+
data-test-subj="ESQLEditor-history-starred-queries-helpText"
660+
>
661+
<p>
662+
{selectedTabId === 'history-queries-tab'
663+
? (() => {
664+
const stats = getStorageStats();
665+
const displayCount = searchQuery.trim()
666+
? filteredHistoryItems.length
667+
: stats.queryCount;
668+
return i18n.translate('esqlEditor.history.historyItemsStorage', {
669+
defaultMessage: 'Showing {queryCount} queries',
670+
values: {
671+
queryCount: displayCount,
672+
},
673+
});
674+
})()
675+
: (() => {
676+
const displayCount = starredSearchQuery.trim()
677+
? filteredStarredQueries.length
678+
: starredQueries.length;
679+
return i18n.translate('esqlEditor.history.starredItemslimit', {
680+
defaultMessage:
681+
'Showing {starredItemsCount} queries (max {starredItemsLimit})',
682+
values: {
683+
starredItemsLimit: ESQL_STARRED_QUERIES_LIMIT,
684+
starredItemsCount: displayCount ?? 0,
685+
},
686+
});
687+
})()}
688+
</p>
689+
</EuiText>
690+
)}
688691
{selectedTabId === 'history-queries-tab' && (
689692
<EuiFlexItem grow={false}>
690693
<EuiFieldSearch
@@ -696,7 +699,8 @@ export function HistoryAndStarredQueriesTabs({
696699
onChange={(e) => setSearchQuery(e.target.value)}
697700
data-test-subj="ESQLEditor-history-search"
698701
css={css`
699-
width: 400px;
702+
max-width: 400px;
703+
width: ${isSpaceReduced ? '100%' : '400px'};
700704
`}
701705
/>
702706
</EuiFlexItem>

src/platform/packages/private/kbn-esql-editor/src/editor_footer/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export const EditorFooter = memo(function EditorFooter({
336336
onUpdateAndSubmit={onUpdateAndSubmit}
337337
containerWidth={measuredContainerWidth}
338338
height={resizableContainerHeight}
339+
isSpaceReduced={isSpaceReduced}
339340
/>
340341
</EuiFlexItem>
341342
)}

0 commit comments

Comments
 (0)