From e771027791cf985ebb6790a32dd4aee0f9de9ddb Mon Sep 17 00:00:00 2001 From: Garrett Date: Mon, 23 Oct 2023 09:16:10 -0700 Subject: [PATCH 1/2] Fix regex check --- schemas/json/dandi/global.json | 4 ++-- src/renderer/src/stories/pages/settings/SettingsPage.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/schemas/json/dandi/global.json b/schemas/json/dandi/global.json index e44e06df6..0daf4ef16 100644 --- a/schemas/json/dandi/global.json +++ b/schemas/json/dandi/global.json @@ -6,12 +6,12 @@ "main_api_key": { "type": "string", "format": "password", - "description": "From the main archive" + "description": "Your DANDI API key from the main archive" }, "staging_api_key": { "type": "string", "format": "password", - "description": "From the staging (testing) server" + "description": "Your DANDI API key from the staging (testing) server" } }, "required": ["main_api_key"] diff --git a/src/renderer/src/stories/pages/settings/SettingsPage.js b/src/renderer/src/stories/pages/settings/SettingsPage.js index afa2cb408..74571de7a 100644 --- a/src/renderer/src/stories/pages/settings/SettingsPage.js +++ b/src/renderer/src/stories/pages/settings/SettingsPage.js @@ -8,7 +8,7 @@ import projectGlobalSchema from "../../../../../../schemas/json/project/globals. const schema = { properties: { output_locations: projectGlobalSchema, - DANDI: dandiGlobalSchema, + DANDI: dandiGlobalSchema }, }; @@ -17,6 +17,7 @@ import { global } from "../../../progress/index.js"; import { merge } from "../utils.js"; import { notyf } from "../../../dependencies/globals.js"; +import { header } from "../../forms/utils"; const dandiAPITokenRegex = /^[a-f0-9]{40}$/; @@ -78,7 +79,9 @@ export class SettingsPage extends Page { onUpdate: () => (this.unsavedUpdates = true), validateOnChange: (name, parent) => { const value = parent[name]; - if (name.includes("api_key")) return dandiAPITokenRegex.test(value); + if (value && name.includes("api_key") && !dandiAPITokenRegex.test(value)) return [ + {type: 'error', message: `${header(name)} must be a 40 character hexadecimal string`} + ] return true; }, onThrow, From a1f40a408b74154e8348c3eeeb9b2a2ab21c0575 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:18:04 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/stories/pages/settings/SettingsPage.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/stories/pages/settings/SettingsPage.js b/src/renderer/src/stories/pages/settings/SettingsPage.js index 74571de7a..c65617574 100644 --- a/src/renderer/src/stories/pages/settings/SettingsPage.js +++ b/src/renderer/src/stories/pages/settings/SettingsPage.js @@ -8,7 +8,7 @@ import projectGlobalSchema from "../../../../../../schemas/json/project/globals. const schema = { properties: { output_locations: projectGlobalSchema, - DANDI: dandiGlobalSchema + DANDI: dandiGlobalSchema, }, }; @@ -79,9 +79,8 @@ export class SettingsPage extends Page { onUpdate: () => (this.unsavedUpdates = true), validateOnChange: (name, parent) => { const value = parent[name]; - if (value && name.includes("api_key") && !dandiAPITokenRegex.test(value)) return [ - {type: 'error', message: `${header(name)} must be a 40 character hexadecimal string`} - ] + if (value && name.includes("api_key") && !dandiAPITokenRegex.test(value)) + return [{ type: "error", message: `${header(name)} must be a 40 character hexadecimal string` }]; return true; }, onThrow,