Skip to content

Commit

Permalink
add follower badge to index management (#29177)
Browse files Browse the repository at this point in the history
* add follower badge to index management

* fixing i18n id
  • Loading branch information
bmcconaghy authored Jan 24, 2019
1 parent bfa417c commit a95be51
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*/

export const ccrDataEnricher = async (indicesList, callWithRequest) => {
if (!indicesList || !indicesList.length) {
return indicesList;
}
const params = {
path: '/_all/_ccr/info',
method: 'GET',
};
try {
const { follower_indices: followerIndices } = await callWithRequest('transport.request', params);
return indicesList.map(index => {
const isFollowerIndex = !!followerIndices.find((followerIndex) => {
return followerIndex.follower_index === index.name;
});
return {
...index,
isFollowerIndex
};
});
} catch (e) {
return indicesList;
}

};
8 changes: 7 additions & 1 deletion x-pack/plugins/cross_cluster_replication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { resolve } from 'path';
import { PLUGIN } from './common/constants';
import { registerLicenseChecker } from './server/lib/register_license_checker';
import { registerRoutes } from './server/routes/register_routes';

import { ccrDataEnricher } from './cross_cluster_replication_data';
import { addIndexManagementDataEnricher } from '../index_management/index_management_data';
export function crossClusterReplication(kibana) {
return new kibana.Plugin({
id: PLUGIN.ID,
Expand Down Expand Up @@ -41,6 +42,11 @@ export function crossClusterReplication(kibana) {
init: function initCcrPlugin(server) {
registerLicenseChecker(server);
registerRoutes(server);
if (
server.config().get('xpack.ccr.ui.enabled')
) {
addIndexManagementDataEnricher(ccrDataEnricher);
}
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 { i18n } from '@kbn/i18n';
import {
addBadgeExtension
} from '../../../index_management/public/index_management_extensions';
import { get } from 'lodash';

const propertyPath = 'isFollowerIndex';
export const followerBadgeExtension = {
matchIndex: (index) => {
return get(index, propertyPath);
},
label: i18n.translate('xpack.crossClusterReplication.indexMgmtBadge.followerLabel', {
defaultMessage: 'Follower',
}),
color: 'default'
};

addBadgeExtension(followerBadgeExtension);

1 change: 1 addition & 0 deletions x-pack/plugins/cross_cluster_replication/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

import './register_ccr_section';
import './register_routes';
import './extend_index_management';

0 comments on commit a95be51

Please sign in to comment.