-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Revise Prebuilds Page #4970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise Prebuilds Page #4970
Changes from all commits
c42eb8e
b90fa62
7c160f9
4a5751c
7fe5cdc
130ed5c
c8c7b92
40af349
7a18a52
1eecdd3
1f24982
88b36e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,16 @@ | |
*/ | ||
|
||
import moment from "moment"; | ||
import { PrebuildInfo, PrebuiltWorkspaceState, Project } from "@gitpod/gitpod-protocol"; | ||
import { PrebuildInfo, Project } from "@gitpod/gitpod-protocol"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { useHistory, useLocation, useRouteMatch } from "react-router"; | ||
import Header from "../components/Header"; | ||
import DropDown, { DropDownEntry } from "../components/DropDown"; | ||
import { ItemsList, Item, ItemField, ItemFieldContextMenu } from "../components/ItemsList"; | ||
import { getGitpodService, gitpodHostUrl } from "../service/service"; | ||
import { TeamsContext, getCurrentTeam } from "../teams/teams-context"; | ||
import { prebuildStatusIcon, prebuildStatusLabel } from "./Prebuilds"; | ||
import { ContextMenuEntry } from "../components/ContextMenu"; | ||
import { toRemoteURL } from "./render-utils"; | ||
import { shortCommitMessage } from "./render-utils"; | ||
|
||
export default function () { | ||
const history = useHistory(); | ||
|
@@ -31,7 +30,6 @@ export default function () { | |
const [lastPrebuilds, setLastPrebuilds] = useState<Map<string, PrebuildInfo>>(new Map()); | ||
|
||
const [searchFilter, setSearchFilter] = useState<string | undefined>(); | ||
const [statusFilter, setStatusFilter] = useState<PrebuiltWorkspaceState | undefined>(); | ||
|
||
useEffect(() => { | ||
updateProject(); | ||
|
@@ -78,38 +76,15 @@ export default function () { | |
onClick: () => onNewWorkspace(branch) | ||
}); | ||
entries.push({ | ||
title: "Trigger Prebuild", | ||
title: "Rerun Prebuild", | ||
onClick: () => triggerPrebuild(branch), | ||
separator: true | ||
}); | ||
entries.push({ | ||
title: "Cancel Prebuild", | ||
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300', | ||
onClick: () => { } | ||
}) | ||
return entries; | ||
} | ||
|
||
const statusFilterEntries = () => { | ||
const entries: DropDownEntry[] = []; | ||
entries.push({ | ||
title: 'All', | ||
onClick: () => setStatusFilter(undefined) | ||
}); | ||
entries.push({ | ||
title: 'READY', | ||
onClick: () => setStatusFilter("available") | ||
}); | ||
return entries; | ||
} | ||
|
||
const lastPrebuild = (branch: Project.BranchDetails) => lastPrebuilds.get(branch.name); | ||
|
||
const filter = (branch: Project.BranchDetails) => { | ||
const prebuild = lastPrebuild(branch); | ||
if (statusFilter && prebuild && statusFilter !== prebuild.status) { | ||
return false; | ||
} | ||
if (searchFilter && `${branch.changeTitle} ${branch.name}`.toLowerCase().includes(searchFilter.toLowerCase()) === false) { | ||
return false; | ||
} | ||
|
@@ -130,8 +105,12 @@ export default function () { | |
history.push(`/${team?.slug}/${projectName}/${pb.id}`); | ||
} | ||
|
||
const formatDate = (date: string | undefined) => { | ||
return date ? moment(date).fromNow() : ""; | ||
} | ||
|
||
return <> | ||
<Header title={project?.name || ""} subtitle={toRemoteURL(project?.cloneUrl || "")} /> | ||
<Header title={"Branches"} subtitle={<h2>View recent active branches for <a className="text-gray-400 hover:text-gray-600" href={project?.cloneUrl}>{project?.name}</a>.</h2>} /> | ||
<div className="lg:px-28 px-10"> | ||
<div className="flex mt-8"> | ||
<div className="flex"> | ||
|
@@ -142,7 +121,6 @@ export default function () { | |
</div> | ||
<div className="flex-1" /> | ||
<div className="py-3 pl-3"> | ||
<DropDown prefix="Prebuild Status: " contextMenuWidth="w-32" entries={statusFilterEntries()} /> | ||
</div> | ||
</div> | ||
<ItemsList className="mt-2"> | ||
|
@@ -159,40 +137,39 @@ export default function () { | |
</ItemField> | ||
</Item> | ||
{branches.map((branch, index) => { | ||
if (!filter(branch)) { | ||
return undefined; | ||
} | ||
Comment on lines
+140
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Wouldn't it be cleaner to filter out branches before the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good! will apply in the following PR. |
||
|
||
const branchName = branch.name; | ||
const prebuild = lastPrebuild(branch); | ||
|
||
const avatar = branch.changeAuthorAvatar && <img className="rounded-full w-4 h-4 inline-block align-text-bottom mr-2" src={branch.changeAuthorAvatar || ''} alt={branch.changeAuthor} />; | ||
const fakeShortHash = branch.changeHash.substring(0, 10); | ||
const statusIcon = prebuild?.status && prebuildStatusIcon(prebuild.status); | ||
const status = prebuild?.status && prebuildStatusLabel(prebuild.status); | ||
console.log(`status for ${branchName} is ${prebuild?.status} (${lastPrebuilds.size})`) | ||
if (!filter(branch)) { | ||
// return undefined; | ||
} | ||
return <Item key={`branch-${index}-${branchName}`} className="grid grid-cols-3 group"> | ||
<ItemField className="flex items-center"> | ||
<div> | ||
<div className="text-base text-gray-900 dark:text-gray-50 font-medium mb-1"> | ||
{branchName} | ||
{branch.isDefault && (<span className="ml-2 self-center rounded-xl py-0.5 px-2 text-sm bg-blue-50 text-blue-400">DEFAULT</span>)} | ||
jankeromnes marked this conversation as resolved.
Show resolved
Hide resolved
AlexTugarev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
<p>Updated _ minutes ago</p> | ||
</div> | ||
</ItemField> | ||
<ItemField className="flex items-center"> | ||
<div> | ||
<div className="text-base text-gray-500 dark:text-gray-50 font-medium mb-1">{branch.changeTitle}</div> | ||
<p>{avatar}Authored {moment(branch.changeDate).fromNow()} · {fakeShortHash}</p> | ||
<div className="text-base text-gray-500 dark:text-gray-50 font-medium mb-1">{shortCommitMessage(branch.changeTitle)}</div> | ||
<p>{avatar}Authored {formatDate(branch.changeDate)} · {branch.changeHash?.substring(0, 8)}</p> | ||
AlexTugarev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</ItemField> | ||
<ItemField className="flex items-center"> | ||
<div className="text-base text-gray-900 dark:text-gray-50 font-medium uppercase mb-1 cursor-pointer" onClick={() => prebuild && openPrebuild(prebuild)}> | ||
{prebuild ? (<><div className="inline-block align-text-bottom mr-2 w-4 h-4">{statusIcon}</div>{status}</>) : (<span>–</span>)} | ||
{prebuild ? (<><div className="inline-block align-text-bottom mr-2 w-4 h-4">{statusIcon}</div>{status}</>) : (<span> </span>)} | ||
</div> | ||
<span className="flex-grow" /> | ||
<a href={gitpodHostUrl.withContext(`${branch.url}`).toString()}> | ||
<button className={`primary mr-2 py-2 ${branch.isDefault ? "" : "opacity-0"} group-hover:opacity-100`}>New Workspace</button> | ||
<button className={`primary mr-2 py-2 opacity-0 group-hover:opacity-100`}>New Workspace</button> | ||
</a> | ||
<ItemFieldContextMenu className="py-0.5" menuEntries={branchContextMenu(branch)} /> | ||
</ItemField> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1461,7 +1461,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl<GitpodClient, GitpodSer | |
return repositories; | ||
} | ||
|
||
async triggerPrebuild(projectId: string, branch: string): Promise<void> { | ||
async triggerPrebuild(projectId: string, branchName: string): Promise<void> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I understand that Please either respect the file-local convention (i.e. explicit |
||
const user = this.checkAndBlockUser("triggerPrebuild"); | ||
|
||
const project = await this.projectsService.getProject(projectId); | ||
|
@@ -1473,7 +1473,11 @@ export class GitpodServerEEImpl extends GitpodServerImpl<GitpodClient, GitpodSer | |
const span = opentracing.globalTracer().startSpan("triggerPrebuild"); | ||
span.setTag("userId", user.id); | ||
|
||
const contextURL = `${project.cloneUrl.replace(".git", "")}/tree/${branch}`; // just a quick hack! | ||
const branchDetails = await this.projectsService.getBranchDetails(user, project, branchName); | ||
if (branchDetails.length !== 1) { | ||
log.debug({ userId: user.id }, 'Cannot find branch details.', { project, branchName }); | ||
} | ||
const contextURL = branchDetails[0].url; | ||
|
||
const context = await this.contextParser.handle({ span }, user, contextURL) as CommitContext; | ||
|
||
|
@@ -1482,7 +1486,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl<GitpodClient, GitpodSer | |
cloneURL: project.cloneUrl, | ||
commit: context.revision, | ||
user, | ||
branch, | ||
branch: branchName, | ||
project | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,11 @@ export class BitbucketRepositoryProvider implements RepositoryProvider { | |
return { host, owner, name, cloneUrl, description, avatarUrl, webUrl }; | ||
} | ||
|
||
async getBranch(user: User, owner: string, repo: string, branch: string): Promise<Branch> { | ||
// todo | ||
throw new Error("not implemented"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: When will we implement the Bitbucket and GitLab methods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Planing to implement GitLab support tomorrow. No plans for BitBucket so far. TODO: remove from selection list for the time being. |
||
} | ||
|
||
async getBranches(user: User, owner: string, repo: string): Promise<Branch[]> { | ||
// todo | ||
return []; | ||
|
Uh oh!
There was an error while loading. Please reload this page.