Skip to content

Commit

Permalink
Adjust to Anitya related API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarcziova committed Aug 20, 2024
1 parent ffc05fc commit 0b501bd
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 48 deletions.
64 changes: 32 additions & 32 deletions frontend/src/apiDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export interface CoprBuildPackage {

// /api/copr-builds/$id
export interface CoprBuild {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch_name: string | null;
build_finished_time: number;
build_id: string;
Expand Down Expand Up @@ -152,10 +152,10 @@ export interface KojiBuildGroup {

// /api/koji-builds/$id
export interface KojiBuild {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch_name: string | null;
build_finished_time: number;
build_logs_urls: [string: string];
Expand Down Expand Up @@ -197,10 +197,10 @@ export interface SRPMBuildGroup {

// /api/srpm-builds/$id
export interface SRPMBuild {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch_name: string | null;
build_finished_time: number;
build_start_time: number;
Expand Down Expand Up @@ -242,10 +242,10 @@ export interface BodhiUpdateGroup {
// /api/bodhi-updates/$id
export interface BodhiUpdate {
alias: string | null;
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch: string;
branch_name: string | null;
issue_id: number | null;
Expand Down Expand Up @@ -280,10 +280,10 @@ export interface TestingFarmRunGroup {

// /api/testing-farm/$id
export interface TestingFarmRun {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch_name: string | null;
chroot: string;
commit_sha: string;
Expand All @@ -305,10 +305,10 @@ export interface TestingFarmRun {
// /api/propose-downstream
// /api/pull-from-upstream
export interface SyncReleaseJobGroup {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
issue_id: number | null;
non_git_upstream: boolean;
packit_id: number;
Expand All @@ -326,10 +326,10 @@ export interface SyncReleaseJobGroup {
// /api/propose-downstream/$id
// /api/pull-from-upstream/$id
export interface SyncReleaseJob {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch: string;
branch_name: string | null;
downstream_pr_id: number | null;
Expand Down Expand Up @@ -372,10 +372,10 @@ export interface PipelineRun {
time_submitted: number;
trigger:
| {
antiya_package: unknown | null;
anitya_project_id: unknown | null;
anitya_project_name: unknown | null;
anitya_project_version: unknown | null;
anitya_package: string | null;
anitya_project_id: number | null;
anitya_project_name: string | null;
anitya_version: string | null;
branch_name: string | null;
issue_id: number | null;
non_git_upstream: boolean;
Expand Down
57 changes: 41 additions & 16 deletions frontend/src/components/trigger/TriggerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,28 @@ interface TriggerLinkProps {
issue_id?: number | null;
branch_name?: string | null;
release?: string | null;
anitya_project_name?: string | null;
anitya_version?: string | null;
anitya_package?: string | null;
};
children?: React.ReactNode;
}

const TriggerLink: React.FC<TriggerLinkProps> = ({ trigger, children }) => {
let link = "";
const gitRepo = trigger.project_url ? trigger.project_url : "";
const projectUrl = trigger.project_url ? trigger.project_url : "";

if (trigger.pr_id) {
link = getPRLink(gitRepo, trigger.pr_id);
link = getPRLink(projectUrl, trigger.pr_id);
} else if (trigger.issue_id) {
link = getIssueLink(gitRepo, trigger.issue_id);
link = getIssueLink(projectUrl, trigger.issue_id);
} else if (trigger.branch_name) {
link = getBranchLink(gitRepo, trigger.branch_name);
link = getBranchLink(projectUrl, trigger.branch_name);
} else if (trigger.release) {
link = getReleaseLink(gitRepo, trigger.release);
link = getReleaseLink(projectUrl, trigger.release);
} else if (trigger.anitya_version) {
// there is no link to the particular version, just the whole project
link = projectUrl;
}

if (link) {
Expand All @@ -44,22 +50,41 @@ const TriggerLink: React.FC<TriggerLinkProps> = ({ trigger, children }) => {
return children;
};

interface TriggerSuffixProps {
trigger: {
branch_name?: string | null;
issue_id?: number | null;
pr_id?: number | null;
release?: string | null;
repo_name: string;
repo_namespace: string;
};
interface TriggerSuffixInterface {
branch_name?: string | null;
issue_id?: number | null;
pr_id?: number | null;
release?: string | null;
}

interface TriggerSuffixGitRepo extends TriggerSuffixInterface {
type: "repo";
repo_name: string;
repo_namespace: string;
}

interface TriggerSuffixAnityaProject extends TriggerSuffixInterface {
type: "anitya";
anitya_project_name: string;
anitya_version: string;
anitya_package: string;
}

type TriggerSuffixProps = {
trigger: TriggerSuffixGitRepo | TriggerSuffixAnityaProject;
};

const TriggerSuffix: React.FC<TriggerSuffixProps> = ({ trigger }) => {
// set suffix to be either PR ID or Branch Name depending on trigger
let jobSuffix = "";

if (trigger.pr_id) {
if (trigger.type === "anitya") {
jobSuffix = `#version:${trigger.anitya_version}`;
return (
<>
{trigger.anitya_project_name}/{jobSuffix}
</>
);
} else if (trigger.pr_id) {
jobSuffix = `#${trigger.pr_id}`;
} else if (trigger.issue_id) {
jobSuffix = `#${trigger.issue_id}`;
Expand Down

0 comments on commit 0b501bd

Please sign in to comment.