mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Textbased] Depict histogram for timebased adhoc dataviews (#161524)
## Summary
Part of https://github.com/elastic/kibana/issues/158802
We decided that in the case we don't render a Lens suggestion (for
example when we have the SELECT * case) to render the histogram.
**Reminder**: Histogram makes sense only of there is a time field. For
text based mode, time field exists **ONLY** if there is the @timestamp
field.
I don't allow navigation to Lens or open the edit flyout in this case.
When the edit flyout allows the editing of the form based visualizations
(such as histogram) I will enable it then.
FTs have been changed to accomodate this change.
<img width="1751" alt="image"
src="3d28d881
-bc60-43de-acf8-8cbcd172a3df">
### Checklist
- [x] [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
This commit is contained in:
parent
91a0d2f454
commit
f8ef18a26b
7 changed files with 23 additions and 20 deletions
|
@ -244,6 +244,17 @@ describe('Chart', () => {
|
|||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not render the edit on the fly button when chart is visible and suggestions dont exist', async () => {
|
||||
const component = await mountComponent({
|
||||
currentSuggestion: undefined,
|
||||
allSuggestions: undefined,
|
||||
isPlainRecord: true,
|
||||
});
|
||||
expect(
|
||||
component.find('[data-test-subj="unifiedHistogramEditFlyoutVisualization"]').exists()
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should render the save button when chart is visible and suggestions exist', async () => {
|
||||
const component = await mountComponent({
|
||||
currentSuggestion: currentSuggestionMock,
|
||||
|
|
|
@ -275,7 +275,7 @@ export function Chart({
|
|||
[isFlyoutVisible]
|
||||
);
|
||||
|
||||
const canEditVisualizationOnTheFly = isPlainRecord && chartVisible;
|
||||
const canEditVisualizationOnTheFly = currentSuggestion && chartVisible;
|
||||
|
||||
return (
|
||||
<EuiFlexGroup
|
||||
|
@ -438,6 +438,7 @@ export function Chart({
|
|||
disableTriggers={disableTriggers}
|
||||
disabledActions={disabledActions}
|
||||
onTotalHitsChange={onTotalHitsChange}
|
||||
hasLensSuggestions={Boolean(currentSuggestion)}
|
||||
onChartLoad={onChartLoad}
|
||||
onFilter={onFilter}
|
||||
onBrushEnd={onBrushEnd}
|
||||
|
|
|
@ -51,6 +51,7 @@ function mountComponent() {
|
|||
request: {
|
||||
searchSessionId: '123',
|
||||
},
|
||||
hasLensSuggestions: false,
|
||||
hits: {
|
||||
status: UnifiedHistogramFetchStatus.loading,
|
||||
total: undefined,
|
||||
|
|
|
@ -40,6 +40,7 @@ export interface HistogramProps {
|
|||
hits?: UnifiedHistogramHitsContext;
|
||||
chart: UnifiedHistogramChartContext;
|
||||
isPlainRecord?: boolean;
|
||||
hasLensSuggestions: boolean;
|
||||
getTimeRange: () => TimeRange;
|
||||
refetch$: Observable<UnifiedHistogramInputMessage>;
|
||||
lensAttributesContext: LensAttributesContext;
|
||||
|
@ -58,6 +59,7 @@ export function Histogram({
|
|||
hits,
|
||||
chart: { timeInterval },
|
||||
isPlainRecord,
|
||||
hasLensSuggestions,
|
||||
getTimeRange,
|
||||
refetch$,
|
||||
lensAttributesContext: attributesContext,
|
||||
|
@ -109,9 +111,10 @@ export function Histogram({
|
|||
}
|
||||
|
||||
const adapterTables = adapters?.tables?.tables;
|
||||
const totalHits = isPlainRecord
|
||||
? Object.values(adapterTables ?? {})?.[0]?.rows?.length
|
||||
: adapterTables?.unifiedHistogram?.meta?.statistics?.totalCount;
|
||||
const totalHits =
|
||||
isPlainRecord && hasLensSuggestions
|
||||
? Object.values(adapterTables ?? {})?.[0]?.rows?.length
|
||||
: adapterTables?.unifiedHistogram?.meta?.statistics?.totalCount;
|
||||
|
||||
onTotalHitsChange?.(
|
||||
isLoading ? UnifiedHistogramFetchStatus.loading : UnifiedHistogramFetchStatus.complete,
|
||||
|
|
|
@ -69,7 +69,7 @@ export const useLensSuggestions = ({
|
|||
return {
|
||||
allSuggestions,
|
||||
currentSuggestion,
|
||||
suggestionUnsupported: isPlainRecord && !currentSuggestion,
|
||||
suggestionUnsupported: !dataView.isTimeBased(),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
expect(await testSubjects.exists('showQueryBarMenu')).to.be(false);
|
||||
expect(await testSubjects.exists('addFilter')).to.be(false);
|
||||
expect(await testSubjects.exists('dscViewModeDocumentButton')).to.be(false);
|
||||
// here Lens suggests a table so the chart is not rendered
|
||||
expect(await testSubjects.exists('unifiedHistogramChart')).to.be(false);
|
||||
// when Lens suggests a table, we render the histogram
|
||||
expect(await testSubjects.exists('unifiedHistogramChart')).to.be(true);
|
||||
expect(await testSubjects.exists('unifiedHistogramQueryHits')).to.be(true);
|
||||
expect(await testSubjects.exists('discoverAlertsButton')).to.be(false);
|
||||
expect(await testSubjects.exists('shareTopNavButton')).to.be(true);
|
||||
|
|
|
@ -131,19 +131,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
|
||||
expect(searchesCountBeforeRestore).to.be(searchesCountAfterRestore); // no new searches started during restore
|
||||
});
|
||||
|
||||
it('should should clean the search session when navigating to SQL mode, and reinitialize when navigating back', async () => {
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await searchSessions.exists()).to.be(true);
|
||||
await PageObjects.discover.selectTextBaseLang('SQL');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
await searchSessions.missingOrFail();
|
||||
await browser.goBack();
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await searchSessions.exists()).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
async function getSearchSessionId(): Promise<string> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue