-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[CCR] Improve form error handling and general UX #29419
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
83d6fd4
Avoid parsing empty string to integer + don't allow negative value fo…
sebelga ff69183
Add missing "type" property to FormEntryRow
sebelga 7cd920c
Fix translation display in remote cluster dropdown
sebelga 6442d95
Fix wrong endpoint for auto-follow stats + show api server error in a…
sebelga c4147f8
Improve UX when remote cluster api requests fail
sebelga 3bda0df
Move header follower indices & auto-follow patterns header to their l…
sebelga 79b3590
Refactor Remote clusters list component for better errors handling
sebelga 9f35f2a
Fix empty prompt in follower indices & auto-follow patterns list
sebelga 3cc75ea
Merge branch 'feature/ccr' into fix/ccr_bugs
sebelga 867c1c3
Small refactor
sebelga a0c2b92
Merge branch 'feature/ccr' into fix/ccr_bugs
sebelga 9a30779
Update <RemoteClusterList /> test snapshot
sebelga c223154
Fix regression in Auto-follow pattern list header
sebelga 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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,19 @@ | |
| import React, { PureComponent, Fragment } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
| import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; | ||
| import { | ||
| EuiButton, | ||
| EuiEmptyPrompt, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiText, | ||
| EuiSpacer, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import routing from '../../../services/routing'; | ||
| import { extractQueryParams } from '../../../services/query_params'; | ||
| import { API_STATUS } from '../../../constants'; | ||
| import { SectionLoading, SectionError } from '../../../components'; | ||
| import { SectionLoading, SectionError, SectionUnauthorized } from '../../../components'; | ||
| import { AutoFollowPatternTable, DetailPanel } from './components'; | ||
|
|
||
| const REFRESH_RATE_MS = 30000; | ||
|
|
@@ -88,6 +95,79 @@ export const AutoFollowPatternList = injectI18n( | |
| clearInterval(this.interval); | ||
| } | ||
|
|
||
| renderHeader() { | ||
| const { isAuthorized } = this.props; | ||
| return ( | ||
| <Fragment> | ||
| <EuiFlexGroup justifyContent="spaceBetween" alignItems="flexStart"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiText> | ||
| <p> | ||
| <FormattedMessage | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
| id="xpack.crossClusterReplication.autoFollowPatternList.autoFollowPatternsDescription" | ||
| defaultMessage="Auto-follow patterns replicate leader indices from a remote | ||
| cluster to follower indices on the local cluster." | ||
| /> | ||
| </p> | ||
| </EuiText> | ||
| </EuiFlexItem> | ||
|
|
||
| <EuiFlexItem grow={false}> | ||
| {isAuthorized && ( | ||
| <EuiButton | ||
| {...routing.getRouterLinkProps('/auto_follow_patterns/add')} | ||
| fill | ||
| iconType="plusInCircle" | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.crossClusterReplication.autoFollowPatternList.addAutoFollowPatternButtonLabel" | ||
| defaultMessage="Create an auto-follow pattern" | ||
| /> | ||
| </EuiButton> | ||
| )} | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
|
|
||
| <EuiSpacer /> | ||
| </Fragment> | ||
| ); | ||
| } | ||
|
|
||
| renderContent(isEmpty) { | ||
| const { apiError, isAuthorized, intl } = this.props; | ||
| if (!isAuthorized) { | ||
| return ( | ||
| <SectionUnauthorized | ||
| title={( | ||
| <FormattedMessage | ||
| id="xpack.crossClusterReplication.autoFollowPatternList.permissionErrorTitle" | ||
| defaultMessage="Permission error" | ||
| /> | ||
| )} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.crossClusterReplication.autoFollowPatternList.noPermissionText" | ||
| defaultMessage="You do not have permission to view or add auto-follow patterns." | ||
| /> | ||
| </SectionUnauthorized> | ||
| ); | ||
| } | ||
|
|
||
| if (apiError) { | ||
| const title = intl.formatMessage({ | ||
| id: 'xpack.crossClusterReplication.autoFollowPatternList.loadingErrorTitle', | ||
| defaultMessage: 'Error loading auto-follow patterns', | ||
| }); | ||
| return <SectionError title={title} error={apiError} />; | ||
| } | ||
|
|
||
| if (isEmpty) { | ||
| return this.renderEmpty(); | ||
| } | ||
|
|
||
| return this.renderList(); | ||
| } | ||
|
|
||
| renderEmpty() { | ||
| return ( | ||
| <EuiEmptyPrompt | ||
|
|
@@ -156,25 +236,15 @@ export const AutoFollowPatternList = injectI18n( | |
| } | ||
|
|
||
| render() { | ||
| const { autoFollowPatterns, apiStatus, apiError, isAuthorized, intl } = this.props; | ||
|
|
||
| if (!isAuthorized) { | ||
| return null; | ||
| } | ||
|
|
||
| if (apiStatus === API_STATUS.IDLE && !autoFollowPatterns.length) { | ||
| return this.renderEmpty(); | ||
| } | ||
|
|
||
| if (apiError) { | ||
| const title = intl.formatMessage({ | ||
| id: 'xpack.crossClusterReplication.autoFollowPatternList.loadingErrorTitle', | ||
| defaultMessage: 'Error loading auto-follow patterns', | ||
| }); | ||
| return <SectionError title={title} error={apiError} />; | ||
| } | ||
| const { autoFollowPatterns, apiStatus, } = this.props; | ||
| const isEmpty = apiStatus === API_STATUS.IDLE && !autoFollowPatterns.length; | ||
|
|
||
| return this.renderList(); | ||
| return ( | ||
| <Fragment> | ||
| {!isEmpty && this.renderHeader()} | ||
| {this.renderContent(isEmpty)} | ||
| </Fragment> | ||
| ); | ||
| } | ||
| } | ||
| ); | ||
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.
With this removed, we now show a prompt to the user when there's an error:
I'm a bit on the fence about this because it seems inaccurate and could possibly seem "deceptive" to the user. Imagine clicking the "Add remote cluster" button, completing the action, and then being redirected back here only to see this prompt again. At that point I'd be pretty surprised and confused -- there's something wrong but I wouldn't know what. What are your thoughts on this UX?
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.
Well, the previous UX was: the user enters follower indices, he clicks on "Add a follower index" and instead of accessing a form he had a red callout saying that the remote clusters could not be loaded. Unless he looks at the documentation and knows about the remote cluster field, that error message was not very helpful for the user, blocking him from accessing the form.
Also, if the list of clusters can't be loaded, he probably won't be able either to add a remote cluster. So that would help him understand better this message here in the add follower index form.