Skip to content

Commit f11e168

Browse files
committed
filter out web apps
1 parent d385cca commit f11e168

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

Coder-Desktop/Coder-Desktop/Views/VPN/WorkspaceAppIcon.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ struct WorkspaceApp {
7878
slug = original.slug
7979
displayName = original.display_name
8080

81+
guard original.external else {
82+
throw .isWebApp
83+
}
84+
8185
guard let originalUrl = original.url else {
8286
throw .missingURL
8387
}
@@ -131,6 +135,7 @@ enum WorkspaceAppError: Error {
131135
case invalidURL
132136
case missingURL
133137
case isCommandApp
138+
case isWebApp
134139

135140
var description: String {
136141
switch self {
@@ -140,6 +145,8 @@ enum WorkspaceAppError: Error {
140145
"Missing URL"
141146
case .isCommandApp:
142147
"is a Command App"
148+
case .isWebApp:
149+
"is an External App"
143150
}
144151
}
145152

Coder-Desktop/Coder-DesktopTests/WorkspaceAppTests.swift

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct WorkspaceAppTests {
1616
let sdkApp = CoderSDK.WorkspaceApp(
1717
id: UUID(),
1818
url: URL(string: "https://localhost:3000/app")!,
19-
external: false,
19+
external: true,
2020
slug: "test-app",
2121
display_name: "Test App",
2222
command: nil,
@@ -43,7 +43,7 @@ struct WorkspaceAppTests {
4343
let sdkApp = CoderSDK.WorkspaceApp(
4444
id: UUID(),
4545
url: URL(string: "https://localhost:3000/app?token=$SESSION_TOKEN")!,
46-
external: false,
46+
external: true,
4747
slug: "token-app",
4848
display_name: "Token App",
4949
command: nil,
@@ -69,7 +69,7 @@ struct WorkspaceAppTests {
6969
let sdkApp = CoderSDK.WorkspaceApp(
7070
id: UUID(),
7171
url: nil,
72-
external: false,
72+
external: true,
7373
slug: "no-url-app",
7474
display_name: "No URL App",
7575
command: nil,
@@ -93,7 +93,7 @@ struct WorkspaceAppTests {
9393
let sdkApp = CoderSDK.WorkspaceApp(
9494
id: UUID(),
9595
url: URL(string: "https://localhost:3000/app")!,
96-
external: false,
96+
external: true,
9797
slug: "command-app",
9898
display_name: "Command App",
9999
command: "echo 'hello'",
@@ -154,7 +154,7 @@ struct WorkspaceAppTests {
154154
let sdkApp1 = CoderSDK.WorkspaceApp(
155155
id: UUID(),
156156
url: URL(string: "https://localhost:3000/app1")!,
157-
external: false,
157+
external: true,
158158
slug: "app1",
159159
display_name: "App 1",
160160
command: nil,
@@ -166,7 +166,7 @@ struct WorkspaceAppTests {
166166
let sdkApp2 = CoderSDK.WorkspaceApp(
167167
id: UUID(),
168168
url: URL(string: "https://localhost:3000/app2")!,
169-
external: false,
169+
external: true,
170170
slug: "app2",
171171
display_name: "App 2",
172172
command: nil,
@@ -179,7 +179,7 @@ struct WorkspaceAppTests {
179179
let sdkApp3 = CoderSDK.WorkspaceApp(
180180
id: UUID(),
181181
url: URL(string: "https://localhost:3000/app3")!,
182-
external: false,
182+
external: true,
183183
slug: "app3",
184184
display_name: "App 3",
185185
command: "echo 'skip me'",
@@ -188,14 +188,25 @@ struct WorkspaceAppTests {
188188
subdomain_name: nil
189189
)
190190

191-
let agent = createMockAgent(apps: [sdkApp1, sdkApp2, sdkApp3], displayApps: [.vscode])
191+
// Web app skipped
192+
let sdkApp4 = CoderSDK.WorkspaceApp(
193+
id: UUID(),
194+
url: URL(string: "https://localhost:3000/app4")!,
195+
external: false,
196+
slug: "app4",
197+
display_name: "App 4",
198+
command: nil,
199+
icon: URL(string: "/icon/app4.svg")!,
200+
subdomain: false, subdomain_name: nil
201+
)
202+
203+
let agent = createMockAgent(apps: [sdkApp1, sdkApp2, sdkApp3, sdkApp4], displayApps: [.vscode])
192204
let apps = agentToApps(logger, agent, host, baseAccessURL, sessionToken)
193205

194206
#expect(apps.count == 3)
195207
let appSlugs = apps.map(\.slug)
196208
#expect(appSlugs.contains("app1"))
197209
#expect(appSlugs.contains("app2"))
198-
#expect(!appSlugs.contains("app3"))
199210
#expect(appSlugs.contains("-vscode"))
200211
}
201212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy