@@ -7,16 +7,34 @@ import {
7
7
FILESYSTEM_READONLY_SCHEMA ,
8
8
explorerProvider ,
9
9
} from "../extension" ;
10
- import { connectionTarget , terminalWithDocker , shellWithDocker , currentFile } from "../utils" ;
10
+ import {
11
+ connectionTarget ,
12
+ terminalWithDocker ,
13
+ shellWithDocker ,
14
+ currentFile ,
15
+ } from "../utils" ;
11
16
import { mainCommandMenu , mainSourceControlMenu } from "./studio" ;
12
17
import { AtelierAPI } from "../api" ;
13
18
import { getCSPToken } from "../utils/getCSPToken" ;
14
19
15
- type ServerAction = { detail : string ; id : string ; label : string ; rawLink ?: string } ;
20
+ type ServerAction = {
21
+ detail : string ;
22
+ id : string ;
23
+ label : string ;
24
+ rawLink ?: string ;
25
+ } ;
16
26
export async function serverActions ( ) : Promise < void > {
17
27
const { apiTarget, configName : workspaceFolder } = connectionTarget ( ) ;
18
28
const api = new AtelierAPI ( apiTarget ) ;
19
- const { active, host = "" , ns = "" , https, port = 0 , pathPrefix, docker } = api . config ;
29
+ const {
30
+ active,
31
+ host = "" ,
32
+ ns = "" ,
33
+ https,
34
+ port = 0 ,
35
+ pathPrefix,
36
+ docker,
37
+ } = api . config ;
20
38
const explorerCount = ( await explorerProvider . getChildren ( ) ) . length ;
21
39
if ( ! explorerCount && ( ! docker || host === "" ) ) {
22
40
await vscode . commands . executeCommand ( "ObjectScriptExplorer.focus" ) ;
@@ -38,7 +56,9 @@ export async function serverActions(): Promise<void> {
38
56
detail : "Force attempt to connect to the server" ,
39
57
} ) ;
40
58
}
41
- const connectionActionsHandler = async ( action : ServerAction ) : Promise < ServerAction > => {
59
+ const connectionActionsHandler = async (
60
+ action : ServerAction
61
+ ) : Promise < ServerAction > => {
42
62
if ( ! action ) {
43
63
return ;
44
64
}
@@ -49,8 +69,13 @@ export async function serverActions(): Promise<void> {
49
69
? vscode . ConfigurationTarget . WorkspaceFolder
50
70
: vscode . ConfigurationTarget . Workspace ;
51
71
const targetConfig =
52
- connConfig . inspect ( "conn" ) . workspaceFolderValue || connConfig . inspect ( "conn" ) . workspaceValue ;
53
- return connConfig . update ( "conn" , { ...targetConfig , active : ! active } , target ) ;
72
+ connConfig . inspect ( "conn" ) . workspaceFolderValue ||
73
+ connConfig . inspect ( "conn" ) . workspaceValue ;
74
+ return connConfig . update (
75
+ "conn" ,
76
+ { ...targetConfig , active : ! active } ,
77
+ target
78
+ ) ;
54
79
}
55
80
case "refreshConnection" : {
56
81
await checkConnection ( true , undefined , true ) ;
@@ -69,10 +94,15 @@ export async function serverActions(): Promise<void> {
69
94
} ) ;
70
95
}
71
96
const file = currentFile ( ) ;
72
- const classname = file && file . name . toLowerCase ( ) . endsWith ( ".cls" ) ? file . name . slice ( 0 , - 4 ) : "" ;
97
+ const classname =
98
+ file && file . name . toLowerCase ( ) . endsWith ( ".cls" )
99
+ ? file . name . slice ( 0 , - 4 )
100
+ : "" ;
73
101
const classnameEncoded = encodeURIComponent ( classname ) ;
74
102
const connInfo = `${ host } :${ port } ${ pathPrefix } [${ nsEncoded . toUpperCase ( ) } ]` ;
75
- const serverUrl = `${ https ? "https" : "http" } ://${ host } :${ port } ${ pathPrefix } ` ;
103
+ const serverUrl = `${
104
+ https ? "https" : "http"
105
+ } ://${ host } :${ port } ${ pathPrefix } `;
76
106
const portalPath = `/csp/sys/UtilHome.csp?$NAMESPACE=${ nsEncoded } ` ;
77
107
const classRef = `/csp/documatic/%25CSP.Documatic.cls?LIBRARY=${ nsEncoded } ${
78
108
classname ? "&CLASSNAME=" + classnameEncoded : ""
@@ -81,7 +111,11 @@ export async function serverActions(): Promise<void> {
81
111
for ( const title in links ) {
82
112
const rawLink = String ( links [ title ] ) ;
83
113
// Skip link if it requires a classname and we don't currently have one
84
- if ( classname == "" && ( rawLink . includes ( "${classname}" ) || rawLink . includes ( "${classnameEncoded}" ) ) ) {
114
+ if (
115
+ classname == "" &&
116
+ ( rawLink . includes ( "${classname}" ) ||
117
+ rawLink . includes ( "${classnameEncoded}" ) )
118
+ ) {
85
119
continue ;
86
120
}
87
121
const link = rawLink
@@ -127,7 +161,8 @@ export async function serverActions(): Promise<void> {
127
161
if (
128
162
! vscode . window . activeTextEditor ||
129
163
vscode . window . activeTextEditor . document . uri . scheme === FILESYSTEM_SCHEMA ||
130
- vscode . window . activeTextEditor . document . uri . scheme === FILESYSTEM_READONLY_SCHEMA
164
+ vscode . window . activeTextEditor . document . uri . scheme ===
165
+ FILESYSTEM_READONLY_SCHEMA
131
166
) {
132
167
actions . push ( {
133
168
id : "serverSourceControlMenu" ,
@@ -184,6 +219,7 @@ export async function serverActions(): Promise<void> {
184
219
const path = vscode . Uri . parse ( urlString ) . path ;
185
220
const token = await getCSPToken ( api , path ) ;
186
221
if ( token . length > 0 ) {
222
+ urlString += urlString . includes ( "?" ) ? "" : "?" ;
187
223
urlString += `&CSPCHD=${ token } ` ;
188
224
}
189
225
}
0 commit comments