Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fe5b71

Browse files
chore!: fix workspace apps response (#17700)
Fix WorkspaceApp response type to better reflect the schema fromhttps://registry.terraform.io/providers/coder/coder/latest/docs/resources/app.
1 parentd146115 commit9fe5b71

File tree

9 files changed

+22
-33
lines changed

9 files changed

+22
-33
lines changed

‎codersdk/workspaceapps.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ type WorkspaceApp struct {
6060
ID uuid.UUID`json:"id" format:"uuid"`
6161
// URL is the address being proxied to inside the workspace.
6262
// If external is specified, this will be opened on the client.
63-
URLstring`json:"url"`
63+
URLstring`json:"url,omitempty"`
6464
// External specifies whether the URL should be opened externally on
6565
// the client or not.
6666
Externalbool`json:"external"`
6767
// Slug is a unique identifier within the agent.
6868
Slugstring`json:"slug"`
6969
// DisplayName is a friendly name for the app.
70-
DisplayNamestring`json:"display_name"`
70+
DisplayNamestring`json:"display_name,omitempty"`
7171
Commandstring`json:"command,omitempty"`
7272
// Icon is a relative path or external URL that specifies
7373
// an icon to be displayed in the dashboard.
@@ -81,7 +81,7 @@ type WorkspaceApp struct {
8181
SubdomainNamestring`json:"subdomain_name,omitempty"`
8282
SharingLevelWorkspaceAppSharingLevel`json:"sharing_level" enums:"owner,authenticated,public"`
8383
// Healthcheck specifies the configuration for checking app health.
84-
HealthcheckHealthcheck`json:"healthcheck"`
84+
HealthcheckHealthcheck`json:"healthcheck,omitempty"`
8585
HealthWorkspaceAppHealth`json:"health"`
8686
Hiddenbool`json:"hidden"`
8787
OpenInWorkspaceAppOpenIn`json:"open_in"`

‎site/src/api/typesGenerated.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/modules/resources/AgentRow.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ describe.each<{
150150

151151
for(constappofprops.agent.apps){
152152
if(app.hidden){
153-
expect(screen.queryByText(app.display_name)).toBeNull();
153+
expect(screen.queryByText(app.display_nameasstring)).toBeNull();
154154
}else{
155-
expect(screen.getByText(app.display_name)).toBeVisible();
155+
expect(screen.getByText(app.display_nameasstring)).toBeVisible();
156156
}
157157
}
158158
});

‎site/src/modules/resources/AgentRowPreview.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ describe("AgentRowPreviewApps", () => {
9191
"<AgentRowPreview agent={$testName} /> displays appropriately",
9292
({ workspaceAgent})=>{
9393
renderComponent(<AgentRowPreviewagent={workspaceAgent}/>);
94-
for(constmoduleofworkspaceAgent.apps){
95-
expect(screen.getByText(module.display_name)).toBeInTheDocument();
94+
for(constappofworkspaceAgent.apps){
95+
expect(
96+
screen.getByText(app.display_nameasstring),
97+
).toBeInTheDocument();
9698
}
9799

98100
for(constappofworkspaceAgent.display_apps){

‎site/src/modules/resources/AgentRowPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
3131
>
3232
<Stackdirection="row"alignItems="baseline">
3333
<divcss={styles.agentStatusWrapper}>
34-
<divcss={styles.agentStatusPreview}></div>
34+
<divcss={styles.agentStatusPreview}/>
3535
</div>
3636
<Stack
3737
alignItems="baseline"

‎site/src/modules/resources/AppLink/AppLink.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,15 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
4343
constappsHost=proxy.preferredWildcardHostname;
4444
const[fetchingSessionToken,setFetchingSessionToken]=useState(false);
4545
const[iconError,setIconError]=useState(false);
46-
4746
consttheme=useTheme();
4847
constusername=workspace.owner_name;
49-
50-
letappSlug=app.slug;
51-
letappDisplayName=app.display_name;
52-
if(!appSlug){
53-
appSlug=appDisplayName;
54-
}
55-
if(!appDisplayName){
56-
appDisplayName=appSlug;
57-
}
48+
constdisplayName=app.display_name||app.slug;
5849

5950
consthref=createAppLinkHref(
6051
window.location.protocol,
6152
preferredPathBase,
6253
appsHost,
63-
appSlug,
54+
app.slug,
6455
username,
6556
workspace,
6657
agent,
@@ -118,7 +109,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
118109
// This is an external URI like "vscode://", so
119110
// it needs to be opened with the browser protocol handler.
120111
constshouldOpenAppExternally=
121-
app.external&&!app.url.startsWith("http");
112+
app.external&&app.url?.startsWith("http");
122113

123114
if(shouldOpenAppExternally){
124115
// This is a magic undocumented string that is replaced
@@ -140,9 +131,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
140131
// an error message will be displayed.
141132
constopenAppExternallyFailedTimeout=500;
142133
constopenAppExternallyFailed=setTimeout(()=>{
143-
displayError(
144-
`${app.display_name!=="" ?app.display_name :app.slug} must be installed first.`,
145-
);
134+
displayError(`${displayName} must be installed first.`);
146135
},openAppExternallyFailedTimeout);
147136
window.addEventListener("blur",()=>{
148137
clearTimeout(openAppExternallyFailed);
@@ -156,7 +145,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
156145
case"slim-window":{
157146
window.open(
158147
href,
159-
Language.appTitle(appDisplayName,generateRandomString(12)),
148+
Language.appTitle(displayName,generateRandomString(12)),
160149
"width=900,height=600",
161150
);
162151
return;
@@ -169,7 +158,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
169158
}}
170159
>
171160
{icon}
172-
{appDisplayName}
161+
{displayName}
173162
{canShare&&<ShareIconapp={app}/>}
174163
</a>
175164
</AgentButton>

‎site/src/modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,11 @@ export const WorkspaceAppStatus = ({
124124

125125
letappHref:string|undefined;
126126
if(app&&agent){
127-
constappSlug=app.slug||app.display_name;
128127
appHref=createAppLinkHref(
129128
window.location.protocol,
130129
preferredPathBase,
131130
appsHost,
132-
appSlug,
131+
app.slug,
133132
workspace.owner_name,
134133
workspace,
135134
agent,

‎site/src/pages/WorkspacePage/AppStatuses.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ export const AppStatuses: FC<AppStatusesProps> = ({
198198
constagent=agents.find((agent)=>agent.id===status.agent_id);
199199

200200
if(currentApp&&agent){
201-
constappSlug=currentApp.slug||currentApp.display_name;
202201
appHref=createAppLinkHref(
203202
window.location.protocol,
204203
preferredPathBase,
205204
appsHost,
206-
appSlug,
205+
currentApp.slug,
207206
workspace.owner_name,
208207
workspace,
209208
agent,

‎site/src/utils/apps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const createAppLinkHref = (
1111
app:TypesGen.WorkspaceApp,
1212
):string=>{
1313
if(app.external){
14-
returnapp.url;
14+
returnapp.urlasstring;
1515
}
1616

1717
// The backend redirects if the trailing slash isn't included, so we add it

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp