Tweak links on build card

This commit is contained in:
Stéphane Bidoul 2021-11-21 01:13:29 +01:00
parent 2052be3b01
commit 9da7e23f4a
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
3 changed files with 12 additions and 10 deletions

View file

@ -49,7 +49,8 @@ class Build(BaseModel):
git_commit: str
image: str
deploy_link: str
repo_link: str
repo_target_branch_link: str
repo_pr_link: Optional[str]
repo_commit_link: str
webui_link: str
status: models.BuildStatus

View file

@ -138,12 +138,14 @@ class Build(BaseModel):
return f"http://{self.slug}.{settings.build_domain}"
@property
def repo_link(self) -> str:
link = f"https://github.com/{self.repo}"
if self.pr:
return f"{link}/pull/{self.pr}"
else:
return f"{link}/tree/{self.target_branch}"
def repo_target_branch_link(self) -> str:
return f"https://github.com/{self.repo}/tree/{self.target_branch}"
@property
def repo_pr_link(self) -> str | None:
if not self.pr:
return None
return f"https://github.com/{self.repo}/pull/{self.pr}"
@property
def repo_commit_link(self) -> str:

View file

@ -42,11 +42,10 @@ class RunboatBuildElement extends LitElement {
<div class="build-card build-status-${this.build.status}">
<p class="build-name">${this.build.name}</p>
<p>
${this.build.repo}
<a href="${this.build.repo_target_branch_link}">${this.build.repo} ${this.build.target_branch}</a>
${this.build.pr?
html`PR <a href="${this.build.repo_link}">${this.build.pr}</a> to`:""
html`PR <a href="${this.build.repo_pr_link}">${this.build.pr}</a>`:""
}
<a href="${this.build.repo_link}">${this.build.target_branch}</a>
<br>
${this.build.git_commit?
html`(<a href="${this.build.repo_commit_link}">${this.build.git_commit.substring(0, 8)}</a>)`:""