@@ -7,16 +7,34 @@ import {
77 FILESYSTEM_READONLY_SCHEMA ,
88 explorerProvider ,
99} from "../extension" ;
10- import { connectionTarget , terminalWithDocker , shellWithDocker , currentFile } from "../utils" ;
10+ import {
11+ connectionTarget ,
12+ terminalWithDocker ,
13+ shellWithDocker ,
14+ currentFile ,
15+ } from "../utils" ;
1116import { mainCommandMenu , mainSourceControlMenu } from "./studio" ;
1217import { AtelierAPI } from "../api" ;
1318import { getCSPToken } from "../utils/getCSPToken" ;
1419
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+ } ;
1626export async function serverActions ( ) : Promise < void > {
1727 const { apiTarget, configName : workspaceFolder } = connectionTarget ( ) ;
1828 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 ;
2038 const explorerCount = ( await explorerProvider . getChildren ( ) ) . length ;
2139 if ( ! explorerCount && ( ! docker || host === "" ) ) {
2240 await vscode . commands . executeCommand ( "ObjectScriptExplorer.focus" ) ;
@@ -38,7 +56,9 @@ export async function serverActions(): Promise<void> {
3856 detail : "Force attempt to connect to the server" ,
3957 } ) ;
4058 }
41- const connectionActionsHandler = async ( action : ServerAction ) : Promise < ServerAction > => {
59+ const connectionActionsHandler = async (
60+ action : ServerAction
61+ ) : Promise < ServerAction > => {
4262 if ( ! action ) {
4363 return ;
4464 }
@@ -49,8 +69,13 @@ export async function serverActions(): Promise<void> {
4969 ? vscode . ConfigurationTarget . WorkspaceFolder
5070 : vscode . ConfigurationTarget . Workspace ;
5171 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+ ) ;
5479 }
5580 case "refreshConnection" : {
5681 await checkConnection ( true , undefined , true ) ;
@@ -69,10 +94,15 @@ export async function serverActions(): Promise<void> {
6994 } ) ;
7095 }
7196 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+ : "" ;
73101 const classnameEncoded = encodeURIComponent ( classname ) ;
74102 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 } `;
76106 const portalPath = `/csp/sys/UtilHome.csp?$NAMESPACE=${ nsEncoded } ` ;
77107 const classRef = `/csp/documatic/%25CSP.Documatic.cls?LIBRARY=${ nsEncoded } ${
78108 classname ? "&CLASSNAME=" + classnameEncoded : ""
@@ -81,7 +111,11 @@ export async function serverActions(): Promise<void> {
81111 for ( const title in links ) {
82112 const rawLink = String ( links [ title ] ) ;
83113 // 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+ ) {
85119 continue ;
86120 }
87121 const link = rawLink
@@ -127,7 +161,8 @@ export async function serverActions(): Promise<void> {
127161 if (
128162 ! vscode . window . activeTextEditor ||
129163 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
131166 ) {
132167 actions . push ( {
133168 id : "serverSourceControlMenu" ,
@@ -184,6 +219,7 @@ export async function serverActions(): Promise<void> {
184219 const path = vscode . Uri . parse ( urlString ) . path ;
185220 const token = await getCSPToken ( api , path ) ;
186221 if ( token . length > 0 ) {
222+ urlString += urlString . includes ( "?" ) ? "" : "?" ;
187223 urlString += `&CSPCHD=${ token } ` ;
188224 }
189225 }
0 commit comments