Skip to content

Commit eb81af9

Browse files
committed
feat: add link to workspace from app error page
When the workspace is stopped we show an error page if you try accessing a Coder app. Now it also includes a button to go to that workspace, where you can start the workspace.
1 parent 2d3eb72 commit eb81af9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

coderd/workspaceapps/errors.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,26 @@ func WriteWorkspaceOffline(log slog.Logger, accessURL *url.URL, rw http.Response
125125
)
126126
}
127127

128+
actions := []site.Action{
129+
{
130+
URL: accessURL.String(),
131+
Text: "Back to site",
132+
},
133+
}
134+
135+
workspaceURL, err := url.Parse(accessURL.String())
136+
if err == nil {
137+
workspaceURL.Path = path.Join(accessURL.Path, "@"+appReq.UsernameOrID, appReq.WorkspaceNameOrID)
138+
actions = append(actions, site.Action{
139+
URL: workspaceURL.String(),
140+
Text: "View workspace",
141+
})
142+
}
143+
128144
site.RenderStaticErrorPage(rw, r, site.ErrorPageData{
129145
Status: http.StatusBadRequest,
130146
Title: "Workspace Offline",
131147
Description: fmt.Sprintf("Last workspace transition was to the %q state. Start the workspace to access its applications.", codersdk.WorkspaceTransitionStop),
132-
Actions: []site.Action{
133-
{
134-
URL: accessURL.String(),
135-
Text: "Back to site",
136-
},
137-
},
148+
Actions: actions,
138149
})
139150
}

0 commit comments

Comments
 (0)