Skip to content

Commit

Permalink
Merge pull request #436 from BalticAmadeus/404-read-only-screen-for-i…
Browse files Browse the repository at this point in the history
…mported-connections

can read imported connections
  • Loading branch information
PauliusKu authored Nov 9, 2023
2 parents d6a31d1 + 1163026 commit 5bc6437
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
42 changes: 29 additions & 13 deletions src/view/app/Connection/connectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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] = React.useState(vsState.config.workState);

const logger = new Logger(configuration.logging.react);

Expand Down Expand Up @@ -275,13 +276,15 @@ function ConnectionForm({
<div className="container">
<div className="heading">
<div className="title">Connect to server</div>
<ProBroButton
className="importPf"
onClick={importPf}
startIcon={<FileUploadRoundedIcon />}
>
Import .pf
</ProBroButton>
{!workState && (
<ProBroButton
className="importPf"
onClick={importPf}
startIcon={<FileUploadRoundedIcon />}
>
Import .pf
</ProBroButton>
)}
</div>
<div className="content">
<form action="#">
Expand All @@ -294,6 +297,7 @@ function ConnectionForm({
onChange={(event) => {
setLabel(event.target.value);
}}
disabled={workState}
/>
</div>
<div className="input-box">
Expand All @@ -313,6 +317,7 @@ function ConnectionForm({
);
setGroup(event.target.value);
}}
disabled={workState}
onKeyDown={handleKeyDown}
/>
<ul className="autocomplete-list" id="column-list"></ul>
Expand All @@ -325,6 +330,7 @@ function ConnectionForm({
onChange={(event) => {
setName(event.target.value);
}}
disabled={workState}
/>
</div>
</div>
Expand All @@ -337,6 +343,7 @@ function ConnectionForm({
onChange={(event) => {
setDescription(event.target.value);
}}
disabled={workState}
/>
</div>
</div>
Expand All @@ -349,6 +356,7 @@ function ConnectionForm({
onChange={(event) => {
setHost(event.target.value);
}}
disabled={workState}
/>
</div>
<div className="input-box">
Expand All @@ -359,6 +367,7 @@ function ConnectionForm({
onChange={(event) => {
setPort(event.target.value);
}}
disabled={workState}
/>
</div>
<div className="input-box">
Expand All @@ -369,6 +378,7 @@ function ConnectionForm({
onChange={(event) => {
setUser(event.target.value);
}}
disabled={workState}
/>
</div>
<div className="input-box">
Expand All @@ -379,6 +389,7 @@ function ConnectionForm({
onChange={(event) => {
setPassword(event.target.value);
}}
disabled={workState}
/>
</div>
<div className="input-box-wide">
Expand All @@ -389,16 +400,21 @@ function ConnectionForm({
onChange={(event) => {
setParams(event.target.value);
}}
disabled={workState}
/>
</div>
</div>
<div className="buttons">
<div className="button-narrow">
<input type="submit" value="Test" onClick={onTestClick} />
</div>
<div className="button-narrow">
<input type="submit" value="Save" onClick={onSaveClick} />
</div>
{!workState && (
<div className="button-narrow">
<input type="submit" value="Test" onClick={onTestClick} />
</div>
)}
{!workState && (
<div className="button-narrow">
<input type="submit" value="Save" onClick={onSaveClick} />
</div>
)}
</div>
</form>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/view/app/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IConfig {
group: string;
params: string;
conStatus?: ConnectionStatus;
workState?: boolean;
}

export interface IRemoteConnectionConfig {
Expand Down
10 changes: 10 additions & 0 deletions src/webview/ConnectionEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,23 @@ export class ConnectionEditor {
params: "",
connectionId: "LOCAL",
type: 0,
workState: false,
};
if (this.id) {
const connections = this.context.globalState.get<{
[id: string]: IConfig;
}>(`${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;
}
}
}
}

Expand Down

0 comments on commit 5bc6437

Please sign in to comment.