-
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
[Uptime] Update no data available state #112403
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f37663
wip
shahzad31 9ae0aeb
Merge branch 'master' of github.com:elastic/kibana into uptime-no-dat…
shahzad31 8bb1da4
Merge branch 'master' of github.com:elastic/kibana into uptime-no-dat…
shahzad31 0b4dd07
update component
shahzad31 d013112
Merge branch 'master' of github.com:elastic/kibana into uptime-no-dat…
shahzad31 bb88552
update paths
shahzad31 431606d
fix i18n
shahzad31 8c83803
fix tests
shahzad31 88fd419
revert uneeded
shahzad31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
x-pack/plugins/uptime/public/apps/uptime_page_template.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useMemo } from 'react'; | ||
import styled from 'styled-components'; | ||
import { EuiPageHeaderProps } from '@elastic/eui'; | ||
import { OVERVIEW_ROUTE } from '../../common/constants'; | ||
import { useKibana } from '../../../../../src/plugins/kibana_react/public'; | ||
import { ClientPluginsStart } from './plugin'; | ||
import { useNoDataConfig } from './use_no_data_config'; | ||
import { EmptyStateLoading } from '../components/overview/empty_state/empty_state_loading'; | ||
import { EmptyStateError } from '../components/overview/empty_state/empty_state_error'; | ||
import { useHasData } from '../components/overview/empty_state/use_has_data'; | ||
|
||
interface Props { | ||
path: string; | ||
pageHeader?: EuiPageHeaderProps; | ||
} | ||
|
||
export const UptimePageTemplateComponent: React.FC<Props> = ({ path, pageHeader, children }) => { | ||
const { | ||
services: { observability }, | ||
} = useKibana<ClientPluginsStart>(); | ||
|
||
const PageTemplateComponent = observability.navigation.PageTemplate; | ||
|
||
const StyledPageTemplateComponent = useMemo(() => { | ||
return styled(PageTemplateComponent)` | ||
.euiPageHeaderContent > .euiFlexGroup { | ||
flex-wrap: wrap; | ||
} | ||
`; | ||
}, [PageTemplateComponent]); | ||
|
||
const noDataConfig = useNoDataConfig(); | ||
|
||
const { loading, error } = useHasData(); | ||
|
||
if (error) { | ||
return <EmptyStateError errors={[error]} />; | ||
} | ||
|
||
return ( | ||
<> | ||
<div data-test-subj={noDataConfig ? 'data-missing' : undefined} /> | ||
<StyledPageTemplateComponent | ||
pageHeader={pageHeader} | ||
noDataConfig={path === OVERVIEW_ROUTE && !loading ? noDataConfig : undefined} | ||
> | ||
{loading && path === OVERVIEW_ROUTE && <EmptyStateLoading />} | ||
<div | ||
style={{ visibility: loading && path === OVERVIEW_ROUTE ? 'hidden' : 'initial' }} | ||
data-test-subj={noDataConfig ? 'data-missing' : undefined} | ||
> | ||
{children} | ||
</div> | ||
</StyledPageTemplateComponent> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { useContext } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { KibanaPageTemplateProps, useKibana } from '../../../../../src/plugins/kibana_react/public'; | ||
import { UptimeSettingsContext } from '../contexts'; | ||
import { ClientPluginsStart } from './plugin'; | ||
import { indexStatusSelector } from '../state/selectors'; | ||
|
||
export function useNoDataConfig(): KibanaPageTemplateProps['noDataConfig'] { | ||
const { basePath } = useContext(UptimeSettingsContext); | ||
|
||
const { | ||
services: { docLinks }, | ||
} = useKibana<ClientPluginsStart>(); | ||
|
||
const { data } = useSelector(indexStatusSelector); | ||
|
||
// Returns no data config when there is no historical data | ||
if (data && !data.indexExists) { | ||
return { | ||
solution: i18n.translate('xpack.uptime.noDataConfig.solutionName', { | ||
defaultMessage: 'Observability', | ||
}), | ||
actions: { | ||
beats: { | ||
title: i18n.translate('xpack.uptime.noDataConfig.beatsCard.title', { | ||
defaultMessage: 'Add monitors with Heartbeat', | ||
}), | ||
description: i18n.translate('xpack.uptime.noDataConfig.beatsCard.description', { | ||
defaultMessage: | ||
'Proactively monitor the availability of your sites and services. Receive alerts and resolve issues faster to optimize your users experience.', | ||
}), | ||
href: basePath + `/app/home#/tutorial/uptimeMonitors`, | ||
}, | ||
}, | ||
docsLink: docLinks!.links.observability.guide, | ||
}; | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
x-pack/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.test.tsx
This file was deleted.
Oops, something went wrong.
87 changes: 0 additions & 87 deletions
87
x-pack/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.tsx
This file was deleted.
Oops, something went wrong.
99 changes: 0 additions & 99 deletions
99
x-pack/plugins/uptime/public/components/overview/empty_state/empty_state.test.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is this for?
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.
This is actually just used for functional testing purpose. The new component which is coming from KIbanaPageTemplate doesn't expose anything in case of no data. So i kep this dataTestSubject to make tests happy.
Perhapsi can rewrite tests to query by text or other css selectors,