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

Skip to content

fix: make build table show empty instead of loading when none are recent #5666

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

Merged
merged 4 commits into from
Jan 11, 2023

Conversation

presleyp
Copy link
Contributor

Fixes #5651
I couldn't figure out what on the backend was making this return null instead of [], so I just fixed the type and did a check on the frontend.

@presleyp presleyp requested a review from a team as a code owner January 11, 2023 02:01
@presleyp presleyp requested review from jsjoeio and removed request for a team January 11, 2023 02:01
@ammario
Copy link
Member

ammario commented Jan 11, 2023

Should be able to just fix it in the backend with:

diff --git a/coderd/workspacebuilds.go b/coderd/workspacebuilds.go
index 4f057786..2f46ba6a 100644
--- a/coderd/workspacebuilds.go
+++ b/coderd/workspacebuilds.go
@@ -897,7 +897,9 @@ func (api *API) convertWorkspaceBuilds(
                templateVersionByID[templateVersion.ID] = templateVersion
        }

-       var apiBuilds []codersdk.WorkspaceBuild
+       // Should never be nil for API consistency.
+       apiBuilds := []codersdk.WorkspaceBuild{}
+
        for _, build := range workspaceBuilds {
                job, exists := jobByID[build.JobID]
                if !exists {
diff --git a/coderd/workspacebuilds_test.go b/coderd/workspacebuilds_test.go
index 77183886..3f0384aa 100644
--- a/coderd/workspacebuilds_test.go
+++ b/coderd/workspacebuilds_test.go
@@ -171,6 +171,8 @@ func TestWorkspaceBuilds(t *testing.T) {
                )
                require.NoError(t, err)
                require.Len(t, builds, 0)
+               // Must never be nil for API consistency.
+               require.NotNil(t, builds)

                builds, err = client.WorkspaceBuilds(ctx,
                        codersdk.WorkspaceBuildsRequest{WorkspaceID: workspace.ID, Since: database.Now().Add(-time.Hour)},

@ammario ammario requested review from ammario and removed request for jsjoeio January 11, 2023 02:25
@presleyp
Copy link
Contributor Author

@ammario ready for another look

@presleyp presleyp merged commit 627fbe5 into main Jan 11, 2023
@presleyp presleyp deleted the 5651/build-spinner branch January 11, 2023 17:18
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bottom workspace UI showed spinner, at stopped and started state
2 participants