Skip to content

Commit

Permalink
feat: make all result pages consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Venefilyn authored and lachmanfrantisek committed Oct 14, 2023
1 parent 4c089cc commit 80af776
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 114 deletions.
12 changes: 6 additions & 6 deletions frontend/src/app/Results/ResultsPageCopr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
DescriptionListTerm,
List,
ListItem,
ClipboardCopy,
} from "@patternfly/react-core";

import { ErrorConnection } from "../Errors/ErrorConnection";
Expand All @@ -25,6 +26,7 @@ import { useTitle } from "../utils/useTitle";
import { getCommitLink } from "../utils/forgeUrls";
import { useQuery } from "@tanstack/react-query";
import { ResultsPageCoprDetails } from "./ResultsPageCoprDetails";
import { SHACopy } from "../utils/SHACopy";

interface BuildPackage {
arch: string;
Expand Down Expand Up @@ -126,16 +128,14 @@ const ResultsPageCopr = () => {
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Copr Build Results</Text>
<StatusLabel
target={data.chroot}
status={data.status}
link={data.web_url}
/>
<Text component="p">
<strong>
<TriggerLink builds={data} />
<SHACopy
git_repo={data.git_repo}
commit_sha={data.commit_sha}
/>
</strong>
<br />
</Text>
</TextContent>
</PageSection>
Expand Down
19 changes: 6 additions & 13 deletions frontend/src/app/Results/ResultsPageCoprDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Timestamp } from "../utils/Timestamp";
import { getCommitLink } from "../utils/forgeUrls";
import { CoprResult } from "./ResultsPageCopr";
import React from "react";
import { StatusLabel } from "../StatusLabel/StatusLabel";

export interface ResultsPageCoprDetailsProps {
data: CoprResult;
Expand All @@ -35,9 +36,11 @@ export const ResultsPageCoprDetails: React.FC<ResultsPageCoprDetailsProps> = ({
</DescriptionListDescription>
<DescriptionListTerm>Copr build</DescriptionListTerm>
<DescriptionListDescription>
<a href={data.web_url} rel="noreferrer" target={"_blank"}>
{data.build_id}
</a>{" "}
<StatusLabel
target={data.chroot}
status={data.status}
link={data.web_url}
/>
(
<a
href={data.build_logs_url}
Expand All @@ -48,16 +51,6 @@ export const ResultsPageCoprDetails: React.FC<ResultsPageCoprDetailsProps> = ({
</a>
)
</DescriptionListDescription>
<DescriptionListTerm>Commit SHA</DescriptionListTerm>
<DescriptionListDescription>
<a
href={getCommitLink(data.git_repo, data.commit_sha)}
rel="noreferrer"
target="_blank"
>
{data.commit_sha.substring(0, 7)}
</a>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Build Submitted Time</DescriptionListTerm>
Expand Down
37 changes: 10 additions & 27 deletions frontend/src/app/Results/ResultsPageKoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useParams } from "react-router-dom";
import { useTitle } from "../utils/useTitle";
import { getCommitLink } from "../utils/forgeUrls";
import { useQuery } from "@tanstack/react-query";
import { SHACopy } from "../utils/SHACopy";

interface KojiBuild {
build_id: string;
Expand Down Expand Up @@ -91,14 +92,13 @@ const ResultsPageKoji = () => {
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">Koji Build Results</Text>
<StatusLabel
target={data.chroot}
status={data.status}
link={data.web_url}
/>
<Text component="p">
<strong>
<TriggerLink builds={data} />
<SHACopy
git_repo={data.git_repo}
commit_sha={data.commit_sha}
/>
</strong>
<br />
</Text>
Expand Down Expand Up @@ -129,13 +129,11 @@ const ResultsPageKoji = () => {
Koji Build
</DescriptionListTerm>
<DescriptionListDescription>
<a
href={data.web_url}
rel="noreferrer"
target={"_blank"}
>
{data.build_id}
</a>{" "}
<StatusLabel
target={data.chroot}
status={data.status}
link={data.web_url}
/>{" "}
(
<a
href={data.build_logs_url}
Expand All @@ -146,21 +144,6 @@ const ResultsPageKoji = () => {
</a>
)
</DescriptionListDescription>
<DescriptionListTerm>
Commit SHA
</DescriptionListTerm>
<DescriptionListDescription>
<a
href={getCommitLink(
data.git_repo,
data.commit_sha,
)}
rel="noreferrer"
target="_blank"
>
{data.commit_sha.substring(0, 7)}
</a>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
Expand Down
44 changes: 16 additions & 28 deletions frontend/src/app/Results/ResultsPageSRPM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,50 +166,38 @@ const ResultsPageSRPM = () => {
>
<DescriptionListGroup>
<DescriptionListTerm>
Status
Copr build
</DescriptionListTerm>
<DescriptionListDescription>
<StatusLabel
status={data.status}
link={data.copr_web_url}
/>
</DescriptionListDescription>
{data.url ? (
<>
<DescriptionListTerm>
Copr
</DescriptionListTerm>
<DescriptionListDescription>
/>{" "}
{data.url ? (
<>
{" "}
(
<a
href={data.url}
href={data.logs_url}
rel="noreferrer"
target={"_blank"}
>
Results
Logs
</a>
</DescriptionListDescription>
<DescriptionListDescription>
<a
href={data.copr_web_url}
rel="noreferrer"
target={"_blank"}
>
Build
</a>{" "}
(
) (
<a
href={data.logs_url}
href={data.url}
rel="noreferrer"
target={"_blank"}
>
Logs
Results
</a>
)
</DescriptionListDescription>
</>
) : (
<></>
)}
</>
) : (
<></>
)}
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
Expand Down
19 changes: 5 additions & 14 deletions frontend/src/app/Results/ResultsPageSyncReleaseRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ const ResultsPageSyncReleaseRuns: React.FC<ResultsPageSyncReleaseRunsProps> = ({
<PageSection variant={PageSectionVariants.light}>
<TextContent>
<Text component="h1">{displayText}</Text>
<SyncReleaseTargetStatusLabel
status={data.status}
target={data.branch}
link={data.downstream_pr_url}
/>
<Text component="p">
<strong>
<TriggerLink builds={data} />
Expand All @@ -262,7 +257,11 @@ const ResultsPageSyncReleaseRuns: React.FC<ResultsPageSyncReleaseRunsProps> = ({
Status
</DescriptionListTerm>
<DescriptionListDescription>
{data.status}
<SyncReleaseTargetStatusLabel
status={data.status}
target={data.branch}
link={data.downstream_pr_url}
/>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
Expand Down Expand Up @@ -294,14 +293,6 @@ const ResultsPageSyncReleaseRuns: React.FC<ResultsPageSyncReleaseRunsProps> = ({
/>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
Link to downstream PR
</DescriptionListTerm>
<DescriptionListDescription>
{linkToDownstreamPR}
</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
</CardBody>
</Card>
Expand Down
31 changes: 5 additions & 26 deletions frontend/src/app/Results/ResultsPageTestingFarm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
} from "./ResultsPageCopr";
import { Preloader } from "../Preloader/Preloader";
import { ResultsPageCoprDetails } from "./ResultsPageCoprDetails";
import { SHACopy } from "../utils/SHACopy";

export interface TestingFarmOverview {
pipeline_id: string; // UUID
Expand Down Expand Up @@ -195,12 +196,6 @@ const ResultsPageTestingFarm = () => {
<>{data?.status}</>
);

const onCopyHash = () => {
if (data) {
navigator.clipboard.writeText(data.commit_sha);
}
};

return (
<>
<PageSection variant={PageSectionVariants.light}>
Expand All @@ -212,26 +207,10 @@ const ResultsPageTestingFarm = () => {
{data ? (
<>
<TriggerLink builds={data} />
<ClipboardCopy
style={{
marginLeft:
"var(--pf-global--spacer--xs)",
}}
hoverTip="Copy commit SHA"
variant="inline-compact"
onCopy={onCopyHash}
>
<a
href={getCommitLink(
data.git_repo,
data.commit_sha,
)}
rel="noreferrer"
target="_blank"
>
{data.commit_sha.substring(0, 7)}
</a>
</ClipboardCopy>
<SHACopy
git_repo={data.git_repo}
commit_sha={data.commit_sha}
/>
</>
) : (
<></>
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/app/utils/SHACopy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ClipboardCopy } from "@patternfly/react-core";
import React from "react";
import { getCommitLink } from "./forgeUrls";

export interface SHACopyInterface {
git_repo: string;
commit_sha: string;
}

export const SHACopy: React.FC<SHACopyInterface> = ({
git_repo,
commit_sha,
}) => {
if (!git_repo || !commit_sha) {
return <></>;
}
const onCopyHash = () => {
navigator.clipboard.writeText(commit_sha);
};

return (
<ClipboardCopy
style={{
marginLeft: "var(--pf-global--spacer--xs)",
}}
hoverTip="Copy commit SHA"
variant="inline-compact"
onCopy={onCopyHash}
>
<a
href={getCommitLink(git_repo, commit_sha)}
rel="noreferrer"
target="_blank"
>
{commit_sha.substring(0, 7)}
</a>
</ClipboardCopy>
);
};

0 comments on commit 80af776

Please sign in to comment.