-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Inference] Fix table responsiveness (#189265)
## Summary This improves the inference endpoint's table responsiveness and code clarity. It also fixes a bug where deleting one endpoint and then a second one would try to delete the same endpoint twice. <img width="879" alt="Screenshot 2024-07-26 at 12 18 59" src="https://github.com/user-attachments/assets/003f47ef-6cd4-4244-abe4-141ebf570a98"> <img width="1016" alt="Screenshot 2024-07-26 at 12 18 52" src="https://github.com/user-attachments/assets/9d7fd119-6c5c-4d5d-b381-68f6189e56e5"> <img width="1410" alt="Screenshot 2024-07-26 at 12 18 37" src="https://github.com/user-attachments/assets/790fe616-36d4-4a11-9ced-dca325efb753"> --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
7bd6ca6
commit a9ae3e5
Showing
23 changed files
with
304 additions
and
405 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
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
47 changes: 47 additions & 0 deletions
47
...nference_endpoints/render_table_columns/render_actions/actions/copy_id/copy_id_action.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,47 @@ | ||
/* | ||
* 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 { EuiButtonIcon, EuiCopy } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React from 'react'; | ||
import { useKibana } from '../../../../../../hooks/use_kibana'; | ||
|
||
interface CopyIDActionProps { | ||
modelId: string; | ||
} | ||
|
||
export const CopyIDAction = ({ modelId }: CopyIDActionProps) => { | ||
const { | ||
services: { notifications }, | ||
} = useKibana(); | ||
const toasts = notifications?.toasts; | ||
|
||
return ( | ||
<EuiCopy textToCopy={modelId}> | ||
{(copy) => ( | ||
<EuiButtonIcon | ||
aria-label={i18n.translate('xpack.searchInferenceEndpoints.actions.copyID', { | ||
defaultMessage: 'Copy inference endpoint ID {modelId}', | ||
values: { modelId }, | ||
})} | ||
data-test-subj="inference-endpoints-action-copy-id-label" | ||
iconType="copyClipboard" | ||
onClick={() => { | ||
copy(); | ||
toasts?.addSuccess({ | ||
title: i18n.translate('xpack.searchInferenceEndpoints.actions.copyIDSuccess', { | ||
defaultMessage: 'Inference endpoint ID {modelId} copied', | ||
values: { modelId }, | ||
}), | ||
}); | ||
}} | ||
size="s" | ||
/> | ||
)} | ||
</EuiCopy> | ||
); | ||
}; |
44 changes: 0 additions & 44 deletions
44
...ence_endpoints/render_table_columns/render_actions/actions/copy_id/use_copy_id_action.tsx
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
..._inference_endpoints/render_table_columns/render_actions/actions/delete/delete_action.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,55 @@ | ||
/* | ||
* 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 { EuiButtonIcon } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React, { useState } from 'react'; | ||
import { useDeleteEndpoint } from '../../../../../../hooks/use_delete_endpoint'; | ||
import { InferenceEndpointUI } from '../../../../types'; | ||
import { ConfirmDeleteEndpointModal } from './confirm_delete_endpoint'; | ||
|
||
interface DeleteActionProps { | ||
selectedEndpoint?: InferenceEndpointUI; | ||
} | ||
|
||
export const DeleteAction: React.FC<DeleteActionProps> = ({ selectedEndpoint }) => { | ||
const [isModalVisible, setIsModalVisible] = useState<boolean>(false); | ||
|
||
const { mutate: deleteEndpoint } = useDeleteEndpoint(() => setIsModalVisible(false)); | ||
|
||
const onConfirmDeletion = () => { | ||
if (!selectedEndpoint) { | ||
return; | ||
} | ||
|
||
deleteEndpoint({ | ||
type: selectedEndpoint.type, | ||
id: selectedEndpoint.endpoint.model_id, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<EuiButtonIcon | ||
aria-label={i18n.translate('xpack.searchInferenceEndpoints.actions.deleteEndpoint', { | ||
defaultMessage: 'Delete inference endpoint {selectedEndpointName}', | ||
values: { selectedEndpointName: selectedEndpoint?.endpoint.model_id }, | ||
})} | ||
key="delete" | ||
iconType="trash" | ||
color="danger" | ||
onClick={() => setIsModalVisible(true)} | ||
/> | ||
{isModalVisible && ( | ||
<ConfirmDeleteEndpointModal | ||
onCancel={() => setIsModalVisible(false)} | ||
onConfirm={onConfirmDeletion} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
55 changes: 0 additions & 55 deletions
55
...erence_endpoints/render_table_columns/render_actions/actions/delete/use_delete_action.tsx
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...c/components/all_inference_endpoints/render_table_columns/render_actions/actions/types.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.