Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
DEVPROD-941, take 2: linkify user name on version metadata panel (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
bthood authored Nov 16, 2023
1 parent ccfd805 commit 8fac64d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8823,6 +8823,7 @@ export type VersionQuery = {
__typename?: "Version";
activated?: boolean | null;
author: string;
authorEmail: string;
createTime: Date;
errors: Array<string>;
finishTime?: Date | null;
Expand Down
1 change: 1 addition & 0 deletions src/gql/queries/version.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ query Version($id: String!) {
version(id: $id) {
activated
author
authorEmail
baseVersion {
id
}
Expand Down
17 changes: 16 additions & 1 deletion src/pages/version/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getCommitQueueRoute,
getProjectPatchesRoute,
getTriggerRoute,
getUserPatchesRoute,
getVersionRoute,
} from "constants/routes";
import { VersionQuery } from "gql/generated/types";
Expand All @@ -32,6 +33,7 @@ export const Metadata: React.FC<Props> = ({ loading, version }) => {
const getDateCopy = useDateFormat();
const {
author,
authorEmail,
baseVersion,
createTime,
externalLinksForMetadata,
Expand Down Expand Up @@ -117,7 +119,15 @@ export const Metadata: React.FC<Props> = ({ loading, version }) => {
</span>
</MetadataItem>
)}
<MetadataItem>{`Submitted by: ${author}`}</MetadataItem>
<MetadataItem>
Submitted by:{" "}
<StyledRouterLink
to={getUserPatchesRoute(getAuthorUsername(authorEmail))}
data-cy="user-patches-link"
>
{author}
</StyledRouterLink>
</MetadataItem>
{isPatch ? (
<MetadataItem>
Base commit:{" "}
Expand Down Expand Up @@ -204,3 +214,8 @@ export const Metadata: React.FC<Props> = ({ loading, version }) => {
</MetadataCard>
);
};

const getAuthorUsername = (email: string) => {
const atIndex = email.indexOf("@");
return atIndex === -1 ? email : email.substring(0, atIndex);
};

0 comments on commit 8fac64d

Please sign in to comment.