-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard] Add Analytics No Data Page #132188
Changes from 8 commits
e596100
996f915
a917c2a
fe2e291
f225c59
8b52d97
405cf21
7e2e665
fe2cbb1
4d695a7
01dc098
c8b6d1b
37a1afe
fdc03d2
ba9bdeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"requiredPlugins": [ | ||
"data", | ||
"dataViews", | ||
"dataViewEditor", | ||
"embeddable", | ||
"controls", | ||
"inspector", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
AnalyticsNoDataPageKibanaProvider, | ||
AnalyticsNoDataPage, | ||
} from '@kbn/shared-ux-page-analytics-no-data'; | ||
import { DataPublicPluginStart } from '@kbn/data-plugin/public'; | ||
|
||
import { DashboardAppServices } from '../types'; | ||
import { useKibana } from '../services/kibana_react'; | ||
|
||
export const DashboardAppEmpty = ({ onDataViewCreated }: { onDataViewCreated: () => void }) => { | ||
const { | ||
services: { core, data, dataViewEditor }, | ||
} = useKibana<DashboardAppServices>(); | ||
const analyticsServices = { | ||
coreStart: core as unknown as React.ComponentProps< | ||
typeof AnalyticsNoDataPageKibanaProvider | ||
>['coreStart'], | ||
dataViews: data.dataViews, | ||
dataViewEditor, | ||
}; | ||
return ( | ||
<AnalyticsNoDataPageKibanaProvider {...analyticsServices}> | ||
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} />; | ||
</AnalyticsNoDataPageKibanaProvider> | ||
); | ||
}; | ||
|
||
export const isDashboardAppEmpty = async (dataViews: DataPublicPluginStart['dataViews']) => { | ||
const hasUserDataView = await dataViews.hasData.hasUserDataView().catch(() => false); | ||
const hasEsData = await dataViews.hasData.hasESData().catch(() => true); | ||
if (!hasUserDataView || !hasEsData) { | ||
return true; | ||
} | ||
|
||
const defaultDataView = await dataViews.getDefaultDataView(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this check necessary for Dashboard? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question. The older version of this code had an Is there a reason this was required for Discover? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if memory serves well, in Discover, you save a saved search with a data view. if all data views get deleted and you try opening a saved search, that would throw an error. That's why the check. That being said, it was there before checking for existence of any data view, so I am not sure if it's relevant any more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like it should all work the same. I will remove this from the dashboard side! |
||
if (!defaultDataView) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit: we're trying to standardize terminology in a way that by "no data" we refer to "there is no data in ES or there are no data views". by "empty" we refer to "this app is empty", aka there is data, but there are no dashboards yet. can we rename this to something like "noDataCheck" or "hasData" or even "canUseDashboard"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I will rename all of these. Naming is important, thank you for pointing this out!