mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Enterprise Search] Align actions according to table defaults (#139284)
* [Enterprise Search] Align actions according to table defaults * Fix i18n and adjust column width * Update x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_indices/indices_logic.ts Co-authored-by: Efe Gürkan YALAMAN <efeyalaman@gmail.com> Co-authored-by: Efe Gürkan YALAMAN <efeyalaman@gmail.com>
This commit is contained in:
parent
1a213bd7ce
commit
081e2d7e30
4 changed files with 63 additions and 63 deletions
|
@ -12,15 +12,22 @@ import { useActions, useValues } from 'kea';
|
|||
import { EuiConfirmModal } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { ingestionMethodToText } from '../../utils/indices';
|
||||
|
||||
import { IndicesLogic } from './indices_logic';
|
||||
|
||||
export const DeleteIndexModal: React.FC = () => {
|
||||
const { closeDeleteModal, deleteIndex } = useActions(IndicesLogic);
|
||||
const { deleteModalIndexName: indexName, isDeleteModalVisible } = useValues(IndicesLogic);
|
||||
const {
|
||||
deleteModalIndexName: indexName,
|
||||
deleteModalIngestionMethod: ingestionMethod,
|
||||
isDeleteModalVisible,
|
||||
} = useValues(IndicesLogic);
|
||||
return isDeleteModalVisible ? (
|
||||
<EuiConfirmModal
|
||||
title={i18n.translate('xpack.enterpriseSearch.content.searchIndices.deleteModal.title', {
|
||||
defaultMessage: 'Delete index',
|
||||
defaultMessage: 'Are you sure you want to delete {indexName}',
|
||||
values: { indexName },
|
||||
})}
|
||||
onCancel={() => {
|
||||
closeDeleteModal();
|
||||
|
@ -48,31 +55,13 @@ export const DeleteIndexModal: React.FC = () => {
|
|||
'xpack.enterpriseSearch.content.searchIndices.deleteModal.delete.description',
|
||||
{
|
||||
defaultMessage:
|
||||
'You are about to delete the index {indexName}. This will also delete any associated connector documents or crawlers.',
|
||||
'Deleting this index will also delete all of its data and its {ingestionMethod} configuration. Any associated search engines will no longer be able to access any data stored in this index.This can not be undone.',
|
||||
values: {
|
||||
indexName,
|
||||
ingestionMethod: ingestionMethodToText(ingestionMethod),
|
||||
},
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.content.searchIndices.deleteModal.searchEngine.description',
|
||||
{
|
||||
defaultMessage:
|
||||
'Any associated search engines will no longer be able to access any data stored in this index.',
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{i18n.translate(
|
||||
'xpack.enterpriseSearch.content.searchIndices.deleteModal.irrevokable.description',
|
||||
{
|
||||
defaultMessage:
|
||||
"You can't recover a deleted index, connector or crawler configuration. Make sure you have appropriate backups.",
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
</EuiConfirmModal>
|
||||
) : (
|
||||
<></>
|
||||
|
|
|
@ -22,13 +22,15 @@ import { DEFAULT_META } from '../../../shared/constants';
|
|||
|
||||
import { FetchIndicesAPILogic } from '../../api/index/fetch_indices_api_logic';
|
||||
|
||||
import { IngestionStatus } from '../../types';
|
||||
import { IngestionMethod, IngestionStatus } from '../../types';
|
||||
|
||||
import { IndicesLogic } from './indices_logic';
|
||||
|
||||
const DEFAULT_VALUES = {
|
||||
data: undefined,
|
||||
deleteModalIndex: null,
|
||||
deleteModalIndexName: '',
|
||||
deleteModalIngestionMethod: IngestionMethod.API,
|
||||
hasNoIndices: false,
|
||||
indices: [],
|
||||
isDeleteModalVisible: false,
|
||||
|
@ -76,17 +78,19 @@ describe('IndicesLogic', () => {
|
|||
});
|
||||
describe('openDeleteModal', () => {
|
||||
it('should set deleteIndexName and set isDeleteModalVisible to true', () => {
|
||||
IndicesLogic.actions.openDeleteModal('delete');
|
||||
IndicesLogic.actions.openDeleteModal(connectorIndex);
|
||||
expect(IndicesLogic.values).toEqual({
|
||||
...DEFAULT_VALUES,
|
||||
deleteModalIndexName: 'delete',
|
||||
deleteModalIndex: connectorIndex,
|
||||
deleteModalIndexName: 'connector',
|
||||
deleteModalIngestionMethod: IngestionMethod.CONNECTOR,
|
||||
isDeleteModalVisible: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('closeDeleteModal', () => {
|
||||
it('should set deleteIndexName to empty and set isDeleteModalVisible to false', () => {
|
||||
IndicesLogic.actions.openDeleteModal('delete');
|
||||
IndicesLogic.actions.openDeleteModal(connectorIndex);
|
||||
IndicesLogic.actions.closeDeleteModal();
|
||||
expect(IndicesLogic.values).toEqual(DEFAULT_VALUES);
|
||||
});
|
||||
|
|
|
@ -25,8 +25,8 @@ import {
|
|||
DeleteIndexApiLogicArgs,
|
||||
} from '../../api/index/delete_index_api_logic';
|
||||
import { FetchIndicesAPILogic } from '../../api/index/fetch_indices_api_logic';
|
||||
import { ElasticsearchViewIndex } from '../../types';
|
||||
import { indexToViewIndex } from '../../utils/indices';
|
||||
import { ElasticsearchViewIndex, IngestionMethod } from '../../types';
|
||||
import { getIngestionMethod, indexToViewIndex } from '../../utils/indices';
|
||||
|
||||
export interface IndicesActions {
|
||||
apiError(error: HttpError): HttpError;
|
||||
|
@ -64,12 +64,14 @@ export interface IndicesActions {
|
|||
}): { meta: Meta; returnHiddenIndices: boolean; searchQuery?: string };
|
||||
makeRequest: typeof FetchIndicesAPILogic.actions.makeRequest;
|
||||
onPaginate(newPageIndex: number): { newPageIndex: number };
|
||||
openDeleteModal(indexName: string): { indexName: string };
|
||||
openDeleteModal(index: ElasticsearchViewIndex): { index: ElasticsearchViewIndex };
|
||||
setIsFirstRequest(): void;
|
||||
}
|
||||
export interface IndicesValues {
|
||||
data: typeof FetchIndicesAPILogic.values.data;
|
||||
deleteModalIndex: ElasticsearchViewIndex | null;
|
||||
deleteModalIndexName: string;
|
||||
deleteModalIngestionMethod: IngestionMethod;
|
||||
hasNoIndices: boolean;
|
||||
indices: ElasticsearchViewIndex[];
|
||||
isDeleteModalVisible: boolean;
|
||||
|
@ -89,7 +91,7 @@ export const IndicesLogic = kea<MakeLogicType<IndicesValues, IndicesActions>>({
|
|||
searchQuery,
|
||||
}),
|
||||
onPaginate: (newPageIndex) => ({ newPageIndex }),
|
||||
openDeleteModal: (indexName) => ({ indexName }),
|
||||
openDeleteModal: (index) => ({ index }),
|
||||
setIsFirstRequest: true,
|
||||
},
|
||||
connect: {
|
||||
|
@ -108,7 +110,7 @@ export const IndicesLogic = kea<MakeLogicType<IndicesValues, IndicesActions>>({
|
|||
flashSuccessToast(
|
||||
i18n.translate('xpack.enterpriseSearch.content.indices.deleteIndex.successToast.title', {
|
||||
defaultMessage:
|
||||
'Your index {indexName} and any associated connectors or crawlers were successfully deleted',
|
||||
'Your index {indexName} and any associated ingestion configurations were successfully deleted',
|
||||
values: {
|
||||
indexName: values.deleteModalIndexName,
|
||||
},
|
||||
|
@ -125,11 +127,11 @@ export const IndicesLogic = kea<MakeLogicType<IndicesValues, IndicesActions>>({
|
|||
}),
|
||||
path: ['enterprise_search', 'content', 'indices_logic'],
|
||||
reducers: () => ({
|
||||
deleteModalIndexName: [
|
||||
'',
|
||||
deleteModalIndex: [
|
||||
null,
|
||||
{
|
||||
closeDeleteModal: () => '',
|
||||
openDeleteModal: (_, { indexName }) => indexName,
|
||||
closeDeleteModal: () => null,
|
||||
openDeleteModal: (_, { index }) => index,
|
||||
},
|
||||
],
|
||||
isDeleteModalVisible: [
|
||||
|
@ -163,6 +165,12 @@ export const IndicesLogic = kea<MakeLogicType<IndicesValues, IndicesActions>>({
|
|||
],
|
||||
}),
|
||||
selectors: ({ selectors }) => ({
|
||||
deleteModalIndexName: [() => [selectors.deleteModalIndex], (index) => index?.name ?? ''],
|
||||
deleteModalIngestionMethod: [
|
||||
() => [selectors.deleteModalIndex],
|
||||
(index: ElasticsearchViewIndex | null) =>
|
||||
index ? getIngestionMethod(index) : IngestionMethod.API,
|
||||
],
|
||||
hasNoIndices: [
|
||||
// We need this to show the landing page on the overview page if there are no indices
|
||||
// We can't rely just on there being no indices, because user might have entered a search query
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
import React from 'react';
|
||||
|
||||
import { useValues } from 'kea';
|
||||
|
||||
import {
|
||||
CriteriaWithPagination,
|
||||
EuiBasicTable,
|
||||
EuiBasicTableColumn,
|
||||
EuiButtonIcon,
|
||||
EuiIcon,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
|
@ -19,7 +20,8 @@ import { i18n } from '@kbn/i18n';
|
|||
|
||||
import { Meta } from '../../../../../common/types';
|
||||
import { generateEncodedPath } from '../../../shared/encode_path_params';
|
||||
import { EuiLinkTo, EuiButtonIconTo } from '../../../shared/react_router_helpers';
|
||||
import { KibanaLogic } from '../../../shared/kibana';
|
||||
import { EuiLinkTo } from '../../../shared/react_router_helpers';
|
||||
import { EuiBadgeTo } from '../../../shared/react_router_helpers/eui_components';
|
||||
import { convertMetaToPagination } from '../../../shared/table_pagination';
|
||||
import { SEARCH_INDEX_PATH } from '../../routes';
|
||||
|
@ -43,7 +45,7 @@ interface IndicesTableProps {
|
|||
isLoading?: boolean;
|
||||
meta: Meta;
|
||||
onChange: (criteria: CriteriaWithPagination<ElasticsearchViewIndex>) => void;
|
||||
onDelete: (indexName: string) => void;
|
||||
onDelete: (index: ElasticsearchViewIndex) => void;
|
||||
}
|
||||
|
||||
export const IndicesTable: React.FC<IndicesTableProps> = ({
|
||||
|
@ -53,6 +55,7 @@ export const IndicesTable: React.FC<IndicesTableProps> = ({
|
|||
onChange,
|
||||
onDelete,
|
||||
}) => {
|
||||
const { navigateToUrl } = useValues(KibanaLogic);
|
||||
const columns: Array<EuiBasicTableColumn<ElasticsearchViewIndex>> = [
|
||||
{
|
||||
field: 'name',
|
||||
|
@ -140,42 +143,38 @@ export const IndicesTable: React.FC<IndicesTableProps> = ({
|
|||
}
|
||||
},
|
||||
truncateText: true,
|
||||
width: '10%',
|
||||
width: '15%',
|
||||
},
|
||||
{
|
||||
actions: [
|
||||
{
|
||||
render: ({ name }) => (
|
||||
<EuiButtonIconTo
|
||||
aria-label={name}
|
||||
iconType="eye"
|
||||
data-test-subj={`view-search-index-button-${name}`}
|
||||
to={generateEncodedPath(SEARCH_INDEX_PATH, {
|
||||
indexName: name,
|
||||
})}
|
||||
/>
|
||||
),
|
||||
description: 'View this index',
|
||||
icon: 'eye',
|
||||
isPrimary: false,
|
||||
name: (index) => `View ${index.name}`,
|
||||
onClick: (index) =>
|
||||
navigateToUrl(
|
||||
generateEncodedPath(SEARCH_INDEX_PATH, {
|
||||
indexName: index.name,
|
||||
})
|
||||
),
|
||||
type: 'icon',
|
||||
},
|
||||
{
|
||||
render: (index) =>
|
||||
// We don't have a way to delete crawlers yet
|
||||
isCrawlerIndex(index) ? (
|
||||
<></>
|
||||
) : (
|
||||
<EuiButtonIcon
|
||||
aria-label={`Delete ${index.name}`}
|
||||
iconType="trash"
|
||||
color="danger"
|
||||
data-test-subj={`delete-search-index-button-${name}`}
|
||||
onClick={() => onDelete(index.name)}
|
||||
/>
|
||||
),
|
||||
available: (index) => !isCrawlerIndex(index),
|
||||
color: 'danger',
|
||||
description: 'Delete this index',
|
||||
icon: 'trash',
|
||||
isPrimary: false,
|
||||
name: (index) => `Delete ${index.name}`,
|
||||
onClick: (index) => onDelete(index),
|
||||
type: 'icon',
|
||||
},
|
||||
],
|
||||
name: i18n.translate('xpack.enterpriseSearch.content.searchIndices.actions.columnTitle', {
|
||||
defaultMessage: 'Actions',
|
||||
}),
|
||||
width: '5%',
|
||||
width: '10%',
|
||||
},
|
||||
];
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue