From 4b74ced804e19fafa0f6df700e6242e8683a59d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 23:18:33 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/JSONSchemaForm.js | 9 ++-- src/renderer/src/stories/JSONSchemaInput.js | 43 ++++++++----------- src/renderer/src/stories/Search.js | 41 +++++++++--------- .../guided-mode/data/GuidedPathExpansion.js | 1 - .../src/stories/pages/uploads/UploadsPage.js | 8 ++-- 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index d86562bd4..c7a12424a 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -125,7 +125,7 @@ const componentCSS = ` border: 1px solid black; border-radius: 4px; position: relative; - + } .link > div { @@ -818,14 +818,13 @@ export class JSONSchemaForm extends LitElement { const value = parent[name]; - const skipValidation = this.validateEmptyValues === null && value === undefined; const validateArgs = input.pattern || skipValidation ? [] : [value, schema]; // Run validation functions const jsonSchemaErrors = validateArgs.length === 2 ? this.validateSchema(...validateArgs, name) : []; - const valid = skipValidation ? true : await this.validateOnChange(name, parent, pathToValidate, value); + const valid = skipValidation ? true : await this.validateOnChange(name, parent, pathToValidate, value); if (valid === null) return null; // Skip validation / data change if the value is null @@ -882,9 +881,7 @@ export class JSONSchemaForm extends LitElement { type: "error", missing: true, }); - } - - else if (this.validateEmptyValues === null) { + } else if (this.validateEmptyValues === null) { warnings.push({ message: `${schema.title ?? header(name)} is a suggested property.`, type: "warning", diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index 0e16f0429..f1738717a 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -858,12 +858,11 @@ export class JSONSchemaInput extends LitElement { } const itemSchema = this.form?.getSchema ? this.form.getSchema("items", schema) : schema["items"]; - + const fileSystemFormat = isFilesystemSelector(name, itemSchema?.format); if (fileSystemFormat) return createFilesystemSelector(fileSystemFormat); // Create tables if possible else if (itemSchema?.type === "string" && !itemSchema.properties) { - const list = new List({ items: this.value, emptyMessage: "No items", @@ -873,10 +872,9 @@ export class JSONSchemaInput extends LitElement { }, }); - console.log(list) + console.log(list); if (itemSchema.enum) { - const search = new Search({ options: itemSchema.enum.map((v) => { return { @@ -889,45 +887,41 @@ export class JSONSchemaInput extends LitElement { }; }), value: this.value, - listMode: schema.strict === false ? 'click' : "append", + listMode: schema.strict === false ? "click" : "append", showAllWhenEmpty: false, onSelect: async ({ label, value }) => { - if (!value) return - if (schema.uniqueItems && this.value && this.value.includes(value)) return - list.add({ content: label, value }) + if (!value) return; + if (schema.uniqueItems && this.value && this.value.includes(value)) return; + list.add({ content: label, value }); }, }); search.style.height = "auto"; return html`
${option.description}
`, - allowHTML: true, - placement: "right", - }); + if (option.description) + tippy(info, { + content: `${option.description}
`, + allowHTML: true, + placement: "right", + }); } container.appendChild(label); @@ -482,14 +483,14 @@ export class Search extends LitElement { @blur=${(blurEvent) => { const relatedTarget = blurEvent.relatedTarget; if (relatedTarget) { - if (relatedTarget.classList.contains("option")) return; - if (relatedTarget.hasAttribute("data-link")) { - this.#ignore = true - return - } - } + if (relatedTarget.classList.contains("option")) return; + if (relatedTarget.hasAttribute("data-link")) { + this.#ignore = true; + return; + } + } - this.#close(); + this.#close(); }} > diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index b815e3554..77a0bb0fc 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -115,7 +115,6 @@ export async function autocompleteFormatString(path) { } } } else { - if (!parent.path) return; if (!value) return; diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js index 3cae6925f..408d1a7f4 100644 --- a/src/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js @@ -56,7 +56,7 @@ export async function createDandiset(results = {}) { }); const updateNIHInput = (embargoed) => { - const nihInput = form.getFormElement([ "nih_award_number" ]); + const nihInput = form.getFormElement(["nih_award_number"]); // Show the NIH input if embargo is set if (embargoed) nihInput.removeAttribute("hidden"); @@ -64,7 +64,7 @@ export async function createDandiset(results = {}) { // Make the NIH input required if embargo is set nihInput.required = embargoed; - } + }; const form = new JSONSchemaForm({ schema: dandiCreateSchema, @@ -73,7 +73,7 @@ export async function createDandiset(results = {}) { validateOnChange: async (name, parent) => { const value = parent[name]; - if (name === 'embargo_status') return updateNIHInput(value); + if (name === "embargo_status") return updateNIHInput(value); if (name === "nih_award_number") { if (value) @@ -97,7 +97,7 @@ export async function createDandiset(results = {}) { content.append(form); modal.append(content); - + modal.onClose = async () => notify("Dandiset was not created.", "error"); return new Promise((resolve) => {