-
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.
[Observability] Load hasData call asynchronously (#80644)
* obs perf * fixing unit tests * fixing ts issues * fixing empty state * addressing pr comments * addressing pr comments * fixing TS issue * fixing some stuff * refactoring * fixing ts issues and unit tests * addressing PR comments * fixing TS issues * fixing eslint issue Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
e3ca8a9
commit ac73b6a
Showing
32 changed files
with
1,214 additions
and
640 deletions.
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
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
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
File renamed without changes.
64 changes: 64 additions & 0 deletions
64
x-pack/plugins/observability/public/components/app/empty_sections/index.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { EuiFlexGrid, EuiFlexItem, EuiSpacer } from '@elastic/eui'; | ||
import React, { useContext } from 'react'; | ||
import { ThemeContext } from 'styled-components'; | ||
import { Alert } from '../../../../../alerts/common'; | ||
import { FETCH_STATUS } from '../../../hooks/use_fetcher'; | ||
import { useHasData } from '../../../hooks/use_has_data'; | ||
import { usePluginContext } from '../../../hooks/use_plugin_context'; | ||
import { getEmptySections } from '../../../pages/overview/empty_section'; | ||
import { UXHasDataResponse } from '../../../typings'; | ||
import { EmptySection } from './empty_section'; | ||
|
||
export function EmptySections() { | ||
const { core } = usePluginContext(); | ||
const theme = useContext(ThemeContext); | ||
const { hasData } = useHasData(); | ||
|
||
const appEmptySections = getEmptySections({ core }).filter(({ id }) => { | ||
if (id === 'alert') { | ||
const { status, hasData: alerts } = hasData.alert || {}; | ||
return ( | ||
status === FETCH_STATUS.FAILURE || | ||
(status === FETCH_STATUS.SUCCESS && (alerts as Alert[]).length === 0) | ||
); | ||
} else { | ||
const app = hasData[id]; | ||
if (app) { | ||
const _hasData = id === 'ux' ? (app.hasData as UXHasDataResponse)?.hasData : app.hasData; | ||
return app.status === FETCH_STATUS.FAILURE || !_hasData; | ||
} | ||
} | ||
return false; | ||
}); | ||
return ( | ||
<EuiFlexItem> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexGrid | ||
columns={ | ||
// when more than 2 empty sections are available show them on 2 columns, otherwise 1 | ||
appEmptySections.length > 2 ? 2 : 1 | ||
} | ||
gutterSize="s" | ||
> | ||
{appEmptySections.map((app) => { | ||
return ( | ||
<EuiFlexItem | ||
key={app.id} | ||
style={{ | ||
border: `1px dashed ${theme.eui.euiBorderColor}`, | ||
borderRadius: '4px', | ||
}} | ||
> | ||
<EmptySection section={app} /> | ||
</EuiFlexItem> | ||
); | ||
})} | ||
</EuiFlexGrid> | ||
</EuiFlexItem> | ||
); | ||
} |
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
Oops, something went wrong.