Skip to content

Commit 7dd8471

Browse files
Copilotbendichter
andcommitted
Address reviewer feedback: change all staging references to sandbox
Co-authored-by: bendichter <[email protected]>
1 parent 70accc0 commit 7dd8471

File tree

11 files changed

+51
-51
lines changed

11 files changed

+51
-51
lines changed

docs/conf_extlinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"guide-issues": ("https://github.com/NeurodataWithoutBorders/nwb-guide/issues/%s", "%s"),
99
"request-format-support": ("https://github.com/catalystneuro/neuroconv/issues/new?assignees=&labels=enhancement%%2Cdata+interfaces&projects=&template=format_request.yml&title=%%5BNew+Format%%5D%%3A+%s", "%s"),
1010
"path-expansion-guide": ("https://neuroconv.readthedocs.io/en/main/user_guide/expand_path.html%s", "%s"),
11-
"dandi-sandbox": ("https://gui-sandbox.dandiarchive.org/%s", "%s"),
11+
"dandi-sandbox": ("https://sandbox.dandiarchive.org/%s", "%s"),
1212
"dandi-archive": ("https://dandiarchive.org/%s", "%s"),
1313
"conda-install": (
1414
"https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html#regular-installation%s",

docs/developer_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Updating Tutorial Screenshots
246246
Before a release, you'll want to update the tutorial screenshots to reflect the latest changes in the application.
247247

248248
#. To regenerate the dataset, you'll need to change ``regenerateTestData`` in the ``tests/e2e/config.ts`` to ``true`` or delete the test dataset directory ``rm -rf ~/NWB_GUIDE/.test``.
249-
#. Create a ``.env`` file with the following content: ``DANDI_STAGING_API_KEY={your_dandi_sandbox_api_key}`` where ``{your_dandi_sandbox_api_key}`` is your DANDI sandbox API key from https://gui-sandbox.dandiarchive.org.
249+
#. Create a ``.env`` file with the following content: ``DANDI_STAGING_API_KEY={your_dandi_sandbox_api_key}`` where ``{your_dandi_sandbox_api_key}`` is your DANDI sandbox API key from https://sandbox.dandiarchive.org.
250250
#. Run the End-to-End Tests locally using ``npm run test:tutorial``. This will generate new screenshots in the ``docs/assets/tutorials`` directory.
251251
#. Review the new screenshots to ensure they are accurate.
252252
#. If the screenshots are accurate, commit them to the repository. Their paths should be consistent across runs—allowing the new versions to show up on the tutorial.

src/electron/frontend/core/components/DandiResults.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LitElement, css, html } from "lit";
22

33
import { get } from "dandi";
4-
import { isStaging, getAPIKey } from "../../utils/upload";
4+
import { isSandbox, getAPIKey } from "../../utils/upload";
55

66
export class DandiResults extends LitElement {
77
static get styles() {
@@ -38,9 +38,9 @@ export class DandiResults extends LitElement {
3838

3939
const otherElIds = ["embargo_status"];
4040

41-
const staging = isStaging(this.id);
42-
const type = staging ? "staging" : undefined;
43-
const api_key = await getAPIKey.call(this, staging);
41+
const sandbox = isSandbox(this.id);
42+
const type = sandbox ? "staging" : undefined;
43+
const api_key = await getAPIKey.call(this, sandbox);
4444

4545
const dandiset = await get(this.id, {
4646
type,

src/electron/frontend/core/components/pages/guided-mode/options/GuidedUpload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class GuidedUploadPage extends Page {
8989
formProps: {
9090
validateOnChange: async (name, parent) => {
9191
const value = parent[name];
92-
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("staging"));
92+
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("sandbox"));
9393
},
9494
},
9595
});

src/electron/frontend/core/components/pages/settings/SettingsPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class SettingsPage extends Page {
330330
onUpdate: () => (this.unsavedUpdates = true),
331331
validateOnChange: async (name, parent) => {
332332
const value = parent[name];
333-
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("staging"));
333+
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("sandbox"));
334334
return true;
335335
},
336336
onThrow,

src/electron/frontend/core/components/pages/uploads/UploadsPage.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import keyIcon from "../../../../assets/icons/key.svg?raw";
3434
import {
3535
AWARD_VALIDATION_FAIL_MESSAGE,
3636
awardNumberValidator,
37-
isStaging,
37+
isSandbox,
3838
validate,
3939
getAPIKey,
4040
} from "../../../../utils/upload";
@@ -119,14 +119,14 @@ export function createDandiset(results = {}) {
119119
throw message;
120120
});
121121

122-
const uploadToMain = form.resolved.archive === "main";
123-
const staging = !uploadToMain;
124-
125-
const api_key = await getAPIKey.call(this, staging);
126-
127-
const api = new dandi.API({
128-
token: api_key,
129-
type: staging ? "staging" : undefined,
122+
const uploadToMain = form.resolved.archive === "main";
123+
const sandbox = !uploadToMain;
124+
125+
const api_key = await getAPIKey.call(this, sandbox);
126+
127+
const api = new dandi.API({
128+
token: api_key,
129+
type: sandbox ? "staging" : undefined,
130130
});
131131

132132
await api.authorize();
@@ -185,15 +185,15 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
185185

186186
const dandiset_id = dandiset;
187187

188-
const staging = isStaging(dandiset_id); // Automatically detect staging IDs
189-
190-
const api_key = await getAPIKey.call(this, staging);
191-
192-
const payload = {
193-
dandiset_id,
194-
...info.additional_settings,
195-
staging,
196-
api_key,
188+
const sandbox = isSandbox(dandiset_id); // Automatically detect sandbox IDs
189+
190+
const api_key = await getAPIKey.call(this, sandbox);
191+
192+
const payload = {
193+
dandiset_id,
194+
...info.additional_settings,
195+
staging: sandbox,
196+
api_key,
197197
};
198198

199199
if (info.project) payload.project = info.project;
@@ -269,7 +269,7 @@ export class UploadsPage extends Page {
269269
formProps: {
270270
validateOnChange: async (name, parent) => {
271271
const value = parent[name];
272-
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("staging"));
272+
if (name.includes("api_key")) return await validateDANDIApiKey(value, name.includes("sandbox"));
273273
},
274274
},
275275
}));

src/electron/frontend/core/validation/dandi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ const dandiAPITokenRegex = /^[a-f0-9]{40}$/;
33

44
import { validateToken } from 'dandi'
55

6-
export const validateDANDIApiKey = async (apiKey: string, staging = false) => {
6+
export const validateDANDIApiKey = async (apiKey: string, sandbox = false) => {
77
if (apiKey) {
88

99
if (!dandiAPITokenRegex.test(apiKey)) return [{ type: "error", message: `Invalid API key format. Must be a 40 character hexadecimal string` }];
1010

11-
const authFailedError = {type: 'error', message: `Authorization failed. Make sure you're providing an API key for the <a href='https://${staging ? 'gui-sandbox.' : ''}dandiarchive.org' target='_blank'>${staging ? 'sandbox' : 'main'} archive</a>.`}
11+
const authFailedError = {type: 'error', message: `Authorization failed. Make sure you're providing an API key for the <a href='https://${sandbox ? 'sandbox.' : ''}dandiarchive.org' target='_blank'>${sandbox ? 'sandbox' : 'main'} archive</a>.`}
1212

13-
const isValid = validateToken({ token: apiKey, type: staging ? 'staging' : undefined }).catch(e => false)
13+
const isValid = validateToken({ token: apiKey, type: sandbox ? 'staging' : undefined }).catch(e => false)
1414
if (!isValid) return [ authFailedError ]
1515
return true
1616
}

src/electron/frontend/utils/upload.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { NotyfNotification } from "notyf";
1818
import dandiGlobalSchema from "../../../schemas/json/dandi/global.json";
1919
import { isNumericString } from "./typecheck";
2020

21-
export const isStaging = (id: string) => parseInt(id) >= 100000;
21+
export const isSandbox = (id: string) => parseInt(id) >= 100000;
2222

2323
type NotificationType = {
2424
type: string;
@@ -51,9 +51,9 @@ export async function validate(
5151
message: `<b>Invalid ID –</b> Dandiset ID must be 6 digits.`
5252
}]
5353

54-
const staging = isStaging(value)
55-
const type = staging ? "staging" : undefined;
56-
const token = await getAPIKey.call(this, staging);
54+
const sandbox = isSandbox(value)
55+
const type = sandbox ? "staging" : undefined;
56+
const token = await getAPIKey.call(this, sandbox);
5757

5858
const dandiset = await get(value, {
5959
type,
@@ -106,14 +106,14 @@ export const AWARD_VALIDATION_FAIL_MESSAGE = 'Award number must be properly spac
106106
// this:
107107
export async function getAPIKey(
108108
this: Page,
109-
staging = false
109+
sandbox = false
110110
) {
111111

112-
const whichAPIKey = staging ? "development_api_key" : "main_api_key";
112+
const whichAPIKey = sandbox ? "sandbox_api_key" : "main_api_key";
113113
const DANDI = global.data.DANDI;
114114
let api_key = DANDI?.api_keys?.[whichAPIKey];
115115

116-
const errors = await validateDANDIApiKey(api_key, staging);
116+
const errors = await validateDANDIApiKey(api_key, sandbox);
117117

118118
const isInvalid = Array.isArray(errors) ? errors.length : !errors;
119119

@@ -154,7 +154,7 @@ export async function getAPIKey(
154154
onClick: async () => {
155155
const value = input.value;
156156
if (value) {
157-
const errors = await validateDANDIApiKey(input.value, staging);
157+
const errors = await validateDANDIApiKey(input.value, sandbox);
158158
if (!errors || !errors.length) {
159159
modal.remove();
160160

src/schemas/dandi-upload.schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Dandiset, getMine } from 'dandi'
22

33
import { global } from '../electron/frontend/core/progress'
44
import upload from './json/dandi/upload.json' assert { type: "json" }
5-
import { isStaging } from '../electron/frontend/utils/upload'
5+
import { isSandbox } from '../electron/frontend/utils/upload'
66
import { baseUrl, onServerOpen } from '../electron/frontend/core/server/globals'
77
import { isStorybook } from '../electron/frontend/core/globals'
88

@@ -54,16 +54,16 @@ export const regenerateDandisets = async () => {
5454

5555
export const updateDandisets = async (main = true) => {
5656

57-
const staging = !main
57+
const sandbox = !main
5858

5959
// Fetch My Dandisets
60-
const whichAPIKey = staging ? "development_api_key" : "main_api_key";
60+
const whichAPIKey = sandbox ? "sandbox_api_key" : "main_api_key";
6161
const DANDI = global.data.DANDI;
6262
let token = DANDI?.api_keys?.[whichAPIKey];
6363

6464
if (!token) return []
6565

66-
return await getMine({ token, type: staging ? 'staging' : undefined }, { embargoed: true })
66+
return await getMine({ token, type: sandbox ? 'staging' : undefined }, { embargoed: true })
6767
.then((results) => results ? Promise.all(results.map(addDandiset)) : [])
6868
.catch(() => {
6969
return []
@@ -85,22 +85,22 @@ export const addDandiset = async (info) => {
8585
enumSet.add(id)
8686
idSchema.enum = Array.from(enumSet)
8787

88-
const staging = isStaging(id)
88+
const sandbox = isSandbox(id)
8989

9090
if (!idSchema.enumLabels) idSchema.enumLabels = {}
9191
if (!idSchema.enumKeywords) idSchema.enumKeywords = {}
9292
if (!idSchema.enumCategories) idSchema.enumCategories = {}
9393

9494

95-
const token = global.data.DANDI.api_keys[staging ? "development_api_key" : "main_api_key"];
95+
const token = global.data.DANDI.api_keys[sandbox ? "sandbox_api_key" : "main_api_key"];
9696

97-
info = new Dandiset(info, { type: staging ? "staging" : undefined, token })
97+
info = new Dandiset(info, { type: sandbox ? "staging" : undefined, token })
9898

9999
const latestVersionInfo = (info.most_recent_published_version ?? info.draft_version)!
100100
const enumLabels = `${id}${latestVersionInfo.name}`
101101

102102
const isDraft = latestVersionInfo.version === 'draft'
103-
const enumCategories = (isDraft ? 'Unpublished' : '') + (staging ? `${isDraft ? ` - ` : ''}Staging` : '')
103+
const enumCategories = (isDraft ? 'Unpublished' : '') + (sandbox ? `${isDraft ? ` - ` : ''}Sandbox` : '')
104104

105105
const fullInfo = await info.getInfo({ version: latestVersionInfo.version });
106106

src/schemas/json/dandi/create.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"archive": {
2424
"type": "string",
2525
"enumLabels": {
26-
"staging": "Sandbox Server",
26+
"sandbox": "Sandbox Server",
2727
"main": "Main Archive"
2828
},
29-
"enum": ["main", "staging"],
29+
"enum": ["main", "sandbox"],
3030
"description": "Which DANDI server to upload to. <br><small><b>Note:</b> The Sandbox Server is recommended for developers, or users learning to use DANDI</small>",
3131
"strict": true
3232
},

0 commit comments

Comments
 (0)