[No Data] Allow access to the app if there are user created data views (#134068)

* [No Data] Allow access to the app if there are user created data views

* Update the checks

* Merge main

* Simplify boolean logic

* Fix Discover test

* Move call to top in Discover

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Maja Grubic 2022-06-13 20:31:25 +02:00 committed by GitHub
parent 363c813e49
commit 247876ad92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 19 deletions

View file

@ -48,10 +48,6 @@ export const KibanaNoDataPage = ({ onDataViewCreated, noDataConfig }: Props) =>
return <EuiLoadingElastic css={{ margin: 'auto' }} size="xxl" />;
}
if (!dataExists) {
return <NoDataConfigPage noDataConfig={noDataConfig} />;
}
/*
TODO: clintandrewhall - the use and population of `NoDataViewPromptProvider` here is temporary,
until `KibanaNoDataPage` is moved to a package of its own.
@ -60,7 +56,7 @@ export const KibanaNoDataPage = ({ onDataViewCreated, noDataConfig }: Props) =>
with `KibanaNoDataPageProvider`, creating a single Provider that manages contextual dependencies
throughout the React tree from the top-level of composition and consumption.
*/
if (!hasUserDataViews) {
if (!hasUserDataViews && dataExists) {
const services: NoDataViewsPromptServices = {
canCreateNewDataView,
dataViewsDocLink,
@ -74,5 +70,9 @@ export const KibanaNoDataPage = ({ onDataViewCreated, noDataConfig }: Props) =>
);
}
if (!dataExists) {
return <NoDataConfigPage noDataConfig={noDataConfig} />;
}
return null;
};

View file

@ -42,6 +42,5 @@ export const isDashboardAppInNoDataState = async (
dataViews: DataPublicPluginStart['dataViews']
) => {
const hasUserDataView = await dataViews.hasData.hasUserDataView().catch(() => false);
const hasEsData = await dataViews.hasData.hasESData().catch(() => true);
return !hasUserDataView || !hasEsData;
return !hasUserDataView;
};

View file

@ -79,13 +79,12 @@ export function DiscoverMainRoute(props: Props) {
const hasUserDataViewValue = await data.dataViews.hasData
.hasUserDataView()
.catch(() => false);
const hasESDataValue =
isDev || (await data.dataViews.hasData.hasESData().catch(() => false));
setHasUserDataView(hasUserDataViewValue);
setHasESData(hasESDataValue);
if (!hasUserDataViewValue || !hasESDataValue) {
if (!hasUserDataViewValue) {
setShowNoDataPage(true);
return;
}

View file

@ -90,15 +90,17 @@ export const VisualizeApp = ({ onAppLeave }: VisualizeAppProps) => {
const checkESOrDataViewExist = async () => {
// check if there is any data view or data source
const hasUserDataView = await dataViews.hasData.hasUserDataView().catch(() => false);
const hasEsData = await dataViews.hasData.hasESData().catch(() => false);
if (!hasUserDataView || !hasEsData) {
setShowNoDataPage(true);
}
// Adding this check as TSVB asks for the default dataview on initialization
const defaultDataView = await dataViews.getDefaultDataView();
if (!defaultDataView) {
setShowNoDataPage(true);
if (hasUserDataView) {
// Adding this check as TSVB asks for the default dataview on initialization
const defaultDataView = await dataViews.getDefaultDataView();
if (!defaultDataView) {
setShowNoDataPage(true);
}
setIsLoading(false);
return;
}
setShowNoDataPage(true);
setIsLoading(false);
};

View file

@ -243,8 +243,7 @@ export async function mountApp(
useEffect(() => {
(async () => {
const hasUserDataView = await data.dataViews.hasData.hasUserDataView().catch(() => false);
const hasEsData = await data.dataViews.hasData.hasESData().catch(() => true);
if (!hasUserDataView || !hasEsData) {
if (!hasUserDataView) {
setEditorState('no_data');
return;
}