diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts index c868ddf8a247e..a02b1578bd38a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts @@ -127,7 +127,7 @@ describe('ApiKeysLogic', () => { const tokenName = 'my-token'; it('should set deleteModalVisible to true and set apiTokenNameToDelete', () => { - ApiKeysLogic.actions.showDeleteModal(tokenName); + ApiKeysLogic.actions.stageTokenNameForDeletion(tokenName); expect(ApiKeysLogic.values).toEqual({ ...values, @@ -445,7 +445,7 @@ describe('ApiKeysLogic', () => { jest.spyOn(ApiKeysLogic.actions, 'fetchApiKeys').mockImplementationOnce(() => {}); http.delete.mockReturnValue(Promise.resolve()); - ApiKeysLogic.actions.showDeleteModal(tokenName); + ApiKeysLogic.actions.stageTokenNameForDeletion(tokenName); ApiKeysLogic.actions.deleteApiKey(); expect(http.delete).toHaveBeenCalledWith( `/internal/workplace_search/api_keys/${tokenName}` diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.ts index 0c5786bc1a6e9..ca3662a8784c8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.ts @@ -45,7 +45,7 @@ interface ApiKeysLogicActions { onPaginate(newPageIndex: number): { newPageIndex: number }; deleteApiKey(): void; onApiFormSubmit(): void; - showDeleteModal(tokenName: string): string; + stageTokenNameForDeletion(tokenName: string): string; hideDeleteModal(): void; } @@ -76,7 +76,7 @@ export const ApiKeysLogic = kea ({ newPageIndex }), deleteApiKey: true, - showDeleteModal: (tokenName) => tokenName, + stageTokenNameForDeletion: (tokenName) => tokenName, hideDeleteModal: true, onApiFormSubmit: () => null, }), @@ -134,14 +134,14 @@ export const ApiKeysLogic = kea true, + stageTokenNameForDeletion: () => true, hideDeleteModal: () => false, }, ], apiTokenNameToDelete: [ '', { - showDeleteModal: (_, tokenName) => tokenName, + stageTokenNameForDeletion: (_, tokenName) => tokenName, hideDeleteModal: () => '', }, ], diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.test.tsx index d6c14bc160de6..3dd300d0eb5c5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.test.tsx @@ -19,7 +19,7 @@ import { ApiKey } from './api_key'; import { ApiKeysList } from './api_keys_list'; describe('ApiKeysList', () => { - const showDeleteModal = jest.fn(); + const stageTokenNameForDeletion = jest.fn(); const hideDeleteModal = jest.fn(); const deleteApiKey = jest.fn(); const onPaginate = jest.fn(); @@ -42,7 +42,7 @@ describe('ApiKeysList', () => { beforeEach(() => { setMockValues(values); - setMockActions({ deleteApiKey, onPaginate, showDeleteModal, hideDeleteModal }); + setMockActions({ deleteApiKey, onPaginate, stageTokenNameForDeletion, hideDeleteModal }); }); it('renders', () => { @@ -182,11 +182,11 @@ describe('ApiKeysList', () => { name: 'some-name', }; - it('calls showDeleteModal when clicked', () => { + it('calls stageTokenNameForDeletion when clicked', () => { const action = columns[2].actions[0]; action.onClick(token); - expect(showDeleteModal).toHaveBeenCalledWith('some-name'); + expect(stageTokenNameForDeletion).toHaveBeenCalledWith('some-name'); }); }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.tsx index 20a6f7a0331bb..5a79e965454b2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/components/api_keys_list.tsx @@ -29,7 +29,8 @@ import { import { ApiKey } from './api_key'; export const ApiKeysList: React.FC = () => { - const { deleteApiKey, onPaginate, showDeleteModal, hideDeleteModal } = useActions(ApiKeysLogic); + const { deleteApiKey, onPaginate, stageTokenNameForDeletion, hideDeleteModal } = + useActions(ApiKeysLogic); const { apiTokens, meta, dataLoading, deleteModalVisible } = useValues(ApiKeysLogic); const deleteModal = ( @@ -87,7 +88,7 @@ export const ApiKeysList: React.FC = () => { type: 'icon', icon: 'trash', color: 'danger', - onClick: (token: ApiToken) => showDeleteModal(token.name), + onClick: (token: ApiToken) => stageTokenNameForDeletion(token.name), }, ], },