mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* fixing issues with bad error message for low permission users * fixing stats, settings, and mappings error message and removing unused file
This commit is contained in:
parent
807f71bb84
commit
b7aa49027f
23 changed files with 43 additions and 104 deletions
|
@ -201,6 +201,7 @@ export class IndexTable extends Component {
|
|||
};
|
||||
|
||||
render() {
|
||||
|
||||
const {
|
||||
filterChanged,
|
||||
filter,
|
||||
|
@ -208,7 +209,6 @@ export class IndexTable extends Component {
|
|||
showSystemIndicesChanged,
|
||||
indices
|
||||
} = this.props;
|
||||
|
||||
const { selectedIndicesMap } = this.state;
|
||||
const atLeastOneItemSelected = Object.keys(selectedIndicesMap).length > 0;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { createAction } from "redux-actions";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { clearCacheIndices as request } from "../../services";
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
|
||||
export const clearCacheIndicesStart = createAction(
|
||||
"INDEX_MANAGEMENT_CLEAR_CACHE_INDICES_START"
|
||||
|
@ -17,7 +17,8 @@ export const clearCacheIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully cleared cache: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* 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 { createAction } from 'redux-actions';
|
||||
|
||||
|
||||
export const clearRowStatus = createAction('INDEX_MANAGEMENT_CLEAR_ROW_STATUS');
|
|
@ -7,7 +7,7 @@
|
|||
import { createAction } from "redux-actions";
|
||||
import { closeIndices as request } from "../../services";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
|
||||
export const closeIndicesStart = createAction(
|
||||
"INDEX_MANAGEMENT_CLOSE_INDICES_START"
|
||||
|
@ -17,7 +17,8 @@ export const closeIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully closed: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { createAction } from "redux-actions";
|
||||
import { deleteIndices as request } from "../../services";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { clearRowStatus } from "../actions";
|
||||
|
||||
export const deleteIndicesSuccess = createAction(
|
||||
"INDEX_MANAGEMENT_DELETE_INDICES_SUCCESS"
|
||||
|
@ -15,7 +16,8 @@ export const deleteIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
toastNotifications.addSuccess(`Successfully deleted: [${indexNames.join(", ")}]`);
|
||||
dispatch(deleteIndicesSuccess({ indexNames }));
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { createAction } from "redux-actions";
|
||||
import { flushIndices as request } from "../../services";
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
export const flushIndicesStart = createAction(
|
||||
|
@ -18,7 +18,8 @@ export const flushIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully flushed: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { createAction } from "redux-actions";
|
||||
import { forcemergeIndices as request } from "../../services";
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
export const forcemergeIndicesStart = createAction(
|
||||
|
@ -18,7 +18,8 @@ export const forcemergeIndices = ({ indexNames, maxNumSegments }) => async (disp
|
|||
try {
|
||||
await request(indexNames, maxNumSegments);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully force merged: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
export * from './clear_cache_indices';
|
||||
export * from './clear_row_status';
|
||||
export * from './close_indices';
|
||||
export * from './delete_indices';
|
||||
export * from './flush_indices';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { createAction } from "redux-actions";
|
||||
import { openIndices as request } from "../../services";
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
export const openIndicesStart = createAction(
|
||||
|
@ -18,7 +18,8 @@ export const openIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully opened: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { createAction } from "redux-actions";
|
||||
|
||||
import { refreshIndices as request } from "../../services";
|
||||
import { reloadIndices } from "../actions";
|
||||
import { clearRowStatus, reloadIndices } from "../actions";
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
export const refreshIndicesStart = createAction(
|
||||
|
@ -18,7 +18,8 @@ export const refreshIndices = ({ indexNames }) => async (dispatch) => {
|
|||
try {
|
||||
await request(indexNames);
|
||||
} catch (error) {
|
||||
return toastNotifications.addDanger(error.data.message);
|
||||
toastNotifications.addDanger(error.data.message);
|
||||
return dispatch(clearRowStatus({ indexNames }));
|
||||
}
|
||||
dispatch(reloadIndices(indexNames));
|
||||
toastNotifications.addSuccess(`Successfully refreshed: [${indexNames.join(", ")}]`);
|
||||
|
|
|
@ -27,7 +27,6 @@ const byId = handleActions({
|
|||
},
|
||||
[loadIndicesSuccess](state, action) {
|
||||
const { indices } = action.payload;
|
||||
|
||||
const newState = {};
|
||||
indices.forEach(index => {
|
||||
newState[index.name] = index;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { handleActions } from 'redux-actions';
|
||||
import {
|
||||
clearCacheIndicesStart,
|
||||
clearRowStatus,
|
||||
closeIndicesStart,
|
||||
openIndicesStart,
|
||||
flushIndicesStart,
|
||||
|
@ -26,6 +27,14 @@ import {
|
|||
} from '../../../common/constants';
|
||||
|
||||
export const rowStatus = handleActions({
|
||||
[clearRowStatus](state, action) {
|
||||
const { indexNames } = action.payload;
|
||||
const newState = { ...state };
|
||||
indexNames.forEach((indexName) => {
|
||||
delete newState[indexName];
|
||||
});
|
||||
return newState;
|
||||
},
|
||||
[closeIndicesStart](state, action) {
|
||||
const { indexNames } = action.payload;
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ function getIndexArrayFromPayload(payload) {
|
|||
|
||||
async function clearCache(callWithRequest, indices) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
format: 'json',
|
||||
index: indices
|
||||
|
|
|
@ -15,8 +15,6 @@ function getIndexArrayFromPayload(payload) {
|
|||
|
||||
async function closeIndices(callWithRequest, indices) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
format: 'json',
|
||||
index: indices
|
||||
|
|
|
@ -15,8 +15,6 @@ function getIndexArrayFromPayload(payload) {
|
|||
|
||||
async function deleteIndices(callWithRequest, indices) {
|
||||
const params = {
|
||||
ignore_unavailable: true,
|
||||
allow_no_indices: false,
|
||||
expand_wildcards: 'none',
|
||||
format: 'json',
|
||||
index: indices
|
||||
|
|
|
@ -17,8 +17,6 @@ async function flushIndices(callWithRequest, indices) {
|
|||
const params = {
|
||||
force: true,
|
||||
waitIfOngoing: true,
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
index: indices
|
||||
};
|
||||
|
|
|
@ -11,8 +11,6 @@ import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factor
|
|||
|
||||
async function forcemergeIndices(callWithRequest, indices, maxNumSegments) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
index: indices,
|
||||
};
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* 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 { callWithRequestFactory } from '../../../lib/call_with_request_factory';
|
||||
import { isEsErrorFactory } from '../../../lib/is_es_error_factory';
|
||||
import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
|
||||
import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory';
|
||||
|
||||
function getIndexNamesFromPayload(payload) {
|
||||
return payload.indexNames || [];
|
||||
}
|
||||
|
||||
function formatHits(hits) {
|
||||
return hits.map(hit => {
|
||||
return {
|
||||
health: hit.health,
|
||||
status: hit.status,
|
||||
name: hit.index,
|
||||
uuid: hit.uuid,
|
||||
primary: hit.pri,
|
||||
replica: hit.rep,
|
||||
documents: hit["docs.count"],
|
||||
documents_deleted: hit["docs.deleted"],
|
||||
size: hit["store.size"],
|
||||
primary_size: hit["pri.store.size"],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchMappings(callWithRequest, indexNames) {
|
||||
const params = {
|
||||
format: 'json',
|
||||
index: indexNames
|
||||
};
|
||||
|
||||
return await callWithRequest('mappings', params);
|
||||
}
|
||||
|
||||
export function registerMappingsRoute(server) {
|
||||
const isEsError = isEsErrorFactory(server);
|
||||
const licensePreRouting = licensePreRoutingFactory(server);
|
||||
|
||||
server.route({
|
||||
path: '/api/index_management/indices/mappings',
|
||||
method: 'POST',
|
||||
handler: async (request, reply) => {
|
||||
const callWithRequest = callWithRequestFactory(server, request);
|
||||
const indexNames = getIndexNamesFromPayload(request.payload);
|
||||
|
||||
try {
|
||||
const hits = await fetchMappings(callWithRequest, indexNames);
|
||||
const response = formatHits(hits);
|
||||
reply(response);
|
||||
} catch (err) {
|
||||
if (isEsError(err)) {
|
||||
return reply(wrapEsError(err));
|
||||
}
|
||||
|
||||
reply(wrapUnknownError(err));
|
||||
}
|
||||
},
|
||||
config: {
|
||||
pre: [ licensePreRouting ]
|
||||
}
|
||||
});
|
||||
}
|
|
@ -15,8 +15,6 @@ function getIndexArrayFromPayload(payload) {
|
|||
|
||||
async function openIndices(callWithRequest, indices) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
format: 'json',
|
||||
index: indices
|
||||
|
|
|
@ -15,8 +15,6 @@ function getIndexArrayFromPayload(payload) {
|
|||
|
||||
async function refreshIndices(callWithRequest, indices) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
index: indices
|
||||
};
|
||||
|
|
|
@ -19,8 +19,6 @@ function formatHit(hit, indexName) {
|
|||
|
||||
async function fetchMapping(callWithRequest, indexName) {
|
||||
const params = {
|
||||
ignore_unavailable: true,
|
||||
allow_no_indices: false,
|
||||
expand_wildcards: 'none',
|
||||
index: indexName,
|
||||
};
|
||||
|
|
|
@ -18,8 +18,6 @@ function formatHit(hit) {
|
|||
|
||||
async function fetchSettings(callWithRequest, indexName) {
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
allowNoIndices: false,
|
||||
expandWildcards: 'none',
|
||||
flatSettings: false,
|
||||
local: false,
|
||||
|
|
|
@ -20,8 +20,6 @@ function formatHit(hit, indexName) {
|
|||
|
||||
async function fetchStats(callWithRequest, indexName) {
|
||||
const params = {
|
||||
ignore_unavailable: true,
|
||||
allow_no_indices: false,
|
||||
expand_wildcards: 'none',
|
||||
index: indexName,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue