-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
803 additions
and
181 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...ch/public/applications/enterprise_search_content/api/index/delete_index_api_logic.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { mockHttpValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import { nextTick } from '@kbn/test-jest-helpers'; | ||
|
||
import { deleteIndex } from './delete_index_api_logic'; | ||
|
||
describe('deleteIndexApiLogic', () => { | ||
const { http } = mockHttpValues; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
describe('deleteIndex', () => { | ||
it('calls correct api', async () => { | ||
const promise = Promise.resolve(); | ||
http.post.mockReturnValue(promise); | ||
const result = deleteIndex({ indexName: 'deleteIndex' }); | ||
await nextTick(); | ||
expect(http.delete).toHaveBeenCalledWith('/internal/enterprise_search/indices/deleteIndex'); | ||
await expect(result).resolves; | ||
}); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
..._search/public/applications/enterprise_search_content/api/index/delete_index_api_logic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export interface DeleteIndexApiLogicArgs { | ||
indexName: string; | ||
} | ||
|
||
export const deleteIndex = async ({ indexName }: DeleteIndexApiLogicArgs): Promise<void> => { | ||
const route = `/internal/enterprise_search/indices/${indexName}`; | ||
await HttpLogic.values.http.delete(route); | ||
return; | ||
}; | ||
|
||
export const DeleteIndexApiLogic = createApiLogic(['delete_index_api_logic'], deleteIndex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...c/applications/enterprise_search_content/components/search_indices/delete_index_modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { useActions, useValues } from 'kea'; | ||
|
||
import { EuiConfirmModal } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { IndicesLogic } from './indices_logic'; | ||
|
||
export const DeleteIndexModal: React.FC = () => { | ||
const { closeDeleteModal, deleteIndex } = useActions(IndicesLogic); | ||
const { deleteModalIndexName: indexName, isDeleteModalVisible } = useValues(IndicesLogic); | ||
return isDeleteModalVisible ? ( | ||
<EuiConfirmModal | ||
title={i18n.translate('xpack.enterpriseSearch.content.searchIndices.deleteModal.title', { | ||
defaultMessage: 'Delete index', | ||
})} | ||
onCancel={() => { | ||
closeDeleteModal(); | ||
}} | ||
onConfirm={() => { | ||
deleteIndex({ indexName }); | ||
}} | ||
cancelButtonText={i18n.translate( | ||
'xpack.enterpriseSearch.content.searchIndices.deleteModal.cancelButton.title', | ||
{ | ||
defaultMessage: 'Cancel', | ||
} | ||
)} | ||
confirmButtonText={i18n.translate( | ||
'xpack.enterpriseSearch.content.searchIndices.deleteModal.confirmButton.title', | ||
{ | ||
defaultMessage: 'Delete index', | ||
} | ||
)} | ||
defaultFocusedButton="confirm" | ||
buttonColor="danger" | ||
> | ||
<p> | ||
{i18n.translate( | ||
'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.', | ||
values: { | ||
indexName, | ||
}, | ||
} | ||
)} | ||
</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> | ||
) : ( | ||
<></> | ||
); | ||
}; |
Oops, something went wrong.