-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search: Inference Management UI] Adding restriction on deleting preconfigured endpoints #196580
Merged
Samiul-TheSoccerFan
merged 3 commits into
elastic:main
from
Samiul-TheSoccerFan:handle-default-endpoint-from-inference-ui
Oct 23, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7c98134
Adding restriction on deleting preconfigured endpoints
Samiul-TheSoccerFan 22d0fbb
Adding preconfigured badge and refactoring preconfigure endpoint vali…
Samiul-TheSoccerFan be214b3
Merge branch 'main' into handle-default-endpoint-from-inference-ui
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These endpoints are renamed in elastic/elasticsearch#115395