mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[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:
parent
363c813e49
commit
247876ad92
5 changed files with 18 additions and 19 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue