Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions coderd/templatebuilder_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func (api *API) templateBuilderCreateTemplate(rw http.ResponseWriter, r *http.Re
jobCtx, jobCancel := context.WithTimeout(ctx, templateBuilderCreateTemplateTimeout)
defer jobCancel()

completedJob, err := api.waitForProvisionerJob(jobCtx, provisionerJob.ID, nil)
completedJob, err := api.waitForProvisionerJob(jobCtx, provisionerJob.ID)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
httpapi.Write(ctx, rw, http.StatusGatewayTimeout, codersdk.Response{
Expand Down Expand Up @@ -616,11 +616,9 @@ func (api *API) templateBuilderCreateTemplate(rw http.ResponseWriter, r *http.Re
}

// waitForProvisionerJob polls until the job completes or the context expires.
// If onUpdate is non-nil, it is called after each poll with the latest job state.
func (api *API) waitForProvisionerJob(
ctx context.Context,
jobID uuid.UUID,
onUpdate func(database.ProvisionerJob),
) (database.ProvisionerJob, error) {
initialIntervals := []time.Duration{
100 * time.Millisecond,
Expand Down Expand Up @@ -648,10 +646,6 @@ func (api *API) waitForProvisionerJob(
return database.ProvisionerJob{}, xerrors.Errorf("get provisioner job: %w", err)
}

if onUpdate != nil {
onUpdate(job)
}

if job.CompletedAt.Valid {
return job, nil
}
Expand Down
12 changes: 6 additions & 6 deletions site/src/pages/TemplateBuilder/BuildingTemplateLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const ICONS: FloatingIcon[] = [

/**
* Full-area animated loader displayed while the template builder compose
* API call is in flight. Shows floating icon boxes, a progress bar, and
* an animated "Building your template..." label.
* API call is in flight. Shows floating icon boxes, an indeterminate progress
* bar that fills once and holds, and an animated "Building your template..."
* label.
*/
export const BuildingTemplateLoader: FC = () => {
return (
Expand Down Expand Up @@ -74,11 +75,10 @@ export const BuildingTemplateLoader: FC = () => {
<motion.div
className="h-full rounded bg-highlight-sky"
initial={{ width: "0%" }}
animate={{ width: "100%" }}
animate={{ width: "90%" }}
transition={{
duration: 5,
ease: "easeInOut",
repeat: Number.POSITIVE_INFINITY,
duration: 9,
ease: "easeOut",
}}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/TemplateBuilder/TemplateBuilderPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const TemplateBuilderPage: FC = () => {
preselectedBase={preselectedBase}
onCreateTemplate={handleCreate}
createError={createMutation.error}
isCreating={createMutation.isPending}
isCreating={createMutation.isPending || createMutation.isSuccess}
onClearCreateError={() => createMutation.reset()}
/>
</>
Expand Down
Loading