Skip to content

Commit

Permalink
[8.x] [Index Management] Fix ILM policy link trigger an SPA friendly …
Browse files Browse the repository at this point in the history
…navigation (#199252) (#201271)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Index Management] Fix ILM policy link trigger an SPA friendly
navigation (#199252)](#199252)

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

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

<!--BACKPORT [{"author":{"name":"Jusheng
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-21T18:35:59Z","message":"[Index
Management] Fix ILM policy link trigger an SPA friendly navigation
(#199252)\n\n## Summary\r\n\r\nClose #87876 \r\n\r\nUse
`core.application.navigateToUrl` navigate to given URL in a
SPA\r\nfriendly.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/1918eb3d-fbec-46d9-8eae-b4a26ebd36a2","sha":"fa100b48191d08fde48894ff88dd49687ef4d524","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index
Management","Team:Kibana
Management","release_note:skip","💝community","v9.0.0","backport:prev-minor"],"title":"[Index
Management] Fix ILM policy link trigger an SPA friendly
navigation","number":199252,"url":"https://github.com/elastic/kibana/pull/199252","mergeCommit":{"message":"[Index
Management] Fix ILM policy link trigger an SPA friendly navigation
(#199252)\n\n## Summary\r\n\r\nClose #87876 \r\n\r\nUse
`core.application.navigateToUrl` navigate to given URL in a
SPA\r\nfriendly.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/1918eb3d-fbec-46d9-8eae-b4a26ebd36a2","sha":"fa100b48191d08fde48894ff88dd49687ef4d524"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199252","number":199252,"mergeCommit":{"message":"[Index
Management] Fix ILM policy link trigger an SPA friendly navigation
(#199252)\n\n## Summary\r\n\r\nClose #87876 \r\n\r\nUse
`core.application.navigateToUrl` navigate to given URL in a
SPA\r\nfriendly.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/1918eb3d-fbec-46d9-8eae-b4a26ebd36a2","sha":"fa100b48191d08fde48894ff88dd49687ef4d524"}}]}]
BACKPORT-->

Co-authored-by: Jusheng Huang <[email protected]>
  • Loading branch information
kibanamachine and viajes7 authored Nov 21, 2024
1 parent a36d790 commit 8df5ece
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ describe('Data Streams tab', () => {

const { actions, findDetailPanelIlmPolicyLink } = testBed;
await actions.clickNameAt(0);
expect(findDetailPanelIlmPolicyLink().prop('href')).toBe('/test/my_ilm_policy');
expect(findDetailPanelIlmPolicyLink().prop('data-href')).toBe('/test/my_ilm_policy');
});

test('with an ILM url locator and no ILM policy', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
const { error, data: dataStream, isLoading } = useLoadDataStream(dataStreamName);

const ilmPolicyLink = useIlmLocator(ILM_PAGES_POLICY_EDIT, dataStream?.ilmPolicyName);
const { history, config } = useAppContext();
const { history, config, core } = useAppContext();
let indicesLink;

let content;
Expand Down Expand Up @@ -193,7 +193,11 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
>
<>
{ilmPolicyLink ? (
<EuiLink data-test-subj={'ilmPolicyLink'} href={ilmPolicyLink}>
<EuiLink
data-test-subj={'ilmPolicyLink'}
data-href={ilmPolicyLink}
onClick={() => core.application.navigateToUrl(ilmPolicyLink)}
>
<EuiTextColor color="subdued">{ilmPolicyName}</EuiTextColor>
</EuiLink>
) : (
Expand All @@ -204,7 +208,11 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
) : (
<>
{ilmPolicyLink ? (
<EuiLink data-test-subj={'ilmPolicyLink'} href={ilmPolicyLink}>
<EuiLink
data-test-subj={'ilmPolicyLink'}
data-href={ilmPolicyLink}
onClick={() => core.application.navigateToUrl(ilmPolicyLink)}
>
{ilmPolicyName}
</EuiLink>
) : (
Expand Down Expand Up @@ -429,7 +437,7 @@ export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
defaultMessage="To edit data retention for this data stream, you must edit its associated {link}."
values={{
link: (
<EuiLink href={ilmPolicyLink}>
<EuiLink onClick={() => core.application.navigateToUrl(ilmPolicyLink)}>
<FormattedMessage
id="xpack.idxMgmt.dataStreamsDetailsPanel.editDataRetentionModal.fullyManagedByILMButtonLabel"
defaultMessage="ILM policy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ const MixedIndicesCallout = ({
dataStreamName,
history,
}: MixedIndicesCalloutProps) => {
const { core } = useAppContext();

return (
<EuiCallOut
title={i18n.translate(
Expand All @@ -177,7 +179,10 @@ const MixedIndicesCallout = ({
defaultMessage="One or more indices are managed by an ILM policy ({viewAllIndicesLink}). Updating data retention for this data stream won't affect these indices. Instead you will have to update the {ilmPolicyLink} policy."
values={{
ilmPolicyLink: (
<EuiLink data-test-subj="viewIlmPolicyLink" href={ilmPolicyLink}>
<EuiLink
data-test-subj="viewIlmPolicyLink"
onClick={() => core.application.navigateToUrl(ilmPolicyLink)}
>
{ilmPolicyName}
</EuiLink>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })

const numIndexPatterns = indexPatterns.length;

const { history } = useAppContext();
const { history, core } = useAppContext();
const ilmPolicyLink = useIlmLocator(ILM_PAGES_POLICY_EDIT, ilmPolicy?.name);

return (
Expand Down Expand Up @@ -171,7 +171,9 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{ilmPolicy?.name && ilmPolicyLink ? (
<EuiLink href={ilmPolicyLink}>{ilmPolicy!.name}</EuiLink>
<EuiLink onClick={() => core.application.navigateToUrl(ilmPolicyLink)}>
{ilmPolicy!.name}
</EuiLink>
) : (
ilmPolicy?.name || i18nTexts.none
)}
Expand Down

0 comments on commit 8df5ece

Please sign in to comment.