Skip to content

Commit

Permalink
fixed solutions badge for non-verified service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Nov 11, 2024
1 parent 47756d2 commit 254aa34
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const InferenceAPIConnectorFields: React.FunctionComponent<ActionConnectorFields
const newTaskType = currentTaskTypes?.find((p) => p.task_type === taskType);

setSelectedTaskType(taskType);
generateInferenceEndpointId(config, setFieldValue);

// transform the schema
const newTaskTypeSchema = Object.keys(newTaskType?.configuration ?? {}).map((k) => ({
Expand Down Expand Up @@ -151,6 +150,10 @@ const InferenceAPIConnectorFields: React.FunctionComponent<ActionConnectorFields
taskTypeConfig: configDefaults,
},
});
generateInferenceEndpointId(
{ ...config, taskType, taskTypeConfig: configDefaults },
setFieldValue
);
},
[config, providers, setFieldValue, updateFieldValues]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ServiceProviderProps {
searchValue?: string;
}

type ProviderSolution = 'Observability' | 'Security' | 'Search';
export type ProviderSolution = 'Observability' | 'Security' | 'Search';

interface ServiceProviderRecord {
icon: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React, { memo, useCallback, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { ServiceProviderKeys } from '../../../../../common/inference/constants';
import {
ProviderSolution,
SERVICE_PROVIDERS,
ServiceProviderIcon,
ServiceProviderName,
Expand Down Expand Up @@ -47,7 +48,20 @@ const SelectableProviderComponent: React.FC<SelectableProviderProps> = ({

const renderProviderOption = useCallback<NonNullable<EuiSelectableProps['renderOption']>>(
(option, searchValue) => {
const provider = SERVICE_PROVIDERS[option.label as ServiceProviderKeys];
const provider = Object.keys(SERVICE_PROVIDERS).includes(option.label)
? SERVICE_PROVIDERS[option.label as ServiceProviderKeys]
: undefined;

const supportedBySolutions = (provider &&
provider.solutions.map((solution) => (
<EuiFlexItem>
<EuiBadge color="hollow">{solution}</EuiBadge>
</EuiFlexItem>
))) ?? (
<EuiFlexItem>
<EuiBadge color="hollow">{'Search' as ProviderSolution}</EuiBadge>
</EuiFlexItem>
);
return (
<EuiFlexGroup gutterSize="s" alignItems="center" responsive={false}>
<EuiFlexItem grow={false}>
Expand All @@ -65,12 +79,7 @@ const SelectableProviderComponent: React.FC<SelectableProviderProps> = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="xs" responsive={false}>
{provider &&
provider.solutions.map((solution) => (
<EuiFlexItem>
<EuiBadge color="hollow">{solution}</EuiBadge>
</EuiFlexItem>
))}
{supportedBySolutions}
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down

0 comments on commit 254aa34

Please sign in to comment.