Skip to content

Commit

Permalink
[8.x] [Inference Connector] Changed UI/UX due to the new RFC for the …
Browse files Browse the repository at this point in the history
…_inference/_service (elastic#203363) (elastic#204690)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Inference Connector] Changed UI/UX due to the new RFC for the
_inference/_service
(elastic#203363)](elastic#203363)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Yuliia
Naumenko","email":"jo.naumenko@gmail.com"},"sourceCommit":{"committedDate":"2024-12-13T16:00:59Z","message":"[Inference
Connector] Changed UI/UX due to the new RFC for the _inference/_service
(elastic#203363)\n\nRelated
RFC\r\nhttps://docs.google.com/document/d/1DbWpqEKM-MJR2cSJNKLC7RcCNXXQ-_iUShsXKRFKXfk/edit?tab=t.0\r\n\r\n##
Summary\r\n\r\n- removed Task Settings from the UI and schema
definition, due to the\r\ndiscussion on Inference sync Dec 5th.\r\n-
renamed provider to service\r\n- added name and description, use name
for the service selector user\r\nfriendly way\r\n- dropped options and
display type dropdown select, use freeform text\r\ninput instead\r\n-
dropped `display` field type, renamed `tooltip` to the
`description`.\r\nProperly updated `ConnectorConfigurationFormItems`
in\r\n`x-pack/plugins/stack_connectors/public/connector_types/lib/dynamic_config/connector_configuration_form_items.tsx`\r\n\r\nUI
with the updates:\r\n<img width=\"1281\" alt=\"Screenshot 2024-12-08 at
10 09
52 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/fdb17dd4-c8e4-496b-85e7-03c363546b8e\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Ying
<ying.mao@elastic.co>","sha":"5b108453ffe823b5d559952f37da1030a79d3352","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:version","v8.18.0"],"number":203363,"url":"https://github.com/elastic/kibana/pull/203363","mergeCommit":{"message":"[Inference
Connector] Changed UI/UX due to the new RFC for the _inference/_service
(elastic#203363)\n\nRelated
RFC\r\nhttps://docs.google.com/document/d/1DbWpqEKM-MJR2cSJNKLC7RcCNXXQ-_iUShsXKRFKXfk/edit?tab=t.0\r\n\r\n##
Summary\r\n\r\n- removed Task Settings from the UI and schema
definition, due to the\r\ndiscussion on Inference sync Dec 5th.\r\n-
renamed provider to service\r\n- added name and description, use name
for the service selector user\r\nfriendly way\r\n- dropped options and
display type dropdown select, use freeform text\r\ninput instead\r\n-
dropped `display` field type, renamed `tooltip` to the
`description`.\r\nProperly updated `ConnectorConfigurationFormItems`
in\r\n`x-pack/plugins/stack_connectors/public/connector_types/lib/dynamic_config/connector_configuration_form_items.tsx`\r\n\r\nUI
with the updates:\r\n<img width=\"1281\" alt=\"Screenshot 2024-12-08 at
10 09
52 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/fdb17dd4-c8e4-496b-85e7-03c363546b8e\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Ying
<ying.mao@elastic.co>","sha":"5b108453ffe823b5d559952f37da1030a79d3352"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203363","number":203363,"mergeCommit":{"message":"[Inference
Connector] Changed UI/UX due to the new RFC for the _inference/_service
(elastic#203363)\n\nRelated
RFC\r\nhttps://docs.google.com/document/d/1DbWpqEKM-MJR2cSJNKLC7RcCNXXQ-_iUShsXKRFKXfk/edit?tab=t.0\r\n\r\n##
Summary\r\n\r\n- removed Task Settings from the UI and schema
definition, due to the\r\ndiscussion on Inference sync Dec 5th.\r\n-
renamed provider to service\r\n- added name and description, use name
for the service selector user\r\nfriendly way\r\n- dropped options and
display type dropdown select, use freeform text\r\ninput instead\r\n-
dropped `display` field type, renamed `tooltip` to the
`description`.\r\nProperly updated `ConnectorConfigurationFormItems`
in\r\n`x-pack/plugins/stack_connectors/public/connector_types/lib/dynamic_config/connector_configuration_form_items.tsx`\r\n\r\nUI
with the updates:\r\n<img width=\"1281\" alt=\"Screenshot 2024-12-08 at
10 09
52 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/fdb17dd4-c8e4-496b-85e7-03c363546b8e\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Ying
<ying.mao@elastic.co>","sha":"5b108453ffe823b5d559952f37da1030a79d3352"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Yuliia Naumenko <jo.naumenko@gmail.com>
  • Loading branch information
pgayvallet and YulNaumenko authored Dec 18, 2024
1 parent f535325 commit 246ef2a
Show file tree
Hide file tree
Showing 15 changed files with 1,915 additions and 548 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45314,7 +45314,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "Paramètres des tâches",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "Type de tâche",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "Configurer la tâche d'inférence. Ces paramètres sont spécifiques au service et au modèle sélectionnés.",
"xpack.stackConnectors.components.inference.taskTypeLabel": "Type de tâche",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "Impossible de trouver des fournisseurs",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "Token d'API",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45163,7 +45163,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "タスク設定",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "タスクタイプ",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "推論タスクを構成します。これらの設定は、選択したサービスおよびモデルに固有です。",
"xpack.stackConnectors.components.inference.taskTypeLabel": "タスクタイプ",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "プロバイダーが見つかりません",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "APIトークン",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45261,7 +45261,6 @@
"xpack.stackConnectors.components.inference.taskTypeDetailsLabel": "任务设置",
"xpack.stackConnectors.components.inference.taskTypeFieldLabel": "任务类型",
"xpack.stackConnectors.components.inference.taskTypeHelpLabel": "配置推理任务。这些设置特定于选定服务和模型。",
"xpack.stackConnectors.components.inference.taskTypeLabel": "任务类型",
"xpack.stackConnectors.components.inference.unableToFindProvidersQueryMessage": "找不到提供商",
"xpack.stackConnectors.components.jira.apiTokenTextFieldLabel": "API 令牌",
"xpack.stackConnectors.components.jira.apiUrlTextFieldLabel": "URL",
Expand Down
23 changes: 3 additions & 20 deletions x-pack/plugins/stack_connectors/common/dynamic_config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
* 2.0.
*/

export enum DisplayType {
TEXTBOX = 'textbox',
TEXTAREA = 'textarea',
NUMERIC = 'numeric',
TOGGLE = 'toggle',
DROPDOWN = 'dropdown',
CHECKABLE = 'checkable',
}

export interface SelectOption {
label: string;
value: string;
Expand All @@ -28,7 +19,6 @@ export interface Dependency {
export enum FieldType {
STRING = 'str',
INTEGER = 'int',
LIST = 'list',
BOOLEAN = 'bool',
}

Expand All @@ -44,21 +34,13 @@ export interface Validation {
}

export interface ConfigProperties {
category?: string;
default_value: string | number | boolean | null;
depends_on: Dependency[];
display: DisplayType;
description: string | null;
label: string;
options?: SelectOption[];
order?: number | null;
placeholder?: string;
required: boolean;
sensitive: boolean;
tooltip: string | null;
updatable: boolean;
type: FieldType;
ui_restrictions: string[];
validations: Validation[];
value: string | number | boolean | null;
}

interface ConfigEntry extends ConfigProperties {
Expand All @@ -68,4 +50,5 @@ interface ConfigEntry extends ConfigProperties {
export interface ConfigEntryView extends ConfigEntry {
isValid: boolean;
validationErrors: string[];
value: string | number | boolean | null;
}
12 changes: 4 additions & 8 deletions x-pack/plugins/stack_connectors/common/inference/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ export type StreamingResponse = TypeOf<typeof StreamingResponseSchema>;

export type FieldsConfiguration = Record<string, ConfigProperties>;

export interface InferenceTaskType {
task_type: string;
configuration: FieldsConfiguration;
}

export interface InferenceProvider {
provider: string;
task_types: InferenceTaskType[];
service: string;
name: string;
task_types: string[];
logo?: string;
configuration: FieldsConfiguration;
configurations: FieldsConfiguration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useMemo, useCallback } from 'react';
import React, { useMemo } from 'react';
import { css } from '@emotion/react';

import {
Expand All @@ -18,7 +18,6 @@ import {
EuiTextColor,
EuiButtonGroup,
EuiPanel,
EuiHorizontalRule,
EuiButtonEmpty,
EuiCopy,
EuiButton,
Expand Down Expand Up @@ -55,7 +54,6 @@ interface AdditionalOptionsConnectorFieldsProps {
onTaskTypeOptionsSelect: (taskType: string, provider?: string) => void;
selectedTaskType?: string;
taskTypeFormFields: ConfigEntryView[];
taskTypeSchema: ConfigEntryView[];
taskTypeOptions: TaskTypeOption[];
}

Expand All @@ -65,35 +63,13 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
isEdit,
taskTypeOptions,
optionalProviderFormFields,
taskTypeFormFields,
taskTypeSchema,
selectedTaskType,
onSetProviderConfigEntry,
onTaskTypeOptionsSelect,
}) => {
const xsFontSize = useEuiFontSize('xs').fontSize;
const { euiTheme } = useEuiTheme();
const { setFieldValue, validateFields } = useFormContext();

const onSetTaskTypeConfigEntry = useCallback(
async (key: string, value: unknown) => {
if (taskTypeSchema) {
const entry: ConfigEntryView | undefined = taskTypeSchema.find(
(p: ConfigEntryView) => p.key === key
);
if (entry) {
if (!config.taskTypeConfig) {
config.taskTypeConfig = {};
}
const newConfig = { ...config.taskTypeConfig };
newConfig[key] = value;
setFieldValue('config.taskTypeConfig', newConfig);
await validateFields(['config.taskTypeConfig']);
}
}
},
[config, setFieldValue, taskTypeSchema, validateFields]
);
const { setFieldValue } = useFormContext();

const taskTypeSettings = useMemo(
() =>
Expand All @@ -103,7 +79,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
<h4>
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeDetailsLabel"
defaultMessage="Task settings"
defaultMessage="Task type"
/>
</h4>
</EuiTitle>
Expand All @@ -116,7 +92,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
>
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeHelpLabel"
defaultMessage="Configure the inference task. These settings are specific to the service and model selected."
defaultMessage="Configure the inference task. Task types are specific to the service and model selected."
/>
</div>
<EuiSpacer size="m" />
Expand All @@ -135,18 +111,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);

return (
<EuiFormRow
id="taskType"
fullWidth
label={
<FormattedMessage
id="xpack.stackConnectors.components.inference.taskTypeLabel"
defaultMessage="Task type"
/>
}
isInvalid={isInvalid}
error={errorMessage}
>
<EuiFormRow id="taskType" fullWidth isInvalid={isInvalid} error={errorMessage}>
{isEdit || readOnly ? (
<EuiButton
css={{
Expand Down Expand Up @@ -186,23 +151,13 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
);
}}
</UseField>
<EuiSpacer size="s" />
<ConnectorConfigurationFormItems
itemsGrow={false}
isLoading={false}
direction="column"
items={taskTypeFormFields}
setConfigEntry={onSetTaskTypeConfigEntry}
/>
</>
) : null,
[
selectedTaskType,
config?.taskType,
config.taskType,
xsFontSize,
euiTheme.colors,
taskTypeFormFields,
onSetTaskTypeConfigEntry,
isEdit,
readOnly,
taskTypeOptions,
Expand Down Expand Up @@ -276,7 +231,7 @@ export const AdditionalOptionsConnectorFields: React.FC<AdditionalOptionsConnect
) : null}

{taskTypeSettings}
<EuiHorizontalRule />
<EuiSpacer size="m" />
<EuiTitle size="xxs" data-test-subj="task-type-details-label">
<h4>
<FormattedMessage
Expand Down
Loading

0 comments on commit 246ef2a

Please sign in to comment.