Skip to content

Commit

Permalink
[8.x] [Search] New search connector creation flow (#187582) (#196293)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Search] New search connector creation flow
(#187582)](#187582)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"José Luis
González","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-15T12:09:30Z","message":"[Search]
New search connector creation flow (#187582)\n\n## Summary\r\n\r\nThis
PR brings a new and dedicated search connector creation flow for\r\nES3
and
ESS.\r\n[Figma\r\nPrototype](https://www.figma.com/proto/eKQr4HYlz0v9pTofRPWIyH/Ingestion-methods-flow?page-id=411%3A158867&node-id=411-158870&viewport=3831%2C-1905%2C1.23&t=ZP9e3LtaSeJ5FMAz-9&scaling=min-zoom&content-scaling=fixed&starting-point-node-id=411%3A158870&show-proto-sidebar=1)\r\n\r\n![CleanShot
2024-07-04 at 16
27\r\n21](https://github.com/elastic/kibana/assets/3108788/45e61110-f222-4bad-b24d-87ebad07ca98)\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Efe Gürkan YALAMAN <[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"63e116bb078c29c70e4e23cba1c88d0ac022801d","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:EnterpriseSearch","backport:prev-minor","v8.16.0"],"title":"[Search]
New search connector creation
flow","number":187582,"url":"https://github.com/elastic/kibana/pull/187582","mergeCommit":{"message":"[Search]
New search connector creation flow (#187582)\n\n## Summary\r\n\r\nThis
PR brings a new and dedicated search connector creation flow for\r\nES3
and
ESS.\r\n[Figma\r\nPrototype](https://www.figma.com/proto/eKQr4HYlz0v9pTofRPWIyH/Ingestion-methods-flow?page-id=411%3A158867&node-id=411-158870&viewport=3831%2C-1905%2C1.23&t=ZP9e3LtaSeJ5FMAz-9&scaling=min-zoom&content-scaling=fixed&starting-point-node-id=411%3A158870&show-proto-sidebar=1)\r\n\r\n![CleanShot
2024-07-04 at 16
27\r\n21](https://github.com/elastic/kibana/assets/3108788/45e61110-f222-4bad-b24d-87ebad07ca98)\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Efe Gürkan YALAMAN <[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"63e116bb078c29c70e4e23cba1c88d0ac022801d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/187582","number":187582,"mergeCommit":{"message":"[Search]
New search connector creation flow (#187582)\n\n## Summary\r\n\r\nThis
PR brings a new and dedicated search connector creation flow for\r\nES3
and
ESS.\r\n[Figma\r\nPrototype](https://www.figma.com/proto/eKQr4HYlz0v9pTofRPWIyH/Ingestion-methods-flow?page-id=411%3A158867&node-id=411-158870&viewport=3831%2C-1905%2C1.23&t=ZP9e3LtaSeJ5FMAz-9&scaling=min-zoom&content-scaling=fixed&starting-point-node-id=411%3A158870&show-proto-sidebar=1)\r\n\r\n![CleanShot
2024-07-04 at 16
27\r\n21](https://github.com/elastic/kibana/assets/3108788/45e61110-f222-4bad-b24d-87ebad07ca98)\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Efe Gürkan YALAMAN <[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"63e116bb078c29c70e4e23cba1c88d0ac022801d"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: José Luis González <[email protected]>
  • Loading branch information
kibanamachine and JoseLuisGJ authored Oct 15, 2024
1 parent 0e205fa commit 529d04f
Show file tree
Hide file tree
Showing 34 changed files with 2,336 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface ConnectorConfigurationProps {
hasPlatinumLicense: boolean;
isLoading: boolean;
saveConfig: (configuration: Record<string, string | number | boolean | null>) => void;
saveAndSync?: (configuration: Record<string, string | number | boolean | null>) => void;
stackManagementLink?: string;
subscriptionLink?: string;
children?: React.ReactNode;
Expand Down Expand Up @@ -90,6 +91,7 @@ export const ConnectorConfigurationComponent: FC<
hasPlatinumLicense,
isLoading,
saveConfig,
saveAndSync,
subscriptionLink,
stackManagementLink,
}) => {
Expand Down Expand Up @@ -166,6 +168,12 @@ export const ConnectorConfigurationComponent: FC<
saveConfig(config);
setIsEditing(false);
}}
{...(saveAndSync && {
saveAndSync: (config) => {
saveAndSync(config);
setIsEditing(false);
},
})}
/>
) : (
uncategorizedDisplayList.length > 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface ConnectorConfigurationForm {
isLoading: boolean;
isNative: boolean;
saveConfig: (config: Record<string, string | number | boolean | null>) => void;
saveAndSync?: (config: Record<string, string | number | boolean | null>) => void;
stackManagementHref?: string;
subscriptionLink?: string;
}
Expand All @@ -60,6 +61,7 @@ export const ConnectorConfigurationForm: React.FC<ConnectorConfigurationForm> =
isLoading,
isNative,
saveConfig,
saveAndSync,
}) => {
const [localConfig, setLocalConfig] = useState<ConnectorConfiguration>(configuration);
const [configView, setConfigView] = useState<ConfigView>(
Expand Down Expand Up @@ -167,19 +169,7 @@ export const ConnectorConfigurationForm: React.FC<ConnectorConfigurationForm> =
)}
<EuiSpacer />
<EuiFormRow>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="entSearchContent-connector-configuration-saveConfiguration"
data-telemetry-id="entSearchContent-connector-configuration-saveConfiguration"
type="submit"
isLoading={isLoading}
>
{i18n.translate('searchConnectors.configurationConnector.config.submitButton.title', {
defaultMessage: 'Save configuration',
})}
</EuiButton>
</EuiFlexItem>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-telemetry-id="entSearchContent-connector-configuration-cancelEdit"
Expand All @@ -196,6 +186,38 @@ export const ConnectorConfigurationForm: React.FC<ConnectorConfigurationForm> =
)}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="entSearchContent-connector-configuration-saveConfiguration"
data-telemetry-id="entSearchContent-connector-configuration-saveConfiguration"
type="submit"
isLoading={isLoading}
>
{i18n.translate('searchConnectors.configurationConnector.config.submitButton.title', {
defaultMessage: 'Save',
})}
</EuiButton>
</EuiFlexItem>
{saveAndSync && (
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="entSearchContent-connector-configuration-saveConfiguration"
data-telemetry-id="entSearchContent-connector-configuration-saveConfiguration"
isLoading={isLoading}
fill
onClick={() => {
saveAndSync(configViewToConfigValues(configView));
}}
>
{i18n.translate(
'searchConnectors.configurationConnector.config.submitButton.title',
{
defaultMessage: 'Save and sync',
}
)}
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFormRow>
</EuiForm>
Expand Down
54 changes: 54 additions & 0 deletions x-pack/plugins/enterprise_search/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import dedent from 'dedent';

import {
ENTERPRISE_SEARCH_APP_ID,
ENTERPRISE_SEARCH_CONTENT_APP_ID,
Expand Down Expand Up @@ -210,6 +212,58 @@ export const SEARCH_RELEVANCE_PLUGIN = {
SUPPORT_URL: 'https://discuss.elastic.co/c/enterprise-search/',
};

export const CREATE_CONNECTOR_PLUGIN = {
CLI_SNIPPET: dedent`./bin/connectors connector create
--index-name my-index
--index-language en
--from-file config.yml
`,
CONSOLE_SNIPPET: dedent`# Create an index
PUT /my-index-000001
{
"settings": {
"index": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}
}
# Create an API key
POST /_security/api_key
{
"name": "my-api-key",
"expiration": "1d",
"role_descriptors":
{
"role-a": {
"cluster": ["all"],
"indices": [
{
"names": ["index-a*"],
"privileges": ["read"]
}
]
},
"role-b": {
"cluster": ["all"],
"indices": [
{
"names": ["index-b*"],
"privileges": ["all"]
}]
}
}, "metadata":
{ "application": "my-application",
"environment": {
"level": 1,
"trusted": true,
"tags": ["dev", "staging"]
}
}
}`,
};

export const LICENSED_SUPPORT_URL = 'https://support.elastic.co';

export const JSON_HEADER = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

interface AddConnectorValue {
Expand All @@ -20,11 +20,17 @@ export interface AddConnectorApiLogicArgs {
language: string | null;
name: string;
serviceType?: string;
// Without a proper refactoring there is no good way to chain actions.
// This prop is simply passed back with the result to let listeners
// know what was the intent of the request. And call the next action
// accordingly.
uiFlags?: Record<string, boolean>;
}

export interface AddConnectorApiLogicResponse {
id: string;
indexName: string;
uiFlags?: Record<string, boolean>;
}

export const addConnector = async ({
Expand All @@ -34,6 +40,7 @@ export const addConnector = async ({
isNative,
language,
serviceType,
uiFlags,
}: AddConnectorApiLogicArgs): Promise<AddConnectorApiLogicResponse> => {
const route = '/internal/enterprise_search/connectors';

Expand All @@ -54,7 +61,12 @@ export const addConnector = async ({
return {
id: result.id,
indexName: result.index_name,
uiFlags,
};
};

export const AddConnectorApiLogic = createApiLogic(['add_connector_api_logic'], addConnector);
export type AddConnectorApiLogicActions = Actions<
AddConnectorApiLogicArgs,
AddConnectorApiLogicResponse
>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

export interface GenerateConfigApiArgs {
connectorId: string;
}

export type GenerateConfigApiActions = Actions<GenerateConfigApiArgs, {}>;

export const generateConnectorConfig = async ({ connectorId }: GenerateConfigApiArgs) => {
const route = `/internal/enterprise_search/connectors/${connectorId}/generate_config`;
return await HttpLogic.values.http.post(route);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,38 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

export interface GenerateConnectorNamesApiArgs {
connectorName?: string;
connectorType?: string;
}

export interface GenerateConnectorNamesApiResponse {
apiKeyName: string;
connectorName: string;
indexName: string;
}

export const generateConnectorNames = async (
{ connectorType }: GenerateConnectorNamesApiArgs = { connectorType: 'custom' }
{ connectorType, connectorName }: GenerateConnectorNamesApiArgs = { connectorType: 'custom' }
) => {
if (connectorType === '') {
connectorType = 'custom';
}
const route = `/internal/enterprise_search/connectors/generate_connector_name`;
return await HttpLogic.values.http.post(route, {
body: JSON.stringify({ connectorType }),
body: JSON.stringify({ connectorName, connectorType }),
});
};

export const GenerateConnectorNamesApiLogic = createApiLogic(
['generate_config_api_logic'],
['generate_connector_names_api_logic'],
generateConnectorNames
);

export type GenerateConnectorNamesApiLogicActions = Actions<
GenerateConnectorNamesApiArgs,
GenerateConnectorNamesApiResponse
>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ import { i18n } from '@kbn/i18n';

export interface GenerateConfigButtonProps {
connectorId: string;
disabled?: boolean;
generateConfiguration: (params: { connectorId: string }) => void;
isGenerateLoading: boolean;
}
export const GenerateConfigButton: React.FC<GenerateConfigButtonProps> = ({
connectorId,
disabled,
generateConfiguration,
isGenerateLoading,
isGenerateLoading = false,
}) => {
return (
<EuiFlexGroup direction="row" gutterSize="xs" responsive={false} alignItems="center">
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="entSearchContent-connector-configuration-generateConfigButton"
data-telemetry-id="entSearchContent-connector-configuration-generateConfigButton"
disabled={disabled}
fill
iconType="sparkles"
isLoading={isGenerateLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { CONNECTOR_DETAIL_PATH, SEARCH_INDEX_PATH } from '../../../routes';
export interface GeneratedConfigFieldsProps {
apiKey?: ApiKey;
connector: Connector;
generateApiKey: () => void;
generateApiKey?: () => void;
isGenerateLoading: boolean;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ export const GeneratedConfigFields: React.FC<GeneratedConfigFieldsProps> = ({
};

const onConfirm = () => {
generateApiKey();
if (generateApiKey) generateApiKey();
setIsModalVisible(false);
};

Expand Down Expand Up @@ -222,16 +222,18 @@ export const GeneratedConfigFields: React.FC<GeneratedConfigFieldsProps> = ({
<EuiFlexItem>
<EuiCode>{apiKey?.encoded}</EuiCode>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="enterpriseSearchGeneratedConfigFieldsButton"
size="xs"
iconType="refresh"
isLoading={isGenerateLoading}
onClick={refreshButtonClick}
disabled={!connector.index_name}
/>
</EuiFlexItem>
{generateApiKey && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="enterpriseSearchGeneratedConfigFieldsButton"
size="xs"
iconType="refresh"
isLoading={isGenerateLoading}
onClick={refreshButtonClick}
disabled={!connector.index_name}
/>
</EuiFlexItem>
)}
<EuiFlexItem grow={false}>
<EuiButtonIcon
size="xs"
Expand All @@ -245,16 +247,18 @@ export const GeneratedConfigFields: React.FC<GeneratedConfigFieldsProps> = ({
</EuiCopy>
</EuiFlexItem>
) : (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="enterpriseSearchGeneratedConfigFieldsButton"
size="xs"
iconType="refresh"
isLoading={isGenerateLoading}
onClick={refreshButtonClick}
disabled={!connector.index_name}
/>
</EuiFlexItem>
generateApiKey && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="enterpriseSearchGeneratedConfigFieldsButton"
size="xs"
iconType="refresh"
isLoading={isGenerateLoading}
onClick={refreshButtonClick}
disabled={!connector.index_name}
/>
</EuiFlexItem>
)
)}
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Loading

0 comments on commit 529d04f

Please sign in to comment.