Skip to content
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 packages/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Add command to run single cypher statement (ctrl+enter) and add new keybind for running all statements (ctrl+alt/cmd+enter)
- Modify run button to run selected text on selection and otherwise run single statement at cursor
- Auto-focus on query results panel when running query
- Minor bugfixes (handling new linter naming scheme, formatter capitalizing preparser keywords in namespaces, linter terminating on slow queries, missing label warnings, queries needing implicit transactions, "run cypher" keybind being active when cypher can't be run, formatting of dynamic labels, duplication in connections pane when db uses clustering (ex. aura business critical), linter switching for aura, point printing alignment with cypher shell)
- Minor bugfixes (handling new linter naming scheme, formatter capitalizing preparser keywords in namespaces, linter terminating on slow queries, missing label warnings, queries needing implicit transactions, "run cypher" keybind being active when cypher can't be run, formatting of dynamic labels, duplication in connections pane when db uses clustering (ex. aura business critical), linter switching for aura, point printing alignment with cypher shell, empty fields being forbidden in the password/user fields when adding a connection)

## 1.13.0
- Adjusts linting automatically depending on the neo4j version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,28 @@ declare const vscode: vscode;

/**
* Validates a Connection object and a password from the webview form.ƒ
* @param connection The Connection object to validate. Only scheme, host, user, and password are required.
* @param connection The Connection object to validate. Only scheme and host are required.
* @param password The password to validate.
* @returns True if the connection is valid, false otherwise.
*/
export function validateConnection(
connection: Connection | null,
password: string,
): boolean {
export function validateConnection(connection: Connection | null): boolean {
highlightInvalidFields();
return (
!connection ||
(!!connection.scheme &&
!!connection.host &&
!!connection.user &&
!!password)
);
return !connection || (!!connection.scheme && !!connection.host);
}

/**
* Highlights any invalid fields in the webview form by toggling the invalid class.
* Only scheme, host, user, and password are required.
* Only scheme and host are required.
*/
export function highlightInvalidFields(): void {
const scheme = document.getElementById('scheme') as HTMLInputElement;
const host = document.getElementById('host') as HTMLInputElement;
const user = document.getElementById('user') as HTMLInputElement;
const password = document.getElementById('password') as HTMLInputElement;

scheme.classList.toggle(
'invalid',
!scheme.value || !isValidScheme(scheme.value),
);
host.classList.toggle('invalid', !host.value);
user.classList.toggle('invalid', !user.value);
password.classList.toggle('invalid', !password.value);
}

/**
Expand Down Expand Up @@ -123,7 +110,7 @@ export function onSubmit(event: Event): boolean {
const connection = getConnection();
const password = getPassword();

if (!validateConnection(connection, password)) {
if (!validateConnection(connection)) {
vscode.postMessage({
command: 'onValidationError',
});
Expand Down