[8.10] [Enterprise Search] Fix crawler domain management bugs (#165820) (#165873)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Enterprise Search] Fix crawler domain management bugs
(#165820)](https://github.com/elastic/kibana/pull/165820)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Jedrzej
Blaszyk","email":"jedrazb@gmail.com"},"sourceCommit":{"committedDate":"2023-09-06T15:53:09Z","message":"[Enterprise
Search] Fix crawler domain management bugs (#165820)\n\n##
Summary\r\n\r\nTackles 2 known crawler domain management issues:\r\n-
[Crawler manage domain doesn't clear data when creating
multiple\r\nCrawler\r\nIndices](https://github.com/elastic/enterprise-search-team/issues/5659)\r\n-
[Crawler with multiple domain doesn't show newly added domains
when\r\n\"All domains\"
button\r\nclicked](https://github.com/elastic/enterprise-search-team/issues/5660)\r\n\r\nSolution:\r\n-
When domain is added successfully we perform 2 additional steps:\r\n-
Fetch current domain list into domain management logic (this solves
2\r\nissues but uncovers another issue): Crawler manage domain doesn't
clear\r\nuser input field for domain, so when adding new crawler index
this field\r\nwill be pre-populated with the last user input\r\n-
Therfore, we also clear user input from add domain form on
successful\r\nsubmission of a domain\r\n
\r\nVideo:\r\n\r\n\r\n\r\na2ba8941-cb76-4d97-9587-3392e815a338","sha":"852513a1bd37e5e4e2ae8cfb735b57249b4e1148","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:EnterpriseSearch","v8.10.0","v8.11.0"],"number":165820,"url":"https://github.com/elastic/kibana/pull/165820","mergeCommit":{"message":"[Enterprise
Search] Fix crawler domain management bugs (#165820)\n\n##
Summary\r\n\r\nTackles 2 known crawler domain management issues:\r\n-
[Crawler manage domain doesn't clear data when creating
multiple\r\nCrawler\r\nIndices](https://github.com/elastic/enterprise-search-team/issues/5659)\r\n-
[Crawler with multiple domain doesn't show newly added domains
when\r\n\"All domains\"
button\r\nclicked](https://github.com/elastic/enterprise-search-team/issues/5660)\r\n\r\nSolution:\r\n-
When domain is added successfully we perform 2 additional steps:\r\n-
Fetch current domain list into domain management logic (this solves
2\r\nissues but uncovers another issue): Crawler manage domain doesn't
clear\r\nuser input field for domain, so when adding new crawler index
this field\r\nwill be pre-populated with the last user input\r\n-
Therfore, we also clear user input from add domain form on
successful\r\nsubmission of a domain\r\n
\r\nVideo:\r\n\r\n\r\n\r\na2ba8941-cb76-4d97-9587-3392e815a338","sha":"852513a1bd37e5e4e2ae8cfb735b57249b4e1148"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165820","number":165820,"mergeCommit":{"message":"[Enterprise
Search] Fix crawler domain management bugs (#165820)\n\n##
Summary\r\n\r\nTackles 2 known crawler domain management issues:\r\n-
[Crawler manage domain doesn't clear data when creating
multiple\r\nCrawler\r\nIndices](https://github.com/elastic/enterprise-search-team/issues/5659)\r\n-
[Crawler with multiple domain doesn't show newly added domains
when\r\n\"All domains\"
button\r\nclicked](https://github.com/elastic/enterprise-search-team/issues/5660)\r\n\r\nSolution:\r\n-
When domain is added successfully we perform 2 additional steps:\r\n-
Fetch current domain list into domain management logic (this solves
2\r\nissues but uncovers another issue): Crawler manage domain doesn't
clear\r\nuser input field for domain, so when adding new crawler index
this field\r\nwill be pre-populated with the last user input\r\n-
Therfore, we also clear user input from add domain form on
successful\r\nsubmission of a domain\r\n
\r\nVideo:\r\n\r\n\r\n\r\na2ba8941-cb76-4d97-9587-3392e815a338","sha":"852513a1bd37e5e4e2ae8cfb735b57249b4e1148"}}]}]
BACKPORT-->

Co-authored-by: Jedrzej Blaszyk <jedrazb@gmail.com>
This commit is contained in:
Kibana Machine 2023-09-07 05:40:46 -04:00 committed by GitHub
parent dab283439d
commit d134492cba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -21,6 +21,14 @@ jest.mock('../../crawler_logic', () => ({
},
}));
jest.mock('../domain_management_logic', () => ({
DomainManagementLogic: {
actions: {
getDomains: jest.fn(),
},
},
}));
jest.mock('./utils', () => ({
...(jest.requireActual('./utils') as object),
getDomainWithProtocol: jest.fn().mockImplementation((domain) => domain),

View file

@ -9,6 +9,7 @@ import { kea, MakeLogicType } from 'kea';
import { i18n } from '@kbn/i18n';
import { DEFAULT_META } from '../../../../../../shared/constants';
import { generateEncodedPath } from '../../../../../../shared/encode_path_params';
import { flashSuccessToast } from '../../../../../../shared/flash_messages';
import { getErrorsFromHttpResponse } from '../../../../../../shared/flash_messages/handle_api_errors';
@ -28,6 +29,7 @@ import {
import { SEARCH_INDEX_CRAWLER_DOMAIN_DETAIL_PATH } from '../../../../../routes';
import { IndexNameLogic } from '../../../index_name_logic';
import { CrawlerLogic } from '../../crawler_logic';
import { DomainManagementLogic } from '../domain_management_logic';
import {
domainValidationFailureResultChange,
@ -252,6 +254,8 @@ export const AddDomainLogic = kea<MakeLogicType<AddDomainLogicValues, AddDomainL
})
);
CrawlerLogic.actions.fetchCrawlerData();
DomainManagementLogic.actions.getDomains(DEFAULT_META);
actions.clearDomainFormInputValue();
},
performDomainValidationStep: async ({ stepName, checks }) => {
const { http } = HttpLogic.values;