-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[dashboard] Fix feedback when triggering prebuilds #5731
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,14 +5,13 @@ | |||||
*/ | ||||||
|
||||||
import moment from "moment"; | ||||||
import { PrebuildInfo, PrebuildWithStatus, PrebuiltWorkspaceState, Project, WorkspaceInstance } from "@gitpod/gitpod-protocol"; | ||||||
import { PrebuildInfo, PrebuildWithStatus, PrebuiltWorkspaceState, Project, StartPrebuildResult, WorkspaceInstance } 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 Spinner from "../icons/Spinner.svg"; | ||||||
import SpinnerDark from "../icons/SpinnerDark.svg"; | ||||||
import StatusDone from "../icons/StatusDone.svg"; | ||||||
import StatusFailed from "../icons/StatusFailed.svg"; | ||||||
import StatusPaused from "../icons/StatusPaused.svg"; | ||||||
|
@@ -38,6 +37,7 @@ export default function () { | |||||
const [statusFilter, setStatusFilter] = useState<PrebuiltWorkspaceState | undefined>(); | ||||||
|
||||||
const [prebuilds, setPrebuilds] = useState<PrebuildWithStatus[]>([]); | ||||||
const [isPrebuildPending, setIsPrebuildPending] = useState<boolean>(false); | ||||||
|
||||||
useEffect(() => { | ||||||
if (!project) { | ||||||
|
@@ -46,7 +46,8 @@ export default function () { | |||||
const registration = getGitpodService().registerClient({ | ||||||
onPrebuildUpdate: (update: PrebuildWithStatus) => { | ||||||
if (update.info.projectId === project.id) { | ||||||
setPrebuilds(prev => [update, ...prev.filter(p => p.info.id !== update.info.id)]) | ||||||
setPrebuilds(prev => [update, ...prev.filter(p => p.info.id !== update.info.id)]); | ||||||
setIsPrebuildPending(false); | ||||||
} | ||||||
} | ||||||
}); | ||||||
|
@@ -126,9 +127,23 @@ export default function () { | |||||
history.push(`/${!!team ? 't/'+team.slug : 'projects'}/${projectName}/${pb.id}`); | ||||||
} | ||||||
|
||||||
const triggerPrebuild = (branchName: string | null) => { | ||||||
const triggerPrebuild = async (branchName: string | null) => { | ||||||
if (project) { | ||||||
getGitpodService().server.triggerPrebuild(project.id, branchName); | ||||||
setIsPrebuildPending(true); | ||||||
try { | ||||||
const result = await Promise.race([ | ||||||
getGitpodService().server.triggerPrebuild(project.id, branchName), | ||||||
new Promise((_, reject) => setTimeout(() => reject(new Error('Timed out while waiting for new prebuild')), 30000)), | ||||||
]) as StartPrebuildResult; | ||||||
console.log('Successfully triggerred!', result); | ||||||
if (result.done) { | ||||||
// TODO(janx): Visually highlight the prebuild with `p.info.buildWorkspaceId === result.wsid` | ||||||
setIsPrebuildPending(false); | ||||||
} | ||||||
} catch (error) { | ||||||
console.error('Running prebuild failed!', error); | ||||||
setIsPrebuildPending(false); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -150,7 +165,7 @@ export default function () { | |||||
<div className="py-3 pl-3"> | ||||||
<DropDown prefix="Prebuild Status: " contextMenuWidth="w-32" entries={statusFilterEntries()} /> | ||||||
</div> | ||||||
<button disabled={!project} onClick={() => triggerPrebuild(null)} className="ml-2">Trigger Prebuild</button> | ||||||
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. suggestion: Regarding the removal of the global Trigger Prebuild button mentioned in #5731 (comment) (Cc @svenefftinge), the linked issue (#5374) in the PR description contains some more context behind this: From #5374 (comment):
From #5374 (comment):
🍊 🍊 🍊 🍊 Adding below some early design drafts how the confirmation modal could look like when triggering a prebuild from the global trigger prebuild button. Let me know if this does not look interesting or useful here. Using a modal here could allow us in the future to provide a way to insert one-time variables for a prebuild which, etc.
🍋 🍋 🍋 🍋 Regarding the replacement of an existing prebuild upon triggering a new prebuild mentioned in #5731 (comment) (Cc @jankeromnes), I'd think that ideally we'd never replace a prebuild but cancel the previous one and creating a new one. Maybe this is currently not technically possible or something we're interested in? 💭 |
||||||
<button disabled={!project || isPrebuildPending} onClick={() => triggerPrebuild(null)} className="ml-2 flex items-center space-x-2"><span>Trigger Prebuild</span>{isPrebuildPending && <img className="h-4 w-4 animate-spin filter brightness-150" src={Spinner} />}</button> | ||||||
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. suggestion: What do you think of placing the spinner on the left of the label? Spinner placement is a minor issue and we could go with any approach but I remember discussing something similar with the GitLab team in the past in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26035#note_297307469. Cross-posting below the relevant comment for visibility within our team:
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. issue: Changing the state of this button whenever someone triggers an arbitrary prebuild form the prebuilds list, as mentioned in #5731 (comment), can be confusing to the user. I'd suggest to keep the state of the button intact instead. |
||||||
</div> | ||||||
<ItemsList className="mt-2"> | ||||||
<Item header={true} className="grid grid-cols-3"> | ||||||
|
@@ -233,7 +248,7 @@ export function prebuildStatusIcon(status: PrebuiltWorkspaceState | undefined) { | |||||
} | ||||||
} | ||||||
|
||||||
export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInstance, isDark?: boolean }) { | ||||||
export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInstance }) { | ||||||
let status = <></>; | ||||||
let details = <></>; | ||||||
switch (props.prebuildInstance?.status.phase) { | ||||||
|
@@ -244,7 +259,7 @@ export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInst | |||||
<span>PENDING</span> | ||||||
</div>; | ||||||
details = <div className="flex space-x-1 items-center text-gray-400"> | ||||||
<img className="h-4 w-4 animate-spin" src={props.isDark ? SpinnerDark : Spinner} /> | ||||||
<img className="h-4 w-4 animate-spin" src={Spinner} /> | ||||||
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. thought: Friendly reminder to come back to this if we ever adjust the spinner color used for light and dark themes. 🌔 |
||||||
<span>Prebuild in progress ...</span> | ||||||
</div>; | ||||||
break; | ||||||
|
@@ -259,7 +274,7 @@ export function PrebuildInstanceStatus(props: { prebuildInstance?: WorkspaceInst | |||||
<span>RUNNING</span> | ||||||
</div>; | ||||||
details = <div className="flex space-x-1 items-center text-gray-400"> | ||||||
<img className="h-4 w-4 animate-spin" src={props.isDark ? SpinnerDark : Spinner} /> | ||||||
<img className="h-4 w-4 animate-spin" src={Spinner} /> | ||||||
<span>Prebuild in progress ...</span> | ||||||
</div>; | ||||||
break; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: Maybe I should remove this debug log.