Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KXI-38118 - Minor connection page issues #278

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/panels/newConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class NewConnectionPannel {
if (message.command === "kdb.newConnection.createNewBundledConnection") {
if (ext.isBundleQCreated) {
vscode.window.showErrorMessage(
"Bundle Q is already created, please remove it first",
"Bundled Q is already created, please remove it first",
);
} else {
vscode.commands.executeCommand(
Expand Down
6 changes: 3 additions & 3 deletions src/validators/kdbValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export function validateServerAlias(
return `Input value must be between 1 and ${MAX_STR_LEN} alphanumeric characters in length.`;
}
if (!validateUtils.isAlphanumericWithHypens(input)) {
return "Input value must contain only alphanumeric characters and hypens only";
return "Input value must contain only alphanumeric characters and hypens";
}

if (input === "InsightsEnterprise") {
return "Input value using restricted keywords of Insights Enterprise";
}

if (!isLocal && input.toLowerCase() === "local") {
return "Input value using restricted keywords of Local for Bundle q Server";
return "The server name “local” is reserved for connections to the Bundled q process";
}
}
return undefined;
Expand All @@ -65,7 +65,7 @@ export function validateServerPort(
return "Input value must be a number.";
}
const parsedNumber = Number(input);
return parsedNumber > 0 && parsedNumber < 65536
return parsedNumber > 0 && parsedNumber < 65537
? undefined
: "Invalid port number, valid range is 1-65536";
}
Expand Down
36 changes: 26 additions & 10 deletions src/webview/components/kdbNewConnectionView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export class KdbNewConnectionView extends LitElement {
<b>Bundled q.</b></span
>`
: html`<span
>Name the server,<u>but do not use "local";</u> "local" has been
>Name the server, <u>but do not use "local";</u> "local" has been
reserved for use by the pre-packaged q in the kdb VS Code
extension</span
extension.</span
>`;
}

Expand Down Expand Up @@ -134,6 +134,18 @@ export class KdbNewConnectionView extends LitElement {
`;
}

renderPortNumberDesc() {
return this.isBundledQ
? html`<span
>Ensure the port number you use does not conflict with another
port.</span
>`
: html`<span
>Ensure <b>Set port number</b> matches the assigned port of your q
process, and doesn’t conflict with another port.</span
>`;
}

renderPortNumber() {
return html`
<div class="row">
Expand All @@ -152,11 +164,7 @@ export class KdbNewConnectionView extends LitElement {
>
</div>
<div class="row option-description option-help">
<span
>${this.isBundledQ
? "Ensure the port number you use does not conflict with another port."
: "Ensure <b>Set port number</b> matches the assigned port of your q process, and doesn’t conflict with another port."}</span
>
${this.renderPortNumberDesc()}
</div>
`;
}
Expand Down Expand Up @@ -254,7 +262,7 @@ export class KdbNewConnectionView extends LitElement {
<vscode-panel-tab
id="tab-1"
@click="${() => this.tabClickAction(1)}"
>Bundle q</vscode-panel-tab
>Bundled q</vscode-panel-tab
>
<vscode-panel-tab
id="tab-2"
Expand Down Expand Up @@ -310,7 +318,11 @@ export class KdbNewConnectionView extends LitElement {
<div class="row">
<vscode-text-field
class="text-field larger option-title"
value="${this.kdbServer.username}"
value="${
this.kdbServer.username
? this.kdbServer.username
: ""
}"
@input="${(event: Event) =>
(this.kdbServer.username = (
event.target as HTMLSelectElement
Expand All @@ -322,7 +334,11 @@ export class KdbNewConnectionView extends LitElement {
<vscode-text-field
type="password"
class="text-field larger option-title"
value="${this.kdbServer.password}"
value="${
this.kdbServer.password
? this.kdbServer.password
: ""
}"
@input="${(event: Event) =>
(this.kdbServer.password = (
event.target as HTMLSelectElement
Expand Down
6 changes: 3 additions & 3 deletions test/suite/validators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("kdbValidator", () => {
const result = kdbValidators.validateServerAlias("test!", false);
assert.strictEqual(
result,
"Input value must contain only alphanumeric characters and hypens only",
"Input value must contain only alphanumeric characters and hypens",
"Input contained special chars",
);
});
Expand All @@ -109,7 +109,7 @@ describe("kdbValidator", () => {
const result = kdbValidators.validateServerAlias("local", false);
assert.strictEqual(
result,
"Input value using restricted keywords of Local for Bundle q Server",
"The server name “local” is reserved for connections to the Bundled q process",
"Input contained restricted keyword.",
);
});
Expand All @@ -118,7 +118,7 @@ describe("kdbValidator", () => {
const result = kdbValidators.validateServerAlias("local", false);
assert.strictEqual(
result,
"Input value using restricted keywords of Local for Bundle q Server",
"The server name “local” is reserved for connections to the Bundled q process",
"Input contained restricted keyword.",
);
});
Expand Down
25 changes: 23 additions & 2 deletions test/suite/webview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,33 @@ describe("KdbNewConnectionView", () => {
});
});

describe("renderPortNumberDesc", () => {
it("should render port number desc for bundled q", () => {
view.isBundledQ = true;
const result = view.renderPortNumberDesc(ServerType.KDB);
assert.strictEqual(
JSON.stringify(result).includes(
"Ensure the port number you use does not conflict with another",
),
true,
);
});

it("should render port number desc for KDB server", () => {
view.isBundledQ = false;
const result = view.renderPortNumberDesc(ServerType.KDB);
assert.strictEqual(
JSON.stringify(result).includes("<b>Set port number</b>"),
true,
);
});
});
describe("renderPortNumber", () => {
it("should render port number for bundle q", () => {
it("should render port number for bundled q", () => {
const result = view.renderPortNumber(ServerType.KDB);
assert.strictEqual(
JSON.stringify(result).includes(
"Ensure the port number you use does not conflict with another port.",
"Ensure the port number you use does not conflict with another",
),
true,
);
Expand Down
Loading