Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Routes, Route } from '@kbn/shared-ux-router';
import { useLocation, matchPath } from 'react-router-dom';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { isInferenceEndpointExists } from '@kbn/inference-endpoint-ui-common';
import { EuiPageTemplate, EuiSpacer, EuiPageHeader, EuiButton, EuiButtonEmpty } from '@elastic/eui';
import { routeToConnectorEdit, routeToConnectors, routeToLogs, Section } from '../../../constants';
import { getAlertingSectionBreadcrumb } from '../../../lib/breadcrumb';
Expand Down Expand Up @@ -67,7 +68,23 @@ export const ActionsConnectorsHome: React.FunctionComponent<RouteComponentProps<
setIsLoadingActions(true);
try {
const actionsResponse = await loadAllActions({ http });
setActions(actionsResponse);
const filteredActionsResponse = await actionsResponse.reduce<Promise<ActionConnector[]>>(
async (result, connector) => {
if (
connector.actionTypeId !== '.inference' ||
(connector.actionTypeId === '.inference' &&
// @ts-ignore property 'config' does not exist on type ActionConnector
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the time sensitive nature of this change, I did not update types as I wanted to keep code churn to a minimum. I can create a follow up to get rid of this ignore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be better to filter on the server side instead of the client making http calls for each .inference connector.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it 100% should be on the server, otherwise there's too many places where this can be used and it's A) a lot of work to find/update them all, B) we risk missing something

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I agree with Yuliia, making this a blocking HTTP call per connector is not the right choice (at all).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR with the server-side fix is up #217641

(await isInferenceEndpointExists(http, connector.config?.inferenceId)))
) {
return [...(await result), connector];
}

return result;
},
Promise.resolve([])
);

setActions(filteredActionsResponse);
} catch (e) {
toasts.addDanger({
title: i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"@kbn/response-ops-rule-params",
"@kbn/response-ops-rules-apis",
"@kbn/fields-metadata-plugin",
"@kbn/share-plugin"
"@kbn/share-plugin",
"@kbn/inference-endpoint-ui-common"
],
"exclude": ["target/**/*"]
}