-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Observability] Load hasData call asynchronously #80644
Merged
cauemarcondes
merged 21 commits into
elastic:master
from
cauemarcondes:obs-improve-perf
Nov 23, 2020
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7702b95
obs perf
cauemarcondes 5afc484
fixing unit tests
cauemarcondes 0dd4a60
fixing ts issues
cauemarcondes f35e2c0
fixing empty state
cauemarcondes 38a67b9
Merge branch 'master' into obs-improve-perf
kibanamachine d37c788
addressing pr comments
cauemarcondes e5b149b
addressing pr comments
cauemarcondes af22249
fixing TS issue
cauemarcondes 21ed767
Merge branch 'master' of github.com:elastic/kibana into obs-improve-perf
cauemarcondes 94eb333
Merge branch 'master' of github.com:elastic/kibana into obs-improve-perf
cauemarcondes 7ba1593
fixing some stuff
cauemarcondes f4f2502
Merge branch 'master' of github.com:elastic/kibana into obs-improve-perf
cauemarcondes 3f3fdd9
refactoring
cauemarcondes 97be452
fixing ts issues and unit tests
cauemarcondes 88fd2e4
Merge branch 'master' into obs-improve-perf
kibanamachine 77b993a
Merge branch 'master' of github.com:elastic/kibana into obs-improve-perf
cauemarcondes c7a12d6
Merge branch 'obs-improve-perf' of github.com:cauemarcondes/kibana in…
cauemarcondes 4f0332d
addressing PR comments
cauemarcondes bf819f8
fixing TS issues
cauemarcondes 6d8a567
fixing eslint issue
cauemarcondes 080edfe
Merge branch 'master' into obs-improve-perf
kibanamachine 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
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.
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.
We should get rid of the special logic for alert and ux here if possible
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.
We can remove the alert logic based on my comment here.
Ux
will demand more changes with I'm not familiar to, maybe we could leave it like this for now and improve it in another PR.