mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(site): use new task data model and endpoints (#20431)
Updates the UI to use the new API endpoints for tasks and use its new data model. Disclaimer: Since the base data model for tasks changed, we had to do a quite large refactor and I'm sorry for that 🙏, but you'll notice most of the changes are to adjust the types. Closes coder/internal#976 --------- Co-authored-by: Bruno Quaresma <bruno_nonato_quaresma@hotmail.com>
This commit is contained in:
co-authored by
Bruno Quaresma
parent
c6e551f538
commit
51d3abb904
+11
-6
@@ -156,6 +156,7 @@ type Task struct {
|
||||
OrganizationID uuid.UUID `json:"organization_id" format:"uuid" table:"organization id"`
|
||||
OwnerID uuid.UUID `json:"owner_id" format:"uuid" table:"owner id"`
|
||||
OwnerName string `json:"owner_name" table:"owner name"`
|
||||
OwnerAvatarURL string `json:"owner_avatar_url,omitempty" table:"owner avatar url"`
|
||||
Name string `json:"name" table:"name,default_sort"`
|
||||
TemplateID uuid.UUID `json:"template_id" format:"uuid" table:"template id"`
|
||||
TemplateVersionID uuid.UUID `json:"template_version_id" format:"uuid" table:"template version id"`
|
||||
@@ -163,6 +164,7 @@ type Task struct {
|
||||
TemplateDisplayName string `json:"template_display_name" table:"template display name"`
|
||||
TemplateIcon string `json:"template_icon" table:"template icon"`
|
||||
WorkspaceID uuid.NullUUID `json:"workspace_id" format:"uuid" table:"workspace id"`
|
||||
WorkspaceName string `json:"workspace_name" table:"workspace name"`
|
||||
WorkspaceStatus WorkspaceStatus `json:"workspace_status,omitempty" enums:"pending,starting,running,stopping,stopped,failed,canceling,canceled,deleting,deleted" table:"workspace status"`
|
||||
WorkspaceBuildNumber int32 `json:"workspace_build_number,omitempty" table:"workspace build number"`
|
||||
WorkspaceAgentID uuid.NullUUID `json:"workspace_agent_id" format:"uuid" table:"workspace agent id"`
|
||||
@@ -200,6 +202,14 @@ type TasksFilter struct {
|
||||
FilterQuery string `json:"filter_query,omitempty"`
|
||||
}
|
||||
|
||||
// TaskListResponse is the response shape for tasks list.
|
||||
//
|
||||
// Experimental response shape for tasks list (server returns []Task).
|
||||
type TasksListResponse struct {
|
||||
Tasks []Task `json:"tasks"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
func (f TasksFilter) asRequestOption() RequestOption {
|
||||
return func(r *http.Request) {
|
||||
var params []string
|
||||
@@ -242,12 +252,7 @@ func (c *ExperimentalClient) Tasks(ctx context.Context, filter *TasksFilter) ([]
|
||||
return nil, ReadBodyAsError(res)
|
||||
}
|
||||
|
||||
// Experimental response shape for tasks list (server returns []Task).
|
||||
type tasksListResponse struct {
|
||||
Tasks []Task `json:"tasks"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
var tres tasksListResponse
|
||||
var tres TasksListResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&tres); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user