-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 additions
and
319 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
/* | ||
* 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 { useHasData } from '../components/overview/empty_state/use_has_data'; | ||
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'; | ||
|
||
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 { loading, errors } = useHasData(); | ||
|
||
const noDataConfig = useNoDataConfig(); | ||
|
||
if (errors?.length) { | ||
return <EmptyStateError errors={errors} />; | ||
} | ||
|
||
return ( | ||
<StyledPageTemplateComponent | ||
pageHeader={pageHeader} | ||
noDataConfig={path === OVERVIEW_ROUTE && !loading ? noDataConfig : undefined} | ||
> | ||
{loading && path === OVERVIEW_ROUTE && <EmptyStateLoading />} | ||
<div style={{ visibility: loading && path === OVERVIEW_ROUTE ? 'hidden' : 'initial' }}> | ||
{children} | ||
</div> | ||
</StyledPageTemplateComponent> | ||
); | ||
}; |
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.
73 changes: 0 additions & 73 deletions
73
x-pack/plugins/uptime/public/components/overview/empty_state/empty_state.tsx
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
x-pack/plugins/uptime/public/components/overview/empty_state/index.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.