Skip to content

Commit dda77f4

Browse files
[ResponseOps][Rules] Rules list: middle-click / "Open in new tab" navigates to Default space instead of current space (elastic#261489)
Closes elastic#260053 ## Summary The rule detail `href` was built using string concatenation, resulting in: `/app/rules/rule/<id>` path without the `/s/<spaceId>` preffix. Middle-click/"Open in new tab" bypasses the SPA router and follows the raw href, causing a `rule not found` error in non-default spaces. - fixed by using `getUrlForApp` which includes the space prefix and the base path.
1 parent d425646 commit dda77f4

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

  • x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rules_list/components

x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_table.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import numeral from '@elastic/numeral';
1010
import { i18n } from '@kbn/i18n';
1111
import { useUiSetting$ } from '@kbn/kibana-react-plugin/public';
1212
import type { EuiTableSortingType, EuiSelectableOption } from '@elastic/eui';
13-
import {
14-
getRulesAppDetailsRoute,
15-
rulesAppRoute,
16-
} from '@kbn/rule-data-utils/src/routes/stack_rule_paths';
13+
import { getRulesAppDetailsRoute } from '@kbn/rule-data-utils/src/routes/stack_rule_paths';
1714
import {
1815
EuiBasicTable,
1916
EuiFlexGroup,
@@ -38,6 +35,7 @@ import {
3835
} from '@kbn/alerting-plugin/common';
3936

4037
import { getRouterLinkProps } from '@kbn/router-utils';
38+
import { useKibana } from '../../../../common/lib/kibana';
4139

4240
import {
4341
SELECT_ALL_RULES,
@@ -252,8 +250,9 @@ export const RulesListTable = (props: RulesListTableProps) => {
252250

253251
const [defaultNumberFormat] = useUiSetting$<string>(DEFAULT_NUMBER_FORMAT);
254252
const { euiTheme } = useEuiTheme();
255-
256-
// Detect current app to determine the correct path format
253+
const {
254+
application: { getUrlForApp },
255+
} = useKibana().services;
257256

258257
const ruleRowCss = css`
259258
min-width: ${euiTheme.breakpoint.xl}px;
@@ -423,7 +422,9 @@ export const RulesListTable = (props: RulesListTableProps) => {
423422
render: (name: string, rule: RuleTableItem) => {
424423
const ruleType = ruleTypesState.data.get(rule.ruleTypeId);
425424
const checkEnabledResult = checkRuleTypeEnabled(ruleType);
426-
const pathToRuleDetails = `${rulesAppRoute}${getRulesAppDetailsRoute(rule.id)}`;
425+
const pathToRuleDetails = getUrlForApp('rules', {
426+
path: getRulesAppDetailsRoute(rule.id),
427+
});
427428

428429
const linkProps = getRouterLinkProps({
429430
href: pathToRuleDetails,
@@ -906,6 +907,7 @@ export const RulesListTable = (props: RulesListTableProps) => {
906907
tagPopoverOpenIndex,
907908
ruleOutcomeColumnField,
908909
euiTheme,
910+
getUrlForApp,
909911
]);
910912

911913
const allRuleColumns = useMemo(() => getRulesTableColumns(), [getRulesTableColumns]);

0 commit comments

Comments
 (0)