From 8f9f6a11c67db2f80dbf297d393df1d0625a8f54 Mon Sep 17 00:00:00 2001 From: Einingis Date: Fri, 27 Oct 2023 15:56:40 +0300 Subject: [PATCH 1/2] can read imported connections --- src/view/app/Connection/connectionForm.tsx | 42 +++++++++++++++------- src/view/app/model.ts | 1 + src/webview/ConnectionEditor.ts | 10 ++++++ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/view/app/Connection/connectionForm.tsx b/src/view/app/Connection/connectionForm.tsx index 32da5918..dc4b3634 100644 --- a/src/view/app/Connection/connectionForm.tsx +++ b/src/view/app/Connection/connectionForm.tsx @@ -39,6 +39,7 @@ function ConnectionForm({ const [group, setGroup] = React.useState(vsState.config.group); const [label, setLabel] = React.useState(vsState.config.label); const [params, setParams] = React.useState(vsState.config.params); + const [workState, setWorkState] = React.useState(vsState.config.workState); const logger = new Logger(configuration.logging.react); @@ -275,13 +276,15 @@ function ConnectionForm({
Connect to server
- } - > - Import .pf - + {!workState && ( + } + > + Import .pf + + )}
@@ -294,6 +297,7 @@ function ConnectionForm({ onChange={(event) => { setLabel(event.target.value); }} + disabled={workState} />
@@ -313,6 +317,7 @@ function ConnectionForm({ ); setGroup(event.target.value); }} + disabled={workState} onKeyDown={handleKeyDown} />
    @@ -325,6 +330,7 @@ function ConnectionForm({ onChange={(event) => { setName(event.target.value); }} + disabled={workState} />
    @@ -337,6 +343,7 @@ function ConnectionForm({ onChange={(event) => { setDescription(event.target.value); }} + disabled={workState} /> @@ -349,6 +356,7 @@ function ConnectionForm({ onChange={(event) => { setHost(event.target.value); }} + disabled={workState} />
    @@ -359,6 +367,7 @@ function ConnectionForm({ onChange={(event) => { setPort(event.target.value); }} + disabled={workState} />
    @@ -369,6 +378,7 @@ function ConnectionForm({ onChange={(event) => { setUser(event.target.value); }} + disabled={workState} />
    @@ -379,6 +389,7 @@ function ConnectionForm({ onChange={(event) => { setPassword(event.target.value); }} + disabled={workState} />
    @@ -389,16 +400,21 @@ function ConnectionForm({ onChange={(event) => { setParams(event.target.value); }} + disabled={workState} />
    -
    - -
    -
    - -
    + {!workState && ( +
    + +
    + )} + {!workState && ( +
    + +
    + )}
    diff --git a/src/view/app/model.ts b/src/view/app/model.ts index 1a1adf7e..e9bf25a0 100644 --- a/src/view/app/model.ts +++ b/src/view/app/model.ts @@ -18,6 +18,7 @@ export interface IConfig { group: string; params: string; conStatus?: ConnectionStatus; + workState?: boolean; } export interface IRemoteConnectionConfig { diff --git a/src/webview/ConnectionEditor.ts b/src/webview/ConnectionEditor.ts index 6130d721..e89b6fd1 100644 --- a/src/webview/ConnectionEditor.ts +++ b/src/webview/ConnectionEditor.ts @@ -175,6 +175,7 @@ export class ConnectionEditor { params: "", connectionId: "LOCAL", type: 0, + workState: false, }; if (this.id) { const connections = this.context.globalState.get<{ @@ -182,6 +183,15 @@ export class ConnectionEditor { }>(`${Constants.globalExtensionKey}.dbconfig`); if (connections) { config = connections[this.id]; + if (!config) { + const workspaceConnections = this.context.workspaceState.get<{ + [id: string]: IConfig; + }>(`${Constants.globalExtensionKey}.dbconfig`); + if (workspaceConnections) { + config = workspaceConnections[this.id]; + config.workState = true; + } + } } } From 116302683fdd7774a5a71a31724e12cee895ab94 Mon Sep 17 00:00:00 2001 From: Einingis Date: Thu, 9 Nov 2023 14:50:29 +0200 Subject: [PATCH 2/2] remove unused variables --- src/view/app/Connection/connectionForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/app/Connection/connectionForm.tsx b/src/view/app/Connection/connectionForm.tsx index dc4b3634..a69c47be 100644 --- a/src/view/app/Connection/connectionForm.tsx +++ b/src/view/app/Connection/connectionForm.tsx @@ -39,7 +39,7 @@ function ConnectionForm({ const [group, setGroup] = React.useState(vsState.config.group); const [label, setLabel] = React.useState(vsState.config.label); const [params, setParams] = React.useState(vsState.config.params); - const [workState, setWorkState] = React.useState(vsState.config.workState); + const [workState] = React.useState(vsState.config.workState); const logger = new Logger(configuration.logging.react);