Skip to content

Commit

Permalink
[dashboard] Fix Cancel button state in Prebuild page by also updating…
Browse files Browse the repository at this point in the history
… prebuild info on instance update
  • Loading branch information
jankeromnes authored and roboquat committed Nov 16, 2021
1 parent 490d0fa commit c52f8a0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/dashboard/src/projects/Prebuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ export default function () {
</div>)
};

const onInstanceUpdate = (instance: WorkspaceInstance) => {
const onInstanceUpdate = async (instance: WorkspaceInstance) => {
setPrebuildInstance(instance);
if (!prebuild) {
return;
}
const prebuilds = await getGitpodService().server.findPrebuilds({
projectId: prebuild.info.projectId,
prebuildId
});
setPrebuild(prebuilds[0]);
}

const rerunPrebuild = async () => {
Expand Down Expand Up @@ -132,7 +140,7 @@ export default function () {
<span>Rerun Prebuild ({prebuild.info.branch})</span>
</button>
: (prebuild?.status === 'building'
? <button className="danger flex items-center space-x-2" disabled={isCancellingPrebuild} onClick={cancelPrebuild}>
? <button className="danger flex items-center space-x-2" disabled={isCancellingPrebuild || (prebuildInstance?.status.phase !== "initializing" && prebuildInstance?.status.phase !== "running")} onClick={cancelPrebuild}>
{isCancellingPrebuild && <img className="h-4 w-4 animate-spin filter brightness-150" src={Spinner} />}
<span>Cancel Prebuild</span>
</button>
Expand Down

0 comments on commit c52f8a0

Please sign in to comment.