mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Discover] Adjust NoData screen (#160747)
- Closes https://github.com/elastic/kibana/issues/150317 ## Summary This PR: - hides "Use without saving" button from NoData screen on Discover page to align with Dashboard and Lens behaviour - allows to open a saved search via URL even if there are no data views present (before NoData screen was shown instead).
This commit is contained in:
parent
6c1ecf9369
commit
91fbd8e9e0
4 changed files with 33 additions and 8 deletions
|
@ -96,6 +96,9 @@ export function DiscoverMainRoute({ customizationCallbacks, isDev }: MainRoutePr
|
|||
|
||||
const checkData = useCallback(async () => {
|
||||
try {
|
||||
if (savedSearchId) {
|
||||
return true; // bypass NoData screen
|
||||
}
|
||||
const hasUserDataViewValue = await data.dataViews.hasData
|
||||
.hasUserDataView()
|
||||
.catch(() => false);
|
||||
|
@ -124,7 +127,7 @@ export function DiscoverMainRoute({ customizationCallbacks, isDev }: MainRoutePr
|
|||
setError(e);
|
||||
return false;
|
||||
}
|
||||
}, [data.dataViews, isDev]);
|
||||
}, [data.dataViews, isDev, savedSearchId]);
|
||||
|
||||
const loadSavedSearch = useCallback(
|
||||
async (nextDataView?: DataView) => {
|
||||
|
@ -221,9 +224,23 @@ export function DiscoverMainRoute({ customizationCallbacks, isDev }: MainRoutePr
|
|||
|
||||
// primary fetch: on initial search + triggered when id changes
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
setHasESData(false);
|
||||
setHasUserDataView(false);
|
||||
setShowNoDataPage(false);
|
||||
setError(undefined);
|
||||
// restore the previously selected data view for a new state
|
||||
loadSavedSearch(!savedSearchId ? stateContainer.internalState.getState().dataView : undefined);
|
||||
}, [loadSavedSearch, savedSearchId, stateContainer]);
|
||||
}, [
|
||||
loadSavedSearch,
|
||||
savedSearchId,
|
||||
stateContainer,
|
||||
setLoading,
|
||||
setHasESData,
|
||||
setHasUserDataView,
|
||||
setShowNoDataPage,
|
||||
setError,
|
||||
]);
|
||||
|
||||
// secondary fetch: in case URL is set to `/`, used to reset to 'new' state, keeping the current data view
|
||||
useUrl({
|
||||
|
@ -255,7 +272,7 @@ export function DiscoverMainRoute({ customizationCallbacks, isDev }: MainRoutePr
|
|||
|
||||
return (
|
||||
<AnalyticsNoDataPageKibanaProvider {...analyticsServices}>
|
||||
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} allowAdHocDataView />
|
||||
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} />
|
||||
</AnalyticsNoDataPageKibanaProvider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ import { useDiscoverServices } from '../../hooks/use_discover_services';
|
|||
export const DiscoverError = ({ error }: { error: Error }) => {
|
||||
const { locator } = useDiscoverServices();
|
||||
|
||||
const goToMain = () => {
|
||||
locator.navigate({});
|
||||
const goToMain = async () => {
|
||||
await locator.navigate({});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.testUser.restoreDefaults();
|
||||
});
|
||||
|
||||
it('should create adhoc data view when there are no data view', async () => {
|
||||
it('should create a data view when there are no data views', async () => {
|
||||
await kibanaServer.uiSettings.replace(defaultSettings);
|
||||
await PageObjects.common.navigateToApp('management');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
|
@ -57,9 +57,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const timestampField = await testSubjects.find('timestampField');
|
||||
return !(await timestampField.elementHasClass('euiComboBox-isDisabled'));
|
||||
});
|
||||
await testSubjects.click('exploreIndexPatternButton');
|
||||
await testSubjects.click('saveIndexPatternButton');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await PageObjects.discover.isAdHocDataViewSelected()).to.be(false);
|
||||
|
||||
await PageObjects.discover.createAdHocDataView('log', true);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
expect(await PageObjects.discover.isAdHocDataViewSelected()).to.be(true);
|
||||
|
||||
expect(await PageObjects.discover.getIndexPatterns()).to.eql(['log*\nTemporary', 'logs*']);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -477,7 +477,9 @@ export class DiscoverPageObject extends FtrService {
|
|||
public async isAdHocDataViewSelected() {
|
||||
const dataView = await this.getCurrentlySelectedDataView();
|
||||
await this.testSubjects.click('discover-dataView-switch-link');
|
||||
return this.testSubjects.exists(`dataViewItemTempBadge-${dataView}`);
|
||||
const hasBadge = await this.testSubjects.exists(`dataViewItemTempBadge-${dataView}`);
|
||||
await this.testSubjects.click('discover-dataView-switch-link');
|
||||
return hasBadge;
|
||||
}
|
||||
|
||||
public async selectIndexPattern(indexPattern: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue