Skip to content

Frontend Workspace Resources Card #1031

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

Closed
4 of 9 tasks
Tracked by #679 ...
presleyp opened this issue Apr 15, 2022 · 22 comments · Fixed by #1627
Closed
4 of 9 tasks
Tracked by #679 ...

Frontend Workspace Resources Card #1031

presleyp opened this issue Apr 15, 2022 · 22 comments · Fixed by #1627
Assignees
Labels
site Area: frontend dashboard
Milestone

Comments

@presleyp
Copy link
Contributor

presleyp commented Apr 15, 2022

Screen Shot 2022-04-28 at 3 18 12 PM

  • read resources from api
  • decide how to handle nesting of agents in resources and ports in agents - subrows? Just rich cells?
  • build resources table component with columns for Resource, Lifetime, Status, and Access. (Lifetime (persistent or ephemerial) is in the Status column in the image but will be separated out)
  • nest agents in resources and ports in agents
  • design Access cell to always have Open in Terminal, and always have Any Port button where you can open any port on that agent. Also have any dev urls/applications that are assigned to that agent and a specific port. However, building Open in Terminal links and DevURL/application links are taken care of in other tickets.
  • Consider having Any Port show which ports are already assigned.
  • hook up all access buttons
  • storybook
  • test

Handled in other tickets:

  • Access Column: 760 and 805
  • Lifecycle Column: TBD
@presleyp presleyp added missing details 👀 site Area: frontend dashboard labels Apr 15, 2022
@presleyp presleyp added this to the V2 Beta milestone Apr 15, 2022
@presleyp presleyp changed the title Resources Card Frontend Workspace Resources Card Apr 15, 2022
@misskniss
Copy link

There is a meeting on the calendar to discuss this one for details.

@misskniss
Copy link

Hey team! Please add your planning poker estimate with ZenHub @presleyp @kylecarbs

@presleyp
Copy link
Contributor Author

presleyp commented Apr 28, 2022

table of resources with ability to open each in web terminal

Button on each row called Open In Terminal

@presleyp
Copy link
Contributor Author

persistent/ephemeral is a different type of data than connection status. can call that column Lifetime?

@presleyp
Copy link
Contributor Author

subrows: could make it monospace and use the ascii elbow

@presleyp
Copy link
Contributor Author

Open Port button - opens dropdown where you type port number

DevURLs are predefined port allocations (and use a certain resource)

But resources can be opened in any port. If you open dev in the port VSCode is assigned to, you see VSCode.

@presleyp
Copy link
Contributor Author

Look into nesting dev urls/applications in resources card
Resource - Agent - Ports (some are apps, can also open any port)

@presleyp
Copy link
Contributor Author

make agent connection status optional so we can reuse this component for a preview

@misskniss
Copy link

@kylecarbs this one needs input from you in a convo with @presleyp so that she has all the right information to implement this.

Can you list the endpoints that she will need? This may also be something that we could use your help with for community since it is pretty large.

Maybe the two of you can separate the endpoint hook ups with the views.

@misskniss
Copy link

@vapurrmaid To help groom this and break it apart with Presley so we can better spread the load on it.

@greyscaled
Copy link
Contributor

greyscaled commented May 11, 2022

Breakout session notes

coder/cli/show.go

Lines 11 to 39 in 982769f

func show() *cobra.Command {
return &cobra.Command{
Annotations: workspaceCommand,
Use: "show",
Short: "Show details of a workspace's resources and agents",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return xerrors.Errorf("get workspace: %w", err)
}
resources, err := client.WorkspaceResourcesByBuild(cmd.Context(), workspace.LatestBuild.ID)
if err != nil {
return xerrors.Errorf("get workspace resources: %w", err)
}
return cliui.WorkspaceResources(cmd.OutOrStdout(), resources, cliui.WorkspaceResourcesOptions{
WorkspaceName: workspace.Name,
})
},
}
}

func (c *Client) WorkspaceResourcesByBuild(ctx context.Context, build uuid.UUID) ([]WorkspaceResource, error) {
res, err := c.request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/workspacebuilds/%s/resources", build), nil)
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, readBodyAsError(res)
}
var resources []WorkspaceResource
return resources, json.NewDecoder(res.Body).Decode(&resources)
}

The API:

/api/v2/workspacebuilds/%s/resources

type WorkspaceResource struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
JobID uuid.UUID `json:"job_id"`
Transition database.WorkspaceTransition `json:"workspace_transition"`
Type string `json:"type"`
Name string `json:"name"`
Agents []WorkspaceAgent `json:"agents,omitempty"`
}

Dev URLs will be added to this later (same endpoint).

Desired (follow-up): open resource in terminal. We need to create another ticket for that.

Step 1

Present the data similarly to the CLI in a table.

Step 2

We're going to clean up the UI (TBD)

Step 3

Dev URLs


Job associated to WorkspaceResource (job created resource)

Workspace and WorkspaceResource do not have a relationship (job creates the resource)
Type can be presented verbatim
Name can be presented verbatim
Agents - Running process attached to resource. (example coder agent running within v2 while dogfooding).


Request --> We can safely poll without 4xx or 5xx, because the data is static (not actually touching the workspace itself). The FE can remain open and continue to poll.

@presleyp
Copy link
Contributor Author

"Desired (follow-up): open resource in terminal. We need to create another ticket for that." @code-asher isn't this essentially #760? It's just that instead of having one terminal link like in v1 there's one per workspace agent as shown here.

@presleyp
Copy link
Contributor Author

And adding Dev URLs is #805

@code-asher
Copy link
Member

"Desired (follow-up): open resource in terminal. We need to create another ticket for that." @code-asher isn't this essentially #760? It's just that instead of having one terminal link like in v1 there's one per workspace agent as shown here.

Yup I think #760 is perfect for this

@greyscaled
Copy link
Contributor

Dev URLs will be added to this later (same endpoint).

We're currently blocked on this (@deansheather 's working on something)

@presleyp
Copy link
Contributor Author

lifecycle is computed on the frontend - we get what resources exist in Stop and what exist in Start, and those that exist in Start but not Stop, they're ephemeral (gets destroyed on Stop). query the template version for its resources. can't query workspace build bc it only shows for the state it's currently in. will get a flat array where each item is a resource with a workspace transition, so need to look for the resource by its name and type and see if the array has one with stop and one with start. prob a nice to have.

@presleyp
Copy link
Contributor Author

Agents will have an array of Apps soon, and status. WorkspaceApp will have external URL and I just need to render name, icon, and a link to that url.

@presleyp
Copy link
Contributor Author

I'm going to take out Lifecycle and Access for this ticket but here's where I envision them:

Screen Shot 2022-05-17 at 10 08 27 PM

@tjcran
Copy link

tjcran commented May 20, 2022

I'm going to take out Lifecycle and Access for this ticket but here's where I envision them:

Screen Shot 2022-05-17 at 10 08 27 PM

@BrunoQuaresma this is an example of what would go above the timeline in #1620

@BrunoQuaresma
Copy link
Collaborator

Ok. How are we going to add DEV URLs and apps inside of this?

@BrunoQuaresma
Copy link
Collaborator

What do you think about removing the Coming soon fields to not look "incomplete"?

@presleyp
Copy link
Contributor Author

@BrunoQuaresma that's what I meant by "I'm going to take out Lifecycle and Access" - I just put them in for the screenshot so we could all be on the same page about how it will look eventually. DevURLs and apps will go in the Access column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site Area: frontend dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants