Skip to content

Commit c4b115c

Browse files
committed
work on frontend connection with open_in
1 parent f6d37f6 commit c4b115c

File tree

15 files changed

+713
-581
lines changed

15 files changed

+713
-581
lines changed

agent/proto/agent.pb.go

Lines changed: 600 additions & 544 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/proto/agent.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ message WorkspaceApp {
2424
AUTHENTICATED = 2;
2525
PUBLIC = 3;
2626
}
27+
2728
SharingLevel sharing_level = 10;
2829

2930
message Healthcheck {
@@ -42,7 +43,13 @@ message WorkspaceApp {
4243
}
4344
Health health = 12;
4445
bool hidden = 13;
45-
string open_in = 14;
46+
47+
enum OpenIn {
48+
WINDOW = 0;
49+
SLIM_WINDOW = 1;
50+
TAB = 2;
51+
}
52+
OpenIn open_in = 14;
4653
}
4754

4855
message WorkspaceAgentScript {

coderd/apidoc/docs.go

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/db2sdk/db2sdk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ func Apps(dbApps []database.WorkspaceApp, agent database.WorkspaceAgent, ownerNa
518518
},
519519
Health: codersdk.WorkspaceAppHealth(dbApp.Health),
520520
Hidden: dbApp.Hidden,
521+
OpenIn: codersdk.WorkspaceAppOpenIn(dbApp.OpenIn),
521522
})
522523
}
523524
return apps

codersdk/agentsdk/convert.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ func AppFromProto(protoApp *proto.WorkspaceApp) (codersdk.WorkspaceApp, error) {
237237
return codersdk.WorkspaceApp{}, xerrors.Errorf("unknown app health: %v (%q)", protoApp.Health, protoApp.Health.String())
238238
}
239239

240+
openIn := codersdk.WorkspaceAppOpenIn(strings.ToLower(protoApp.OpenIn.String()))
241+
if _, ok := codersdk.MapWorkspaceAppOpenIns[openIn]; !ok {
242+
return codersdk.WorkspaceApp{}, xerrors.Errorf("unknown app open in option: %v (%q)", protoApp.OpenIn, protoApp.OpenIn.String())
243+
}
244+
240245
return codersdk.WorkspaceApp{
241246
ID: id,
242247
URL: protoApp.Url,
@@ -255,7 +260,7 @@ func AppFromProto(protoApp *proto.WorkspaceApp) (codersdk.WorkspaceApp, error) {
255260
},
256261
Health: health,
257262
Hidden: protoApp.Hidden,
258-
OpenIn: protoApp.OpenIn,
263+
OpenIn: openIn,
259264
}, nil
260265
}
261266

@@ -268,6 +273,10 @@ func ProtoFromApp(a codersdk.WorkspaceApp) (*proto.WorkspaceApp, error) {
268273
if !ok {
269274
return nil, xerrors.Errorf("unknown health %s", a.Health)
270275
}
276+
openIn, ok := proto.WorkspaceApp_OpenIn_value[strings.ToUpper(string(a.OpenIn))]
277+
if !ok {
278+
return nil, xerrors.Errorf("unknown open_in %s", a.OpenIn)
279+
}
271280
return &proto.WorkspaceApp{
272281
Id: a.ID[:],
273282
Url: a.URL,
@@ -286,7 +295,7 @@ func ProtoFromApp(a codersdk.WorkspaceApp) (*proto.WorkspaceApp, error) {
286295
},
287296
Health: proto.WorkspaceApp_Health(health),
288297
Hidden: a.Hidden,
289-
OpenIn: a.OpenIn,
298+
OpenIn: proto.WorkspaceApp_OpenIn(openIn),
290299
}, nil
291300
}
292301

codersdk/workspaceapps.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const (
2828
WorkspaceAppSharingLevelPublic WorkspaceAppSharingLevel = "public"
2929
)
3030

31+
var MapWorkspaceAppSharingLevels = map[WorkspaceAppSharingLevel]struct{}{
32+
WorkspaceAppSharingLevelOwner: {},
33+
WorkspaceAppSharingLevelAuthenticated: {},
34+
WorkspaceAppSharingLevelPublic: {},
35+
}
36+
3137
type WorkspaceAppOpenIn string
3238

3339
const (
@@ -36,10 +42,10 @@ const (
3642
WorkspaceAppOpenInTab WorkspaceAppOpenIn = "tab"
3743
)
3844

39-
var MapWorkspaceAppSharingLevels = map[WorkspaceAppSharingLevel]struct{}{
40-
WorkspaceAppSharingLevelOwner: {},
41-
WorkspaceAppSharingLevelAuthenticated: {},
42-
WorkspaceAppSharingLevelPublic: {},
45+
var MapWorkspaceAppOpenIns = map[WorkspaceAppOpenIn]struct{}{
46+
WorkspaceAppOpenInSlimWindow: {},
47+
WorkspaceAppOpenInWindow: {},
48+
WorkspaceAppOpenInTab: {},
4349
}
4450

4551
type WorkspaceApp struct {
@@ -70,7 +76,7 @@ type WorkspaceApp struct {
7076
Healthcheck Healthcheck `json:"healthcheck"`
7177
Health WorkspaceAppHealth `json:"health"`
7278
Hidden bool `json:"hidden"`
73-
OpenIn string `json:"open_in"`
79+
OpenIn WorkspaceAppOpenIn `json:"open_in"`
7480
}
7581

7682
type Healthcheck struct {

docs/reference/api/agents.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/builds.md

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)