Skip to content

Commit

Permalink
Merge pull request #1506 from RoadieHQ/fix-query
Browse files Browse the repository at this point in the history
Fix query and add story links
  • Loading branch information
punkle authored Jul 26, 2024
2 parents dace4b2 + 239ab17 commit a31f4f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-beers-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/backstage-plugin-shortcut': patch
---

Fix stories query where either parameter or annotation is undefined.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/

import React from 'react';
import { ErrorPanel, Table, TableColumn } from '@backstage/core-components';
import {
ErrorPanel,
Table,
TableColumn,
Link,
} from '@backstage/core-components';
import SyncIcon from '@material-ui/icons/Sync';
import { shortcutApiRef } from '../../api';
import { useApi } from '@backstage/core-plugin-api';
Expand All @@ -29,7 +34,7 @@ const columnsBuilder: (users?: User[]) => TableColumn<Story>[] = (
) => [
{
title: 'Name',
field: 'name',
render: story => <Link to={story.app_url}>{story.name}</Link>,
},
{
title: 'Status',
Expand Down Expand Up @@ -61,7 +66,9 @@ export const EntityStoriesCard = (props: {
} = useAsyncRetry(async () => {
let query = entity.metadata.annotations?.[SHORTCUT_QUERY_ANNOTATION];
if (props.additionalQuery) {
query = `${query} ${props.additionalQuery}`;
query = [query, props.additionalQuery]
.filter(queryItem => queryItem !== undefined)
.join(' ');
}
if (query) {
return (await shortcutApi.fetchStories({ query })).data;
Expand Down

0 comments on commit a31f4f6

Please sign in to comment.