-
Notifications
You must be signed in to change notification settings - Fork 0
[CCR] UI updates #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * 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 { EuiCallOut } from '@elastic/eui'; | ||
| import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
| import { getPreviewIndicesFromAutoFollowPattern } from '../services/auto_follow_pattern'; | ||
|
|
||
| export const AutoFollowPatternIndicesPreview = injectI18n(({ prefix, suffix, leaderIndexPatterns, intl }) => { | ||
| const { indicesPreview } = getPreviewIndicesFromAutoFollowPattern({ | ||
| prefix, | ||
| suffix, | ||
| leaderIndexPatterns | ||
| }); | ||
|
|
||
| const title = intl.formatMessage({ | ||
| id: 'xpack.crossClusterReplication.autoFollowPatternForm.indicesPreviewTitle', | ||
| defaultMessage: 'Index name examples', | ||
| }); | ||
|
|
||
| return ( | ||
| <EuiCallOut | ||
| title={title} | ||
| iconType="indexMapping" | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.crossClusterReplication.autoFollowPatternForm.indicesPreviewDescription" | ||
| defaultMessage="The above settings will generate index names that look like this:" | ||
| /> | ||
| <ul> | ||
| {indicesPreview.map((followerIndex, i) => <li key={i}>{followerIndex}</li>)} | ||
| </ul> | ||
| </EuiCallOut> | ||
| ); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ import { | |
| import { API_STATUS } from '../../../../../constants'; | ||
| import { AutoFollowPatternDeleteProvider } from '../../../../../components'; | ||
| import routing from '../../../../../services/routing'; | ||
| import { getPrefixSuffixFromFollowPattern } from '../../../../../services/auto_follow_pattern'; | ||
|
|
||
| export class AutoFollowPatternTableUI extends PureComponent { | ||
| static propTypes = { | ||
|
|
@@ -44,12 +43,14 @@ export class AutoFollowPatternTableUI extends PureComponent { | |
|
|
||
| if(queryText) { | ||
| return autoFollowPatterns.filter(autoFollowPattern => { | ||
| const { name, remoteCluster } = autoFollowPattern; | ||
| const { name, remoteCluster, followIndexPatternPrefix, followIndexPatternSuffix } = autoFollowPattern; | ||
|
|
||
| const inName = name.toLowerCase().includes(queryText); | ||
| const inRemoteCluster = remoteCluster.toLowerCase().includes(queryText); | ||
| const inPrefix = followIndexPatternPrefix.toLowerCase().includes(queryText); | ||
| const inSuffix = followIndexPatternSuffix.toLowerCase().includes(queryText); | ||
|
|
||
| return inName || inRemoteCluster; | ||
| return inName || inRemoteCluster || inPrefix || inSuffix; | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -89,29 +90,21 @@ export class AutoFollowPatternTableUI extends PureComponent { | |
| ), | ||
| render: (leaderPatterns) => leaderPatterns.join(', '), | ||
| }, { | ||
| field: 'followIndexPattern', | ||
| field: 'followIndexPatternPrefix', | ||
|
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. Can we add
Owner
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. Yes, don't know why I thought it was already set to |
||
| name: ( | ||
| <FormattedMessage | ||
| id="xpack.cross_cluster_replication.autofollow_pattern_list.table.connected_nodes_column_title" | ||
| defaultMessage="Follower pattern prefix" | ||
| /> | ||
| ), | ||
| render: (followIndexPattern) => { | ||
| const { followIndexPatternPrefix } = getPrefixSuffixFromFollowPattern(followIndexPattern); | ||
| return followIndexPatternPrefix; | ||
| } | ||
| }, { | ||
| field: 'followIndexPattern', | ||
| field: 'followIndexPatternSuffix', | ||
| name: ( | ||
| <FormattedMessage | ||
| id="xpack.cross_cluster_replication.autofollow_pattern_list.table.connected_nodes_column_title" | ||
| defaultMessage="Follower pattern suffix" | ||
| /> | ||
| ), | ||
| render: (followIndexPattern) => { | ||
| const { followIndexPatternSuffix } = getPrefixSuffixFromFollowPattern(followIndexPattern); | ||
| return followIndexPatternSuffix; | ||
| } | ||
| }, { | ||
| name: '', | ||
| actions: [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,15 @@ | |
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { Fragment } from 'react'; | ||
| import { format, addDays } from 'date-fns'; | ||
|
|
||
| export const getFollowPattern = (prefix = '', suffix = '', template = '{{leader_index}}') => ( | ||
| prefix + template + suffix | ||
| <Fragment> | ||
|
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. I have a few suggestions!
Owner
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. Ok, good points. About where the bold is, I asked Yaron and he agrees with you. |
||
| <span style={{ fontWeight: 'bold' }}>{prefix}</span> | ||
| {template} | ||
| <span style={{ fontWeight: 'bold' }}>{suffix}</span> | ||
| </Fragment> | ||
| ); | ||
|
|
||
| /** | ||
|
|
@@ -20,7 +27,11 @@ export const getPreviewIndicesFromAutoFollowPattern = ({ | |
| suffix, | ||
| leaderIndexPatterns, | ||
| limit = 5, | ||
| wildcardPlaceHolders = ['0', '1', '2'] | ||
| wildcardPlaceHolders = [ | ||
| format(new Date(), 'YYYY-MM-DD'), | ||
| format(addDays(new Date(), 1), 'YYYY-MM-DD'), | ||
| format(addDays(new Date(), 2), 'YYYY-MM-DD'), | ||
| ] | ||
| }) => { | ||
| const indicesPreview = []; | ||
| let indexPreview; | ||
|
|
||

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.
Why was this added?
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.
Mainly because
https://medium.com/@k2u4yt/momentjs-vs-date-fns-6bddc7bfa21e
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.
Thanks, I read the link and have a good idea of why date-fns is better than moment. I'd be in support of exploring migrating over. :)
In this particular situation, is it worth adding the extra dependency though? Do we gain anything significant, e.g. noticeable performance improvement? If not, then I think we should just stick with moment (warts and all) to avoid adding another dependency.