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

Commit902c34c

Browse files
refactor: improve apps.ts readbility (#17741)
Apply PR comments from#17724
1 parent2bdd035 commit902c34c

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

‎site/migrate-icons.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Look for all the@mui/icons-material icons below and replace them accordinlying with the Lucide icon:
2+
3+
MUI | Lucide
4+
TaskAlt | CircleCheckBigIcon
5+
InfoOutlined | InfoIcon
6+
ErrorOutline | CircleAlertIcon
7+
8+
You should update the imports and usage.

‎site/src/modules/apps/apps.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,11 @@ export const getAppHref = (
8383
:app.url;
8484
}
8585

86-
// The backend redirects if the trailing slash isn't included, so we add it
87-
// here to avoid extra roundtrips.
88-
lethref=`${path}/@${workspace.owner_name}/${workspace.name}.${
89-
agent.name
90-
}/apps/${encodeURIComponent(app.slug)}/`;
91-
9286
if(app.command){
9387
// Terminal links are relative. The terminal page knows how
9488
// to select the correct workspace proxy for the websocket
9589
// connection.
96-
href=`/@${workspace.owner_name}/${workspace.name}.${
90+
return`/@${workspace.owner_name}/${workspace.name}.${
9791
agent.name
9892
}/terminal?command=${encodeURIComponent(app.command)}`;
9993
}
@@ -102,23 +96,14 @@ export const getAppHref = (
10296
constbaseUrl=`${window.location.protocol}//${host.replace(/\*/g,app.subdomain_name)}`;
10397
consturl=newURL(baseUrl);
10498
url.pathname="/";
105-
href=url.toString();
106-
}
107-
108-
returnhref;
109-
};
110-
111-
exportconstneedsSessionToken=(app:WorkspaceApp)=>{
112-
if(!isExternalApp(app)){
113-
returnfalse;
99+
returnurl.toString();
114100
}
115101

116-
// HTTP links should never need the session token, since Cookies
117-
// handle sharing it when you access the Coder Dashboard. We should
118-
// never be forwarding the bare session token to other domains!
119-
constisHttp=app.url.startsWith("http");
120-
constrequiresSessionToken=app.url.includes(SESSION_TOKEN_PLACEHOLDER);
121-
returnrequiresSessionToken&&!isHttp;
102+
// The backend redirects if the trailing slash isn't included, so we add it
103+
// here to avoid extra roundtrips.
104+
return`${path}/@${workspace.owner_name}/${workspace.name}.${
105+
agent.name
106+
}/apps/${encodeURIComponent(app.slug)}/`;
122107
};
123108

124109
typeExternalWorkspaceApp=WorkspaceApp&{
@@ -131,3 +116,12 @@ export const isExternalApp = (
131116
):app isExternalWorkspaceApp=>{
132117
returnapp.external&&app.url!==undefined;
133118
};
119+
120+
exportconstneedsSessionToken=(app:ExternalWorkspaceApp)=>{
121+
// HTTP links should never need the session token, since Cookies
122+
// handle sharing it when you access the Coder Dashboard. We should
123+
// never be forwarding the bare session token to other domains!
124+
constisHttp=app.url.startsWith("http");
125+
constrequiresSessionToken=app.url.includes(SESSION_TOKEN_PLACEHOLDER);
126+
returnrequiresSessionToken&&!isHttp;
127+
};

‎site/src/modules/apps/useAppLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const useAppLink = (
3434
consthref=getAppHref(app,{
3535
agent,
3636
workspace,
37-
token:apiKeyResponse?.key??"",
37+
token:apiKeyResponse?.key,
3838
path:proxy.preferredPathAppURL,
3939
host:proxy.preferredWildcardHostname,
4040
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TooltipTrigger,
1010
}from"components/Tooltip/Tooltip";
1111
import{useProxy}from"contexts/ProxyContext";
12-
import{needsSessionToken}from"modules/apps/apps";
12+
import{isExternalApp,needsSessionToken}from"modules/apps/apps";
1313
import{useAppLink}from"modules/apps/useAppLink";
1414
import{typeFC,useState}from"react";
1515
import{AgentButton}from"../AgentButton";
@@ -65,7 +65,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
6565
"Your admin has not configured subdomain application access";
6666
}
6767

68-
if(needsSessionToken(app)&&!link.hasToken){
68+
if(isExternalApp(app)&&needsSessionToken(app)&&!link.hasToken){
6969
canClick=false;
7070
}
7171

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp