From c28f77e56fcb64b35c9c5352b2248e687f7523e9 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 11 Jan 2019 12:54:43 -0800 Subject: [PATCH] PR feedback --- .../follower_index_pause_provider.js | 2 +- .../follower_index_resume_provider.js | 2 +- .../follower_index_unfollow_provider.js | 22 +++++++++---------- .../components/context_menu/context_menu.js | 15 +++++-------- .../follower_indices_table.js | 4 ++-- .../public/app/services/api.js | 8 +++---- .../app/store/actions/follower_index.js | 6 ++--- .../server/client/elasticsearch_ccr.js | 3 +-- .../server/routes/api/follower_index.js | 5 ++--- 9 files changed, 30 insertions(+), 37 deletions(-) diff --git a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_pause_provider.js b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_pause_provider.js index 93d43979fca55..837d77a893f5a 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_pause_provider.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_pause_provider.js @@ -83,7 +83,7 @@ class Provider extends PureComponent {

diff --git a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_resume_provider.js b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_resume_provider.js index 06a8337e9e392..d6bdeaca06755 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_resume_provider.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_resume_provider.js @@ -83,7 +83,7 @@ class Provider extends PureComponent {

diff --git a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_unfollow_provider.js b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_unfollow_provider.js index e24719ac41869..86ac938582062 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_unfollow_provider.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/components/follower_index_unfollow_provider.js @@ -12,7 +12,7 @@ import { EuiOverlayMask, } from '@elastic/eui'; -import { unfollowFollowerIndex } from '../store/actions'; +import { unfollowLeaderIndex } from '../store/actions'; import { arrify } from '../../../common/services/utils'; class Provider extends PureComponent { @@ -27,12 +27,12 @@ class Provider extends PureComponent { event.stopPropagation(); }; - unfollowFollowerIndex = (id) => { + unfollowLeaderIndex = (id) => { this.setState({ isModalOpen: true, ids: arrify(id) }); }; onConfirm = () => { - this.props.unfollowFollowerIndex(this.state.ids); + this.props.unfollowLeaderIndex(this.state.ids); this.setState({ isModalOpen: false, ids: null }); } @@ -48,11 +48,11 @@ class Provider extends PureComponent { const isSingle = ids.length === 1; const title = isSingle ? intl.formatMessage({ - id: 'xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.unfollowSingleTitle', + id: 'xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.unfollowSingleTitle', defaultMessage: 'Unfollow leader index of follower index \'{name}\'?', }, { name: ids[0] }) : intl.formatMessage({ - id: 'xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.unfollowMultipleTitle', + id: 'xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.unfollowMultipleTitle', defaultMessage: 'Unfollow leader indices of {count} follower indices?', }, { count: ids.length }); @@ -65,14 +65,14 @@ class Provider extends PureComponent { onConfirm={this.onConfirm} cancelButtonText={ intl.formatMessage({ - id: 'xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.cancelButtonText', + id: 'xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.cancelButtonText', defaultMessage: 'Cancel', }) } buttonColor="danger" confirmButtonText={ intl.formatMessage({ - id: 'xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.confirmButtonText', + id: 'xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.confirmButtonText', defaultMessage: 'Unfollow', }) } @@ -82,7 +82,7 @@ class Provider extends PureComponent {

@@ -91,7 +91,7 @@ class Provider extends PureComponent {

@@ -109,7 +109,7 @@ class Provider extends PureComponent { return ( - {children(this.unfollowFollowerIndex)} + {children(this.unfollowLeaderIndex)} {isModalOpen && this.renderModal()} ); @@ -117,7 +117,7 @@ class Provider extends PureComponent { } const mapDispatchToProps = (dispatch) => ({ - unfollowFollowerIndex: (id) => dispatch(unfollowFollowerIndex(id)), + unfollowLeaderIndex: (id) => dispatch(unfollowLeaderIndex(id)), }); export const FollowerIndexUnfollowProvider = connect( diff --git a/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/context_menu/context_menu.js b/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/context_menu/context_menu.js index 32355d80e9674..6b0973d4e5858 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/context_menu/context_menu.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/sections/home/follower_indices_list/components/context_menu/context_menu.js @@ -32,12 +32,8 @@ export class ContextMenuUi extends Component { followerIndices: PropTypes.array.isRequired, } - constructor(props) { - super(props); - - this.state = { - isPopoverOpen: false, - }; + state = { + isPopoverOpen: false, } onButtonClick = () => { @@ -74,7 +70,6 @@ export class ContextMenuUi extends Component { { - activeFollowerIndexNames ? ( + activeFollowerIndexNames.length ? ( {(pauseFollowerIndex) => ( - {(unfollowFollowerIndex) => ( + {(unfollowLeaderIndex) => ( unfollowFollowerIndex(followerIndexNames)} + onClick={() => unfollowLeaderIndex(followerIndexNames)} > - {(unfollowFollowerIndex) => ( + {(unfollowLeaderIndex) => ( unfollowFollowerIndex(name)} + onClick={() => unfollowLeaderIndex(name)} /> )} diff --git a/x-pack/plugins/cross_cluster_replication/public/app/services/api.js b/x-pack/plugins/cross_cluster_replication/public/app/services/api.js index 40f3042e0dc8d..4fa43d19f552e 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/services/api.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/services/api.js @@ -76,17 +76,17 @@ export const createFollowerIndex = (followerIndex) => ( export const pauseFollowerIndex = (id) => { const ids = arrify(id).map(_id => encodeURIComponent(_id)).join(','); - return httpClient.put(`${apiPrefix}/follower_indices/${encodeURIComponent(ids)}/pause`).then(extractData); + return httpClient.put(`${apiPrefix}/follower_indices/${ids}/pause`).then(extractData); }; export const resumeFollowerIndex = (id) => { const ids = arrify(id).map(_id => encodeURIComponent(_id)).join(','); - return httpClient.put(`${apiPrefix}/follower_indices/${encodeURIComponent(ids)}/resume`).then(extractData); + return httpClient.put(`${apiPrefix}/follower_indices/${ids}/resume`).then(extractData); }; -export const unfollowFollowerIndex = (id) => { +export const unfollowLeaderIndex = (id) => { const ids = arrify(id).map(_id => encodeURIComponent(_id)).join(','); - return httpClient.put(`${apiPrefix}/follower_indices/${encodeURIComponent(ids)}/unfollow`).then(extractData); + return httpClient.put(`${apiPrefix}/follower_indices/${ids}/unfollow`).then(extractData); }; /* Stats */ diff --git a/x-pack/plugins/cross_cluster_replication/public/app/store/actions/follower_index.js b/x-pack/plugins/cross_cluster_replication/public/app/store/actions/follower_index.js index 84420ff4394e9..16a1b9a7fb74e 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/store/actions/follower_index.js +++ b/x-pack/plugins/cross_cluster_replication/public/app/store/actions/follower_index.js @@ -13,7 +13,7 @@ import { createFollowerIndex as createFollowerIndexRequest, pauseFollowerIndex as pauseFollowerIndexRequest, resumeFollowerIndex as resumeFollowerIndexRequest, - unfollowFollowerIndex as unfollowFollowerIndexRequest, + unfollowLeaderIndex as unfollowLeaderIndexRequest, } from '../../services/api'; import * as t from '../action_types'; import { sendApiRequest } from './api'; @@ -175,13 +175,13 @@ export const resumeFollowerIndex = (id) => ( }) ); -export const unfollowFollowerIndex = (id) => ( +export const unfollowLeaderIndex = (id) => ( sendApiRequest({ label: t.FOLLOWER_INDEX_UNFOLLOW, status: API_STATUS.DELETING, scope: `${scope}-delete`, handler: async () => ( - unfollowFollowerIndexRequest(id) + unfollowLeaderIndexRequest(id) ), onSuccess(response, dispatch, getState) { /** diff --git a/x-pack/plugins/cross_cluster_replication/server/client/elasticsearch_ccr.js b/x-pack/plugins/cross_cluster_replication/server/client/elasticsearch_ccr.js index 138b668a76b7d..f166b12ed60f4 100644 --- a/x-pack/plugins/cross_cluster_replication/server/client/elasticsearch_ccr.js +++ b/x-pack/plugins/cross_cluster_replication/server/client/elasticsearch_ccr.js @@ -126,11 +126,10 @@ export const elasticsearchJsPlugin = (Client, config, components) => { } } ], - needBody: true, method: 'POST' }); - ccr.unfollowFollowerIndex = ca({ + ccr.unfollowLeaderIndex = ca({ urls: [ { fmt: '/<%=id%>/_ccr/unfollow', diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index.js b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index.js index 3863b932c8f5c..cc7eeaef99514 100644 --- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index.js +++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index.js @@ -154,8 +154,7 @@ export const registerFollowerIndexRoutes = (server) => { const errors = []; await Promise.all(ids.map((_id) => ( - // TODO: Remove empty body when fixed in ES: https://github.com/elastic/elasticsearch/issues/37022 - callWithRequest('ccr.resumeFollowerIndex', { id: _id, body: {} }) + callWithRequest('ccr.resumeFollowerIndex', { id: _id }) .then(() => itemsResumed.push(_id)) .catch(err => { if (isEsError(err)) { @@ -200,7 +199,7 @@ export const registerFollowerIndexRoutes = (server) => { await callWithRequest('indices.close', { index: _id }); // Unfollow leader - await callWithRequest('ccr.unfollowFollowerIndex', { id: _id }); + await callWithRequest('ccr.unfollowLeaderIndex', { id: _id }); // Push success itemsUnfollowed.push(_id);