forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search: Inference Management UI] Adding restriction on deleting prec…
…onfigured endpoints (elastic#196580) ## Summary Disables the delete action when the endpoints are preconfigured. ![Screenshot 2024-10-18 at 12 12 20 PM](https://github.com/user-attachments/assets/6684b5c6-5f7d-434f-83e3-74872125753b) ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [X] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [X] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [X] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) (cherry picked from commit dc219f9)
- Loading branch information
1 parent
d77d619
commit 2ba14da
Showing
10 changed files
with
195 additions
and
10 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
...rence_endpoints/render_table_columns/render_actions/actions/delete/delete_action.test.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,59 @@ | ||
/* | ||
* 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 { render, screen, fireEvent } from '@testing-library/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import React from 'react'; | ||
|
||
import { DeleteAction } from './delete_action'; | ||
import { InferenceEndpointUI } from '../../../../types'; | ||
|
||
describe('Delete Action', () => { | ||
const mockProvider = { | ||
inference_id: 'my-hugging-face', | ||
service: 'hugging_face', | ||
service_settings: { | ||
api_key: 'aaaa', | ||
url: 'https://dummy.huggingface.com', | ||
}, | ||
task_settings: {}, | ||
} as any; | ||
|
||
const mockItem: InferenceEndpointUI = { | ||
endpoint: 'my-hugging-face', | ||
provider: mockProvider, | ||
type: 'text_embedding', | ||
}; | ||
|
||
const Wrapper = ({ item }: { item: InferenceEndpointUI }) => { | ||
const queryClient = new QueryClient(); | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<DeleteAction selectedEndpoint={item} /> | ||
</QueryClientProvider> | ||
); | ||
}; | ||
it('renders', () => { | ||
render(<Wrapper item={mockItem} />); | ||
|
||
expect(screen.getByTestId('inferenceUIDeleteAction')).toBeEnabled(); | ||
}); | ||
|
||
it('disable the delete action for preconfigured endpoint', () => { | ||
const preconfiguredMockItem = { ...mockItem, endpoint: '.elser-2' }; | ||
render(<Wrapper item={preconfiguredMockItem} />); | ||
|
||
expect(screen.getByTestId('inferenceUIDeleteAction')).toBeDisabled(); | ||
}); | ||
|
||
it('loads confirm delete modal', () => { | ||
render(<Wrapper item={mockItem} />); | ||
|
||
fireEvent.click(screen.getByTestId('inferenceUIDeleteAction')); | ||
expect(screen.getByTestId('deleteModalForInferenceUI')).toBeInTheDocument(); | ||
}); | ||
}); |
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
15 changes: 15 additions & 0 deletions
15
...c/components/all_inference_endpoints/render_table_columns/render_endpoint/translations.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,15 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const PRECONFIGURED_LABEL = i18n.translate( | ||
'xpack.searchInferenceEndpoints.elasticsearch.endpointInfo.preconfigured', | ||
{ | ||
defaultMessage: 'PRECONFIGURED', | ||
} | ||
); |
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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/search_inference_endpoints/public/utils/preconfigured_endpoint_helper.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,23 @@ | ||
/* | ||
* 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 { PRECONFIGURED_ENDPOINTS } from '../components/all_inference_endpoints/constants'; | ||
import { isEndpointPreconfigured } from './preconfigured_endpoint_helper'; | ||
|
||
describe('Preconfigured Endpoint helper', () => { | ||
it('return true for preconfigured elser', () => { | ||
expect(isEndpointPreconfigured(PRECONFIGURED_ENDPOINTS.ELSER)).toEqual(true); | ||
}); | ||
|
||
it('return true for preconfigured e5', () => { | ||
expect(isEndpointPreconfigured(PRECONFIGURED_ENDPOINTS.E5)).toEqual(true); | ||
}); | ||
|
||
it('return false for other endpoints', () => { | ||
expect(isEndpointPreconfigured('other-endpoints')).toEqual(false); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
x-pack/plugins/search_inference_endpoints/public/utils/preconfigured_endpoint_helper.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,11 @@ | ||
/* | ||
* 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 { PRECONFIGURED_ENDPOINTS } from '../components/all_inference_endpoints/constants'; | ||
|
||
export const isEndpointPreconfigured = (endpoint: string) => | ||
Object.values(PRECONFIGURED_ENDPOINTS).includes(endpoint); |