Skip to content

Commit

Permalink
wikiLinkTemplate is now optional (#189)
Browse files Browse the repository at this point in the history
the title column doesn't display a link anymore if the computed value is
empty.
  • Loading branch information
T0RAT0RA authored Apr 15, 2023
1 parent eab0cdd commit bd30933
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-jobs-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oriflame/backstage-plugin-score-card': minor
---

wikiLinkTemplate is now optionnal
2 changes: 1 addition & 1 deletion plugins/score-card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Also the server providing the data needs to have correctly configured CORS polic
All configuration options:

- `jsonDataUrl`[optional]: url for the JSON data client, see [ScoringDataJsonClient](#scoringdatajsonclient).
- `wikiLinkTemplate`: the template for the link to the wiki. You may use any existing properties from the `EntityScoreEntry`, e.g. `"https://TBD/XXX/_wiki/wikis/XXX.wiki/{id}"`.
- `wikiLinkTemplate`[optional]: the template for the link to the wiki. You may use any existing properties from the `EntityScoreEntry`, e.g. `"https://TBD/XXX/_wiki/wikis/XXX.wiki/{id}"` or `"{scoreUrl}"`.

### How to use the plugin

Expand Down
2 changes: 1 addition & 1 deletion plugins/score-card/src/components/ScoreCard/ScoreCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const useScoringDataLoader = () => {

const wikiLinkTemplate =
config.getOptionalString('scorecards.wikiLinkTemplate') ??
'https://TBD/XXX/_wiki/wikis/XXX.wiki/{id}';
'';

return { loading, value, wikiLinkTemplate, error };
};
Expand Down
30 changes: 18 additions & 12 deletions plugins/score-card/src/components/ScoreCard/columns/titleColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ export function titleColumn(
field: 'title',
grouping: false,
width: '1%',
render: entityScoreEntry => (
<span>
<Link
href={getWikiUrl(wikiLinkTemplate, entityScoreEntry)}
target="_blank"
data-id={entityScoreEntry.id}
>
{entityScoreEntry.title}
</Link>
{entityScoreEntry.isOptional ? ' (Optional)' : null}
</span>
),
render: entityScoreEntry => {
const wikiUrl = getWikiUrl(wikiLinkTemplate, entityScoreEntry);
return (<span>
{wikiUrl ? (
<Link
href={wikiUrl}
target="_blank"
data-id={entityScoreEntry.id}
>
{entityScoreEntry.title}
</Link>
) : (
<>{entityScoreEntry.title}</>
)}
{entityScoreEntry.isOptional ? ' (Optional)' : null}
</span>
)
},
};
}

0 comments on commit bd30933

Please sign in to comment.