fix: use core Link component for action links

Signed-off-by: pamelin <pamelin@expediagroup.com>
This commit is contained in:
pamelin
2023-02-16 16:59:00 +00:00
parent 89209ca8da
commit 52b453aadb
2 changed files with 11 additions and 3 deletions
@@ -56,6 +56,11 @@ describe('ActionsList', () => {
const mockApi: jest.Mocked<StackstormApi> = {
getPacks: jest.fn().mockResolvedValue(packs),
getActions: jest.fn().mockResolvedValue(actions),
getActionUrl: jest
.fn()
.mockResolvedValue(
'http://stackstorm.example.com:8080/?#/actions/core.action',
),
} as any;
it('should render all packs', async () => {
@@ -15,7 +15,7 @@
*/
import React, { useState } from 'react';
import useAsync from 'react-use/lib/useAsync';
import { Progress, ResponseErrorPanel } from '@backstage/core-components';
import { Link, Progress, ResponseErrorPanel } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
import {
List,
@@ -72,9 +72,12 @@ export const ActionItems = ({ pack }: ActionItemsProps) => {
return (
<ListItem
key={a.ref}
button
component={Link}
to={st2.getActionUrl(a.ref)}
className={classes.nested}
onClick={() => window.open(st2.getActionUrl(a.ref), '_blank')}
underline="none"
color="inherit"
button
>
<ListItemText primary={a.name} secondary={a.description} />
<ListItemSecondaryAction>{a.runner_type}</ListItemSecondaryAction>