Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Jan 11, 2019
1 parent 8b39c90 commit c28f77e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Provider extends PureComponent {
<p>
<FormattedMessage
id="xpack.crossClusterReplication.pauseFollowerIndex.confirmModal.multiplePauseDescription"
defaultMessage="These follower indices will paused:"
defaultMessage="These follower indices will be paused:"
/>
</p>
<ul>{ids.map(id => <li key={id}>{id}</li>)}</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Provider extends PureComponent {
<p>
<FormattedMessage
id="xpack.crossClusterReplication.resumeFollowerIndex.confirmModal.multipleResumeDescription"
defaultMessage="These follower indices will resumed:"
defaultMessage="These follower indices will be resumed:"
/>
</p>
<ul>{ids.map(id => <li key={id}>{id}</li>)}</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 });
}

Expand All @@ -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 });

Expand All @@ -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',
})
}
Expand All @@ -82,7 +82,7 @@ class Provider extends PureComponent {
<Fragment>
<p>
<FormattedMessage
id="xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.singleUnfollowDescription"
id="xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.singleUnfollowDescription"
defaultMessage="This follower index will be paused, closed, and converted into a regular index."
/>
</p>
Expand All @@ -91,7 +91,7 @@ class Provider extends PureComponent {
<Fragment>
<p>
<FormattedMessage
id="xpack.crossClusterReplication.unfollowFollowerIndex.confirmModal.multipleUnfollowDescription"
id="xpack.crossClusterReplication.unfollowLeaderIndex.confirmModal.multipleUnfollowDescription"
defaultMessage="These follower indices will be paused, closed, and converted into regular indices:"
/>
</p>
Expand All @@ -109,15 +109,15 @@ class Provider extends PureComponent {

return (
<Fragment>
{children(this.unfollowFollowerIndex)}
{children(this.unfollowLeaderIndex)}
{isModalOpen && this.renderModal()}
</Fragment>
);
}
}

const mapDispatchToProps = (dispatch) => ({
unfollowFollowerIndex: (id) => dispatch(unfollowFollowerIndex(id)),
unfollowLeaderIndex: (id) => dispatch(unfollowLeaderIndex(id)),
});

export const FollowerIndexUnfollowProvider = connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -74,7 +70,6 @@ export class ContextMenuUi extends Component {
<EuiButton
data-test-subj="followerIndexContextMenuButton"
iconSide={iconSide}
// aria-label={`${entity} options`}
onClick={this.onButtonClick}
iconType={iconType}
fill
Expand Down Expand Up @@ -108,7 +103,7 @@ export class ContextMenuUi extends Component {
<EuiContextMenuPanel>

{
activeFollowerIndexNames ? (
activeFollowerIndexNames.length ? (
<FollowerIndexPauseProvider>
{(pauseFollowerIndex) => (
<EuiContextMenuItem
Expand Down Expand Up @@ -146,10 +141,10 @@ export class ContextMenuUi extends Component {
}

<FollowerIndexUnfollowProvider>
{(unfollowFollowerIndex) => (
{(unfollowLeaderIndex) => (
<EuiContextMenuItem
icon="indexFlush"
onClick={() => unfollowFollowerIndex(followerIndexNames)}
onClick={() => unfollowLeaderIndex(followerIndexNames)}
>
<FormattedMessage
id="xpack.crossClusterReplication.followerIndex.contextMenu.unfollowLabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ export const FollowerIndicesTable = injectI18n(
delay="long"
>
<FollowerIndexUnfollowProvider>
{(unfollowFollowerIndex) => (
{(unfollowLeaderIndex) => (
<EuiButtonIcon
aria-label={label}
iconType="indexFlush"
color="danger"
onClick={() => unfollowFollowerIndex(name)}
onClick={() => unfollowLeaderIndex(name)}
/>
)}
</FollowerIndexUnfollowProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c28f77e

Please sign in to comment.