Skip to content

Commit

Permalink
Merge branch 'main' into preload_imports
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Sep 6, 2023
2 parents 1ca8523 + 4ca74cc commit d10242a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/renderer/src/stories/JSONSchemaForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,15 @@ export class JSONSchemaForm extends LitElement {
this.#clearMessages(fullPath, "errors");
this.#clearMessages(fullPath, "warnings");

const isFunction = typeof valid === "function";
const isValid =
valid === true ||
valid == undefined ||
isFunction ||
(Array.isArray(valid) && !valid.find((o) => o.type === "error"));

if (!isValid && errors.length === 0) errors.push({ type: "error", message: "Invalid value detected" });

// Track errors and warnings
this.#nErrors += errors.length;
this.#nWarnings += warnings.length;
Expand All @@ -595,12 +604,7 @@ export class JSONSchemaForm extends LitElement {
// Show aggregated errors and warnings (if any)
warnings.forEach((info) => this.#addMessage(fullPath, info, "warnings"));

const isFunction = typeof valid === "function";

if (
(valid === true || valid == undefined || isFunction || !valid.find((o) => o.type === "error")) &&
errors.length === 0
) {
if (isValid && errors.length === 0) {
element.classList.remove("invalid");

const linkEl = this.#getLinkElement(externalPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class GuidedMetadataPage extends ManagedPage {
},

onUpdate: (...args) => {
console.log(...args);
this.unsavedUpdates = true;
},

Expand Down
7 changes: 7 additions & 0 deletions src/renderer/src/stories/pages/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { merge } from "../utils.js";

import { notyf } from "../../../dependencies/globals.js";

const dandiAPITokenRegex = /^[a-f0-9]{40}$/;

const setUndefinedIfNotDeclared = (schema, resolved) => {
for (let prop in schema.properties) {
const propInfo = schema.properties[prop];
Expand Down Expand Up @@ -65,6 +67,11 @@ export class SettingsPage extends Page {
schema,
mode: "accordion",
onUpdate: () => (this.unsavedUpdates = true),
validateOnChange: (name, parent) => {
const value = parent[name];
if (name === "api_key") return dandiAPITokenRegex.test(value);
return true;
},
onThrow,
});

Expand Down

0 comments on commit d10242a

Please sign in to comment.