-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Alerting UI] Don't wait for health check before showing Create Alert flyout #80996
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d17b38d
wip
ymao1 b6c4f38
Adding health context provider and option to block waiting for health…
ymao1 12ef7cf
Merge branch 'master' of https://github.com/elastic/kibana into alert…
ymao1 c2b785d
Adding tests
ymao1 9dff0db
Removing forced lag
ymao1 821e050
Fixing action form not rendering pre selected action
ymao1 f483526
PR fixes
ymao1 8092495
Merge branch 'master' into alerting/slow-alert-flyout
kibanamachine c9701ea
Merge branch 'master' into alerting/slow-alert-flyout
kibanamachine 0c2412a
Updating i18n ids
ymao1 aaf710d
Applying i18n fix
ymao1 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 hidden or 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 hidden or 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
45 changes: 45 additions & 0 deletions
45
x-pack/plugins/triggers_actions_ui/public/application/context/health_context.tsx
This file contains hidden or 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,45 @@ | ||
| /* | ||
| * 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 React, { createContext, useCallback, useContext, useMemo, useState } from 'react'; | ||
|
|
||
| export interface HealthContextValue { | ||
| loadingHealthCheck: boolean; | ||
| setLoadingHealthCheck: (loading: boolean) => void; | ||
| } | ||
|
|
||
| const defaultHealthContext: HealthContextValue = { | ||
| loadingHealthCheck: false, | ||
| setLoadingHealthCheck: (loading: boolean) => { | ||
| throw new Error( | ||
| 'setLoadingHealthCheck was not initialized, set it when you invoke the context' | ||
| ); | ||
| }, | ||
| }; | ||
|
|
||
| const HealthContext = createContext<HealthContextValue>(defaultHealthContext); | ||
|
|
||
| export const HealthContextProvider = ({ children }: { children: React.ReactNode }) => { | ||
| const [loading, setLoading] = useState<boolean>(false); | ||
|
|
||
| const setLoadingHealthCheck = useCallback((isLoading: boolean) => { | ||
| setLoading(isLoading); | ||
| }, []); | ||
|
|
||
| const value = useMemo(() => { | ||
| return { loadingHealthCheck: loading, setLoadingHealthCheck }; | ||
| }, [loading, setLoadingHealthCheck]); | ||
|
|
||
| return <HealthContext.Provider value={value}>{children}</HealthContext.Provider>; | ||
| }; | ||
|
|
||
| export const useHealthContext = () => { | ||
| const ctx = useContext(HealthContext); | ||
| if (!ctx) { | ||
| throw new Error('HealthContext has not been set.'); | ||
| } | ||
| return ctx; | ||
| }; |
This file contains hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
...k/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add_footer.tsx
This file contains hidden or 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,61 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { | ||
| EuiFlyoutFooter, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiButtonEmpty, | ||
| EuiButton, | ||
| } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { useHealthContext } from '../../context/health_context'; | ||
|
|
||
| interface AlertAddFooterProps { | ||
| isSaving: boolean; | ||
| hasErrors: boolean; | ||
| onSave: () => void; | ||
| onCancel: () => void; | ||
| } | ||
|
|
||
| export const AlertAddFooter = ({ isSaving, hasErrors, onSave, onCancel }: AlertAddFooterProps) => { | ||
| const { loadingHealthCheck } = useHealthContext(); | ||
|
|
||
| return ( | ||
| <EuiFlyoutFooter> | ||
| <EuiFlexGroup justifyContent="spaceBetween"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiButtonEmpty data-test-subj="cancelSaveAlertButton" onClick={onCancel}> | ||
| {i18n.translate('xpack.triggersActionsUI.sections.alertAdd.cancelButtonLabel', { | ||
| defaultMessage: 'Cancel', | ||
| })} | ||
| </EuiButtonEmpty> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiButton | ||
| fill | ||
| color="secondary" | ||
| data-test-subj="saveAlertButton" | ||
| type="submit" | ||
| iconType="check" | ||
| isDisabled={hasErrors || loadingHealthCheck} | ||
| isLoading={isSaving} | ||
| onClick={onSave} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.triggersActionsUI.sections.alertAdd.saveButtonLabel" | ||
ymao1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| defaultMessage="Save" | ||
| /> | ||
| </EuiButton> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiFlyoutFooter> | ||
| ); | ||
| }; | ||
|
|
||
| // eslint-disable-next-line import/no-default-export | ||
| export { AlertAddFooter as default }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.