Skip to content

Commit

Permalink
[Search] Update configuration updates immediately after configuration…
Browse files Browse the repository at this point in the history
… changed (elastic#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
  • Loading branch information
efegurkan authored Mar 12, 2024
1 parent d2d0c83 commit e864880
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 <></>;
Expand Down Expand Up @@ -195,9 +193,9 @@ export const ConnectorConfiguration: React.FC = () => {
<ConnectorConfigurationComponent
connector={connector}
hasPlatinumLicense={hasPlatinumLicense}
isLoading={status === Status.LOADING}
isLoading={updateConnectorConfigurationStatus === Status.LOADING}
saveConfig={(configuration) =>
makeRequest({
updateConnectorConfiguration({
configuration,
connectorId: connector.id,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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;
Expand Down Expand Up @@ -75,8 +80,6 @@ export const ConnectorViewLogic = kea<MakeLogicType<ConnectorViewValues, Connect
actions: {},
connect: {
actions: [
IndexNameLogic,
['setIndexName'],
CachedFetchConnectorByIdApiLogic,
[
'makeRequest as fetchConnector',
Expand All @@ -93,12 +96,19 @@ export const ConnectorViewLogic = kea<MakeLogicType<ConnectorViewValues, Connect
'apiError as fetchIndexApiError',
'apiReset as fetchIndexApiReset',
],
ConnectorConfigurationApiLogic,
[
'makeRequest as updateConnectorConfiguration',
'apiSuccess as updateConnectorConfigurationSuccess',
],
],
values: [
CachedFetchConnectorByIdApiLogic,
['status as fetchConnectorApiStatus', 'connectorData', 'isInitialLoading'],
FetchIndexApiLogic,
['data as index', 'status as fetchIndexApiStatus'],
ConnectorConfigurationApiLogic,
['status as updateConnectorConfigurationStatus'],
],
},
events: ({ actions }) => ({
Expand All @@ -107,10 +117,10 @@ export const ConnectorViewLogic = kea<MakeLogicType<ConnectorViewValues, Connect
actions.fetchConnectorApiReset();
},
}),
listeners: ({ actions }) => ({
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 });
}
},
}),
Expand Down

0 comments on commit e864880

Please sign in to comment.