Skip to content

Commit

Permalink
Merge pull request #470 from NeurodataWithoutBorders/update-api-settings
Browse files Browse the repository at this point in the history
Update API Settings
  • Loading branch information
CodyCBakerPhD authored Oct 23, 2023
2 parents 13c8e8f + a1f40a4 commit fe407f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions schemas/json/dandi/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"main_api_key": {
"type": "string",
"format": "password",
"description": "From the <a href='https://dandiarchive.org' target='_blank'>main archive</a>"
"description": "Your DANDI API key from the <a href='https://dandiarchive.org' target='_blank'>main archive</a>"
},
"staging_api_key": {
"type": "string",
"format": "password",
"description": "From the <a href='https://gui-staging.dandiarchive.org' target='_blank'>staging (testing) server</a>"
"description": "Your DANDI API key from the <a href='https://gui-staging.dandiarchive.org' target='_blank'>staging (testing) server</a>"
}
},
"required": ["main_api_key"]
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/stories/pages/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}$/;

Expand Down Expand Up @@ -78,7 +79,8 @@ 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,
Expand Down

0 comments on commit fe407f4

Please sign in to comment.