Skip to content

Commit

Permalink
[8.x] [Fix][Synonyms UI]Add navigation link to the Detail breadcrumb. (
Browse files Browse the repository at this point in the history
…#209574) (#210670)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fix][Synonyms UI]Add navigation link to the Detail breadcrumb.
(#209574)](#209574)

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

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

<!--BACKPORT [{"author":{"name":"Efe Gürkan
YALAMAN","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-11T17:57:11Z","message":"[Fix][Synonyms
UI]Add navigation link to the Detail breadcrumb. (#209574)\n\n##
Summary\r\n\r\n<img width=\"1332\" alt=\"Screenshot 2025-02-04 at 18 18
12\"\r\nsrc=\"https://github.com/user-attachments/assets/5bab6b16-ccf8-4ae5-ae70-8db81360db84\"\r\n/>\r\n\r\nAdds
navigation link to move back to synonyms set list.\r\nFixes missing
invalidation when a synonym rule is set.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] 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/src/platform/packages/shared/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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cce32a9474d6ac41cf18d8f7503ea274e6b5baf6","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","Team:Search","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Fix][Synonyms
UI]Add navigation link to the Detail
breadcrumb.","number":209574,"url":"https://github.com/elastic/kibana/pull/209574","mergeCommit":{"message":"[Fix][Synonyms
UI]Add navigation link to the Detail breadcrumb. (#209574)\n\n##
Summary\r\n\r\n<img width=\"1332\" alt=\"Screenshot 2025-02-04 at 18 18
12\"\r\nsrc=\"https://github.com/user-attachments/assets/5bab6b16-ccf8-4ae5-ae70-8db81360db84\"\r\n/>\r\n\r\nAdds
navigation link to move back to synonyms set list.\r\nFixes missing
invalidation when a synonym rule is set.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] 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/src/platform/packages/shared/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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cce32a9474d6ac41cf18d8f7503ea274e6b5baf6"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209574","number":209574,"mergeCommit":{"message":"[Fix][Synonyms
UI]Add navigation link to the Detail breadcrumb. (#209574)\n\n##
Summary\r\n\r\n<img width=\"1332\" alt=\"Screenshot 2025-02-04 at 18 18
12\"\r\nsrc=\"https://github.com/user-attachments/assets/5bab6b16-ccf8-4ae5-ae70-8db81360db84\"\r\n/>\r\n\r\nAdds
navigation link to move back to synonyms set list.\r\nFixes missing
invalidation when a synonym rule is set.\r\n\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] 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/src/platform/packages/shared/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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cce32a9474d6ac41cf18d8f7503ea274e6b5baf6"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Efe Gürkan YALAMAN <[email protected]>
  • Loading branch information
kibanamachine and efegurkan authored Feb 11, 2025
1 parent b28c80e commit 32a3b22
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const SYNONYMS_RULE_FETCH_QUERY_KEY = 'synonyms-rule-fetch';
export const SYNONYMS_SETS_QUERY_KEY = 'synonyms-sets-fetch';
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiText,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { docLinks } from '../../../common/doc_links';
import { useKibana } from '../../hooks/use_kibana';
import { SynonymSets } from '../synonym_sets/synonym_sets';
import { useFetchSynonymsSets } from '../../hooks/use_fetch_synonyms_sets';
Expand Down Expand Up @@ -50,7 +51,12 @@ export const SearchSynonymsOverview = () => {
rightSideItems={[
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiLink data-test-subj="searchSynonymsSearchSynonymsOverviewApiDocumentationLink">
<EuiLink
data-test-subj="searchSynonymsSearchSynonymsOverviewApiDocumentationLink"
external
target="_blank"
href={docLinks.synonymsApi}
>
<FormattedMessage
id="xpack.searchSynonyms.synonymsSetDetail.documentationLink"
defaultMessage="API Documentation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { useParams } from 'react-router-dom';
import React, { useMemo } from 'react';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { i18n } from '@kbn/i18n';
import { PLUGIN_ROUTE_ROOT } from '../../../common/api_routes';
import { useKibana } from '../../hooks/use_kibana';
import { SynonymsSetRuleTable } from './synonyms_set_rule_table';
import { ConnectToApiButton } from '../connect_to_api/connect_to_api_button';
Expand All @@ -18,7 +20,7 @@ export const SynonymsSetDetail = () => {
synonymsSetId?: string;
}>();
const {
services: { console: consolePlugin, history, searchNavigation },
services: { console: consolePlugin, history, searchNavigation, http, application },
} = useKibana();

const embeddableConsole = useMemo(
Expand All @@ -40,6 +42,23 @@ export const SynonymsSetDetail = () => {
pageTitle={synonymsSetId}
restrictWidth
color="primary"
breadcrumbs={[
{
text: (
<>
{i18n.translate('xpack.searchSynonyms.viewAll', {
defaultMessage: 'View all',
})}
</>
),
color: 'primary',
'aria-current': false,
onClick: (e) => {
e.preventDefault();
application.navigateToUrl(http.basePath.prepend(PLUGIN_ROUTE_ROOT));
},
},
]}
rightSideItems={[
<ConnectToApiButton
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { useQueryClient, useMutation } from '@tanstack/react-query';
import { i18n } from '@kbn/i18n';
import { KibanaServerError } from '@kbn/kibana-utils-plugin/common';
import { SYNONYMS_RULE_FETCH_QUERY_KEY, SYNONYMS_SETS_QUERY_KEY } from '../../common/constants';
import { useKibana } from './use_kibana';

interface MutationArgs {
Expand All @@ -28,8 +29,9 @@ export const useDeleteSynonymRule = (onSuccess?: () => void, onError?: (error: s
);
},
{
onSuccess: (_, { synonymsSetId, ruleId }) => {
queryClient.invalidateQueries(['synonyms-rule-delete', synonymsSetId, ruleId]);
onSuccess: (_, { ruleId }) => {
queryClient.invalidateQueries([SYNONYMS_RULE_FETCH_QUERY_KEY]);
queryClient.invalidateQueries([SYNONYMS_SETS_QUERY_KEY]);
notifications?.toasts?.addSuccess({
title: i18n.translate('xpack.searchSynonyms.deleteSynonymRuleSuccess', {
defaultMessage: 'Synonym rule {ruleId} deleted',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { i18n } from '@kbn/i18n';
import { KibanaServerError } from '@kbn/kibana-utils-plugin/common';
import { SYNONYMS_SETS_QUERY_KEY } from '../../common/constants';
import { useKibana } from './use_kibana';

interface MutationArgs {
Expand All @@ -28,7 +29,7 @@ export const useDeleteSynonymsSet = (onSuccess?: () => void, onError?: (error: s
},
{
onSuccess: (_, { synonymsSetId }) => {
queryClient.invalidateQueries(['synonyms-sets-fetch']);
queryClient.invalidateQueries([SYNONYMS_SETS_QUERY_KEY]);
notifications?.toasts?.addSuccess({
title: i18n.translate('xpack.searchSynonyms.deleteSynonymsSetSuccess', {
defaultMessage: 'Synonyms set {synonymsSetId} deleted',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { SynonymsSynonymRule } from '@elastic/elasticsearch/lib/api/types';
import { useQuery } from '@tanstack/react-query';
import { SYNONYMS_RULE_FETCH_QUERY_KEY } from '../../common/constants';
import { useKibana } from './use_kibana';

export const useFetchSynonymRule = (synonymsSetId: string, ruleId: string) => {
Expand All @@ -15,7 +16,7 @@ export const useFetchSynonymRule = (synonymsSetId: string, ruleId: string) => {
} = useKibana();

return useQuery({
queryKey: ['synonyms-rule-fetch', synonymsSetId, ruleId],
queryKey: [SYNONYMS_RULE_FETCH_QUERY_KEY, synonymsSetId, ruleId],
queryFn: async () => {
return await http.get<SynonymsSynonymRule>(
`/internal/search_synonyms/synonyms/${synonymsSetId}/${ruleId}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { SynonymsSynonymRule } from '@elastic/elasticsearch/lib/api/types';
import { useQuery } from '@tanstack/react-query';
import { SYNONYMS_SETS_QUERY_KEY } from '../../common/constants';
import { DEFAULT_PAGE_VALUE, Page, Paginate } from '../../common/pagination';
import { useKibana } from './use_kibana';

Expand All @@ -15,7 +16,7 @@ export const useFetchSynonymsSet = (synonymsSetId: string, page: Page = DEFAULT_
services: { http },
} = useKibana();
return useQuery({
queryKey: ['synonyms-sets-fetch', synonymsSetId, page.from, page.size],
queryKey: [SYNONYMS_SETS_QUERY_KEY, synonymsSetId, page.from, page.size],
queryFn: async () => {
return await http.get<Paginate<SynonymsSynonymRule> & { id: string }>(
`/internal/search_synonyms/synonyms/${synonymsSetId}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { useQuery } from '@tanstack/react-query';
import type { SynonymsGetSynonymsSetsSynonymsSetItem } from '@elastic/elasticsearch/lib/api/types';
import { SYNONYMS_SETS_QUERY_KEY } from '../../common/constants';
import { DEFAULT_PAGE_VALUE, Page, Paginate } from '../../common/pagination';
import { APIRoutes } from '../../common/api_routes';
import { useKibana } from './use_kibana';
Expand All @@ -16,7 +17,7 @@ export const useFetchSynonymsSets = (page: Page = DEFAULT_PAGE_VALUE) => {
services: { http },
} = useKibana();
return useQuery({
queryKey: ['synonyms-sets-fetch', page.from, page.size],
queryKey: [SYNONYMS_SETS_QUERY_KEY, page.from, page.size],
queryFn: async () => {
return await http.get<Paginate<SynonymsGetSynonymsSetsSynonymsSetItem>>(
APIRoutes.SYNONYM_SETS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { SynonymsPutSynonymResponse } from '@elastic/elasticsearch/lib/api/types';
import { i18n } from '@kbn/i18n';
import { KibanaServerError } from '@kbn/kibana-utils-plugin/common';
import { SYNONYMS_RULE_FETCH_QUERY_KEY, SYNONYMS_SETS_QUERY_KEY } from '../../common/constants';
import { PLUGIN_ROUTE_ROOT } from '../../common/api_routes';
import { useKibana } from './use_kibana';

Expand All @@ -30,8 +31,8 @@ export const usePutSynonymsSet = (onSuccess?: () => void, onError?: (error: stri
},
{
onSuccess: (_, { synonymsSetId }) => {
queryClient.invalidateQueries(['synonyms-sets-fetch']);
queryClient.invalidateQueries(['synonyms-rule-fetch']);
queryClient.invalidateQueries([SYNONYMS_RULE_FETCH_QUERY_KEY]);
queryClient.invalidateQueries([SYNONYMS_SETS_QUERY_KEY]);
notifications?.toasts?.addSuccess({
title: i18n.translate('xpack.searchSynonyms.putSynonymsSetSuccess', {
defaultMessage: 'Synonyms set added',
Expand Down

0 comments on commit 32a3b22

Please sign in to comment.