mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Stack Connectors] Lift feature flag to show organizationId
and projectId
OpenAI headers in UI (#213760)
This commit is contained in:
parent
a6fd5b7e10
commit
c3b3810eee
4 changed files with 44 additions and 59 deletions
|
@ -18,7 +18,6 @@ export const allowedExperimentalValues = Object.freeze({
|
|||
inferenceConnectorOff: false,
|
||||
crowdstrikeConnectorRTROn: true,
|
||||
microsoftDefenderEndpointOn: true,
|
||||
openAIAdditionalHeadersOn: false,
|
||||
});
|
||||
|
||||
export type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
|
||||
|
|
|
@ -14,8 +14,6 @@ import { DEFAULT_OPENAI_MODEL, OpenAiProviderType } from '../../../common/openai
|
|||
import { useKibana } from '@kbn/triggers-actions-ui-plugin/public';
|
||||
import { useGetDashboard } from '../lib/gen_ai/use_get_dashboard';
|
||||
import { createStartServicesMock } from '@kbn/triggers-actions-ui-plugin/public/common/lib/kibana/kibana_react.mock';
|
||||
import { ExperimentalFeaturesService } from '../../common/experimental_features_service';
|
||||
import { experimentalFeaturesMock } from '../../mocks';
|
||||
|
||||
const mockUseKibanaReturnValue = createStartServicesMock();
|
||||
jest.mock('@kbn/triggers-actions-ui-plugin/public/common/lib/kibana', () => ({
|
||||
|
@ -70,12 +68,6 @@ const otherOpenAiConnector = {
|
|||
const navigateToUrl = jest.fn();
|
||||
|
||||
describe('ConnectorFields renders', () => {
|
||||
beforeAll(() => {
|
||||
ExperimentalFeaturesService.init({
|
||||
// @ts-ignore force enable for testing
|
||||
experimentalFeatures: { ...experimentalFeaturesMock, openAIAdditionalHeadersOn: true },
|
||||
});
|
||||
});
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
useKibanaMock().services.application.navigateToUrl = navigateToUrl;
|
||||
|
|
|
@ -31,7 +31,6 @@ import {
|
|||
useFormData,
|
||||
} from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib';
|
||||
import { fieldValidators } from '@kbn/es-ui-shared-plugin/static/forms/helpers';
|
||||
import { ExperimentalFeaturesService } from '../../common/experimental_features_service';
|
||||
import * as i18nAuth from '../../common/auth/translations';
|
||||
import DashboardLink from './dashboard_link';
|
||||
import { OpenAiProviderType } from '../../../common/openai/constants';
|
||||
|
@ -43,7 +42,7 @@ import {
|
|||
otherOpenAiSecrets,
|
||||
openAiSecrets,
|
||||
providerOptions,
|
||||
getOpenAiConfig,
|
||||
openAiConfig,
|
||||
} from './constants';
|
||||
|
||||
const { emptyField } = fieldValidators;
|
||||
|
@ -53,7 +52,6 @@ const ConnectorFields: React.FC<ActionConnectorFieldsProps> = ({ readOnly, isEdi
|
|||
const [{ config, __internal__, id, name }] = useFormData({
|
||||
watch: ['config.apiProvider', '__internal__.hasHeaders'],
|
||||
});
|
||||
const enabledAdditionalHeaders = ExperimentalFeaturesService.get().openAIAdditionalHeadersOn;
|
||||
const hasHeaders = __internal__ != null ? __internal__.hasHeaders : false;
|
||||
const hasHeadersDefaultValue = !!getFieldDefaultValue<boolean | undefined>('config.headers');
|
||||
|
||||
|
@ -93,7 +91,7 @@ const ConnectorFields: React.FC<ActionConnectorFieldsProps> = ({ readOnly, isEdi
|
|||
<SimpleConnectorForm
|
||||
isEdit={isEdit}
|
||||
readOnly={readOnly}
|
||||
configFormSchema={getOpenAiConfig(enabledAdditionalHeaders)}
|
||||
configFormSchema={openAiConfig}
|
||||
secretsFormSchema={openAiSecrets}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -54,7 +54,7 @@ export const getDefaultBody = (config?: Config) => {
|
|||
return DEFAULT_BODY;
|
||||
};
|
||||
|
||||
export const getOpenAiConfig = (enabledAdditionalHeaders: boolean): ConfigFieldSchema[] => [
|
||||
export const openAiConfig: ConfigFieldSchema[] = [
|
||||
{
|
||||
id: 'apiUrl',
|
||||
label: i18n.API_URL_LABEL,
|
||||
|
@ -89,51 +89,47 @@ export const getOpenAiConfig = (enabledAdditionalHeaders: boolean): ConfigFieldS
|
|||
),
|
||||
defaultValue: DEFAULT_OPENAI_MODEL,
|
||||
},
|
||||
...(enabledAdditionalHeaders
|
||||
? [
|
||||
{
|
||||
id: 'organizationId',
|
||||
label: i18n.ORG_ID_LABEL,
|
||||
isRequired: false,
|
||||
helpText: (
|
||||
<FormattedMessage
|
||||
defaultMessage="For users who belong to multiple organizations. Organization IDs can be found on your Organization settings page."
|
||||
id="xpack.stackConnectors.components.genAi.openAiOrgId"
|
||||
/>
|
||||
),
|
||||
euiFieldProps: {
|
||||
append: (
|
||||
<EuiText size="xs" color="subdued">
|
||||
{i18n.OPTIONAL_LABEL}
|
||||
</EuiText>
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'projectId',
|
||||
label: i18n.PROJECT_ID_LABEL,
|
||||
isRequired: false,
|
||||
helpText: (
|
||||
<FormattedMessage
|
||||
defaultMessage="For users who are accessing their projects through their legacy user API key. Project IDs can be found on your General settings page by selecting the specific project."
|
||||
id="xpack.stackConnectors.components.genAi.openAiProjectId"
|
||||
/>
|
||||
),
|
||||
euiFieldProps: {
|
||||
autocomplete: 'new-password',
|
||||
autoComplete: 'new-password',
|
||||
onFocus: (event: React.FocusEvent<HTMLInputElement>) => {
|
||||
event.target.setAttribute('autocomplete', 'new-password');
|
||||
},
|
||||
append: (
|
||||
<EuiText size="xs" color="subdued">
|
||||
{i18n.OPTIONAL_LABEL}
|
||||
</EuiText>
|
||||
),
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'organizationId',
|
||||
label: i18n.ORG_ID_LABEL,
|
||||
isRequired: false,
|
||||
helpText: (
|
||||
<FormattedMessage
|
||||
defaultMessage="For users who belong to multiple organizations. Organization IDs can be found on your Organization settings page."
|
||||
id="xpack.stackConnectors.components.genAi.openAiOrgId"
|
||||
/>
|
||||
),
|
||||
euiFieldProps: {
|
||||
append: (
|
||||
<EuiText size="xs" color="subdued">
|
||||
{i18n.OPTIONAL_LABEL}
|
||||
</EuiText>
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'projectId',
|
||||
label: i18n.PROJECT_ID_LABEL,
|
||||
isRequired: false,
|
||||
helpText: (
|
||||
<FormattedMessage
|
||||
defaultMessage="For users who are accessing their projects through their legacy user API key. Project IDs can be found on your General settings page by selecting the specific project."
|
||||
id="xpack.stackConnectors.components.genAi.openAiProjectId"
|
||||
/>
|
||||
),
|
||||
euiFieldProps: {
|
||||
autocomplete: 'new-password',
|
||||
autoComplete: 'new-password',
|
||||
onFocus: (event: React.FocusEvent<HTMLInputElement>) => {
|
||||
event.target.setAttribute('autocomplete', 'new-password');
|
||||
},
|
||||
append: (
|
||||
<EuiText size="xs" color="subdued">
|
||||
{i18n.OPTIONAL_LABEL}
|
||||
</EuiText>
|
||||
),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const azureAiConfig: ConfigFieldSchema[] = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue