From e864880173a9487c11bc97f20238435754bbdcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Efe=20G=C3=BCrkan=20YALAMAN?= Date: Tue, 12 Mar 2024 11:29:59 +0100 Subject: [PATCH] [Search] Update configuration updates immediately after configuration changed (#178171) ## Summary https://github.com/elastic/kibana/assets/1410658/9646ef5a-0a50-481e-93ae-864cc404d5d7 ### Checklist Delete any items that are not applicable to this PR. - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed --- .../connector_configuration.tsx | 12 ++++----- .../connector_detail/connector_view_logic.ts | 26 +++++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_configuration.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_configuration.tsx index 5319f04042389..26df487caf199 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_configuration.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_configuration.tsx @@ -37,7 +37,6 @@ import { HttpLogic } from '../../../shared/http'; import { LicensingLogic } from '../../../shared/licensing'; import { EuiButtonTo, EuiLinkTo } from '../../../shared/react_router_helpers'; import { GenerateConnectorApiKeyApiLogic } from '../../api/connector/generate_connector_api_key_api_logic'; -import { ConnectorConfigurationApiLogic } from '../../api/connector/update_connector_configuration_api_logic'; import { CONNECTOR_DETAIL_TAB_PATH } from '../../routes'; import { SyncsContextMenu } from '../search_index/components/header_actions/syncs_context_menu'; import { ApiKeyConfig } from '../search_index/connector/api_key_configuration'; @@ -54,13 +53,12 @@ import { NativeConnectorConfiguration } from './native_connector_configuration'; export const ConnectorConfiguration: React.FC = () => { const { data: apiKeyData } = useValues(GenerateConnectorApiKeyApiLogic); - const { fetchConnector } = useActions(ConnectorViewLogic); - const { index, isLoading, connector } = useValues(ConnectorViewLogic); + const { index, isLoading, connector, updateConnectorConfigurationStatus } = + useValues(ConnectorViewLogic); const cloudContext = useCloudDetails(); const { hasPlatinumLicense } = useValues(LicensingLogic); - const { status } = useValues(ConnectorConfigurationApiLogic); - const { makeRequest } = useActions(ConnectorConfigurationApiLogic); const { errorConnectingMessage, http } = useValues(HttpLogic); + const { fetchConnector, updateConnectorConfiguration } = useActions(ConnectorViewLogic); if (!connector) { return <>; @@ -195,9 +193,9 @@ export const ConnectorConfiguration: React.FC = () => { - makeRequest({ + updateConnectorConfiguration({ configuration, connectorId: connector.id, }) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_view_logic.ts b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_view_logic.ts index c06a82307f501..a1eef12c28e86 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_view_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_view_logic.ts @@ -23,9 +23,12 @@ import { CachedFetchConnectorByIdApiLogicValues, } from '../../api/connector/cached_fetch_connector_by_id_api_logic'; +import { + ConnectorConfigurationApiLogic, + PostConnectorConfigurationActions, +} from '../../api/connector/update_connector_configuration_api_logic'; import { FetchIndexActions, FetchIndexApiLogic } from '../../api/index/fetch_index_api_logic'; import { ElasticsearchViewIndex } from '../../types'; -import { IndexNameActions, IndexNameLogic } from '../search_index/index_name_logic'; export interface ConnectorViewActions { fetchConnector: CachedFetchConnectorByIdApiLogicActions['makeRequest']; @@ -38,10 +41,12 @@ export interface ConnectorViewActions { fetchIndexApiError: FetchIndexActions['apiError']; fetchIndexApiReset: FetchIndexActions['apiReset']; fetchIndexApiSuccess: FetchIndexActions['apiSuccess']; - setIndexName: IndexNameActions['setIndexName']; + updateConnectorConfiguration: PostConnectorConfigurationActions['makeRequest']; + updateConnectorConfigurationSuccess: PostConnectorConfigurationActions['apiSuccess']; } export interface ConnectorViewValues { + updateConnectorConfigurationStatus: Status; connector: Connector | undefined; connectorData: CachedFetchConnectorByIdApiLogicValues['connectorData']; connectorError: string | undefined; @@ -75,8 +80,6 @@ export const ConnectorViewLogic = kea ({ @@ -107,10 +117,10 @@ export const ConnectorViewLogic = kea ({ - fetchConnectorApiSuccess: (response) => { - if (response.connector?.index_name) { - actions.setIndexName(response.connector.index_name); + listeners: ({ actions, values }) => ({ + updateConnectorConfigurationSuccess: () => { + if (values.connectorId) { + actions.fetchConnector({ connectorId: values.connectorId }); } }, }),