Skip to content

Commit

Permalink
issue-1246 Truncate commit message to first newline (backstage#2012)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Holmberg <[email protected]>
  • Loading branch information
jasonholmberg authored Nov 21, 2024
1 parent 99dcb80 commit a130288
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions workspaces/github-actions/.changeset/mean-apes-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-github-actions': patch
---

Truncate commit message to first newline
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ import { useRouteRef } from '@backstage/core-plugin-api';
import { getHostnameFromEntity } from '../getHostnameFromEntity';
import { getStatusDescription } from '../WorkflowRunStatus/WorkflowRunStatus';

// Utility function to truncate string at the first newline character
const truncateAtNewline = (str: string) => {
const newlineIndex = str.indexOf('\n');
return newlineIndex !== -1 ? str.substring(0, newlineIndex) : str;
};

const generatedColumns: TableColumn<Partial<WorkflowRun>>[] = [
{
title: 'ID',
Expand All @@ -53,9 +59,14 @@ const generatedColumns: TableColumn<Partial<WorkflowRun>>[] = [
render: row => {
const LinkWrapper = () => {
const routeLink = useRouteRef(buildRouteRef);
const truncatedMessage = truncateAtNewline(row.message!);
return (
<Link component={RouterLink} to={routeLink({ id: row.id! })}>
{row.message}
<Link
component={RouterLink}
to={routeLink({ id: row.id! })}
title={row.message} // display full message on hover
>
{truncatedMessage}
</Link>
);
};
Expand Down

0 comments on commit a130288

Please sign in to comment.