Skip to content

Commit

Permalink
update component
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Sep 16, 2021
1 parent 8bb1da4 commit 0b4dd07
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 319 deletions.
58 changes: 58 additions & 0 deletions x-pack/plugins/uptime/public/apps/uptime_page_template.tsx
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>
);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0b4dd07

Please sign in to comment.