Skip to content

Commit 905825d

Browse files
authored
Merge branch 'main' into fix_windows_path
2 parents 3808fa5 + 637d624 commit 905825d

File tree

62 files changed

+676
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+676
-407
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export class BasicTable extends LitElement {
509509
size="small"
510510
@click=${() => {
511511
const input = document.createElement("input");
512-
input.type = "file";
512+
input.type = "file-path";
513513
input.accept = "text/tab-separated-values";
514514
input.click();
515515
input.onchange = () => {

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

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,41 @@ const { dialog } = remote;
77
import restartSVG from "../../assets/icons/restart.svg?raw";
88
import { unsafeSVG } from "lit/directives/unsafe-svg.js";
99

10-
function getObjectTypeReferenceString(type, multiple, { nested, native } = {}) {
11-
if (Array.isArray(type))
12-
return `${multiple ? "" : "a "}${type
13-
.map((type) => getObjectTypeReferenceString(type, multiple, { native, nested: true }))
14-
.join(" / ")}`;
15-
16-
const isDir = type === "directory";
17-
return multiple && (!isDir || (isDir && !native) || dialog)
18-
? type === "directory"
19-
? "directories"
20-
: "files"
21-
: nested
22-
? type
23-
: `a ${type}`;
10+
/**
11+
* Generates a human-readable reference string for filesystem object types.
12+
*
13+
* @param {string|Array<string>} type - The filesystem object type(s). Can be "file-path",
14+
* "directory-path", or an array ["file-path", "directory-path"].
15+
* @param {boolean} multiple - Whether multiple objects are expected (affects pluralization).
16+
*
17+
* @returns {string} A formatted reference string like "a file", "directories",
18+
* "a file / directory", etc.
19+
*/
20+
function getObjectTypeReferenceString(type, multiple) {
21+
if (Array.isArray(type)) {
22+
const article = multiple ? "" : "a ";
23+
return `${article}file / directory`;
24+
}
25+
26+
if (multiple) {
27+
return type === "directory-path" ? "directories" : "files";
28+
}
29+
30+
const cleanTypeName = type.replace("-path", "");
31+
return `a ${cleanTypeName}`;
32+
}
33+
34+
/**
35+
* Generates a simple string representation of a filesystem object type.
36+
*
37+
* @param {string|Array<string>} type - The filesystem object type(s).
38+
* @returns {string} A simple string representation of the type(s): "file", "directory", or "file / directory".
39+
*/
40+
function getSimpleObjectTypeString(type) {
41+
if (Array.isArray(type)) {
42+
return "file / directory";
43+
}
44+
return type.replace("-path", "");
2445
}
2546

2647
const componentCSS = css`
@@ -113,7 +134,7 @@ export class FilesystemSelector extends LitElement {
113134

114135
this.accept = props.accept;
115136
this.multiple = props.multiple;
116-
this.type = props.type ?? "file";
137+
this.type = props.type ?? "file-path";
117138
this.value = props.value ?? "";
118139
this.dialogOptions = props.dialogOptions ?? {};
119140
this.onChange = props.onChange ?? (() => {});
@@ -146,7 +167,7 @@ export class FilesystemSelector extends LitElement {
146167
}
147168

148169
options.properties = [
149-
type === "file" ? "openFile" : "openDirectory",
170+
type === "file-path" ? "openFile" : "openDirectory",
150171
"noResolveAliases",
151172
...(options.properties ?? []),
152173
];
@@ -165,8 +186,11 @@ export class FilesystemSelector extends LitElement {
165186
#check = (value) => {
166187
// Check type
167188
const isLikelyFile = fs ? fs.statSync(value).isFile() : value.split(".").length;
168-
if ((this.type === "directory" && isLikelyFile) || (this.type === "file" && !isLikelyFile))
169-
this.#onThrow("Incorrect filesystem object", `Please provide a <b>${this.type}</b> instead.`);
189+
if ((this.type === "directory-path" && isLikelyFile) || (this.type === "file-path" && !isLikelyFile))
190+
this.#onThrow(
191+
"Incorrect filesystem object",
192+
`Please provide a <b>${this.type.replace("-path", "")}</b> instead.`
193+
);
170194
};
171195

172196
#handleFiles = async (pathOrPaths, type) => {
@@ -182,7 +206,7 @@ export class FilesystemSelector extends LitElement {
182206
if (Array.isArray(resolvedValue) && !this.multiple) {
183207
if (resolvedValue.length > 1)
184208
this.#onThrow(
185-
`Too many ${resolvedType === "directory" ? "directories" : "files"} detected`,
209+
`Too many ${resolvedType === "directory-path" ? "directories" : "files"} detected`,
186210
`This selector will only accept one.`
187211
);
188212
resolvedValue = resolvedValue[0];
@@ -205,7 +229,7 @@ export class FilesystemSelector extends LitElement {
205229
this.#handleFiles(results.filePath ?? results.filePaths, type);
206230
} else {
207231
let handles = await (
208-
type === "directory"
232+
type === "directory-path"
209233
? window.showDirectoryPicker()
210234
: window.showOpenFilePicker({ multiple: this.multiple })
211235
).catch(() => []); // Call using the same options
@@ -230,8 +254,6 @@ export class FilesystemSelector extends LitElement {
230254
: this.value[0]
231255
: this.value;
232256

233-
const objectTypeReference = getObjectTypeReferenceString(this.type, this.multiple);
234-
235257
const instanceThis = this;
236258

237259
return html`
@@ -261,20 +283,18 @@ export class FilesystemSelector extends LitElement {
261283
${dialog
262284
? ""
263285
: html`<br /><small
264-
>Cannot get full ${isMultipleTypes ? this.type.join(" / ") : this.type}
286+
>Cannot get full ${getSimpleObjectTypeString(this.type)}
265287
path${this.multiple ? "s" : ""} on web distribution</small
266288
>`}
267289
`
268290
: html`<span
269-
>Drop ${objectTypeReference}
291+
>Drop ${getObjectTypeReferenceString(this.type, this.multiple)}
270292
here${isMultipleTypes
271293
? ""
272-
: `, or click to choose ${getObjectTypeReferenceString(this.type, this.multiple, {
273-
native: true,
274-
})}`}</span
294+
: `, or click to choose ${getObjectTypeReferenceString(this.type, this.multiple)}`}</span
275295
>${this.multiple &&
276-
(this.type === "directory" ||
277-
(isMultipleTypes && this.type.includes("directory") && !dialog))
296+
(this.type === "directory-path" ||
297+
(isMultipleTypes && this.type.includes("directory-path") && !dialog))
278298
? html`<br /><small
279299
>Multiple directory support only available using drag-and-drop.</small
280300
>`
@@ -301,8 +321,7 @@ export class FilesystemSelector extends LitElement {
301321
${this.type.map(
302322
(type) =>
303323
html`<nwb-button primary @click=${() => this.selectFormat(type)}
304-
>Select
305-
${getObjectTypeReferenceString(type, this.multiple, { native: true })}</nwb-button
324+
>Select ${getObjectTypeReferenceString(type, this.multiple)}</nwb-button
306325
>`
307326
)}
308327
</div>`

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ const isFilesystemSelector = (name = "", format) => {
314314
if (Array.isArray(format)) return format.map((f) => isFilesystemSelector(name, f)).every(Boolean) ? format : null;
315315

316316
const matched = name.match(/(.+_)?(.+)_paths?/);
317-
if (!format && matched) format = matched[2] === "folder" ? "directory" : matched[2];
318-
return ["file", "directory"].includes(format) ? format : null; // Handle file and directory formats
317+
if (!format && matched) format = matched[2] === "folder" ? "directory-path" : matched[2];
318+
return ["file-path", "directory-path"].includes(format) ? format : null; // Handle file and directory formats
319319
};
320320

321321
function getFirstFocusableElement(element) {

src/electron/frontend/core/components/pages/guided-mode/data/GuidedPathExpansion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function autocompleteFormatString(path) {
3030
const schema = getSchema(path, this.info.globalState.schema.source_data);
3131

3232
const isFile = "file_path" in schema.properties;
33-
const pathType = isFile ? "file" : "directory";
33+
const pathType = isFile ? "file-path" : "directory-path";
3434

3535
const description = isFile ? schema.properties.file_path.description : schema.properties.folder_path.description;
3636

src/electron/frontend/core/components/pages/guided-mode/data/alignment/TimeAlignment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const options = {
1515
name: "Upload Timestamps",
1616
schema: {
1717
type: "string",
18-
format: "file",
18+
format: "file-path",
1919
description: "A CSV file containing the timestamps of the recording.",
2020
},
2121
},

src/electron/frontend/core/components/pages/guided-mode/setup/Preform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const questions = {
5353

5454
base_directory: {
5555
type: "string",
56-
format: "directory",
56+
format: "directory-path",
5757
title: "Where is your data located?",
5858
description:
5959
"A single directory where all data is contained. Can override for specific data formats.<br><small>Leave blank if unknown</small>",

src/electron/frontend/core/components/pages/inspect/InspectPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class InspectPage extends Page {
132132
type: "array",
133133
items: {
134134
type: "string",
135-
format: ["file", "directory"],
135+
format: ["file-path", "directory-path"],
136136
multiple: true,
137137
},
138138
},

src/electron/frontend/core/components/pages/preview/PreviewPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class PreviewPage extends Page {
3434
path: ["file_path"],
3535
schema: {
3636
type: "string",
37-
format: "file",
37+
format: "file-path",
3838
description:
3939
"Please provide a file path that you'd like to visualize using Neurosift. The GUIDE will serve this file and access the appropriate URL automatically.",
4040
},

src/schemas/json/dandi/standalone.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "array",
88
"items":{
99
"type": "string",
10-
"format": ["file", "directory"]
10+
"format": ["file-path", "directory-path"]
1111
},
1212
"minItems": 1
1313
},

src/schemas/json/developer/globals.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"properties": {
33
"testing_data_folder": {
44
"type": "string",
5-
"format": "directory",
5+
"format": "directory-path",
66
"description": "Common folder where GIN testing data (e.g. ephy_testing_data, ophys_testing_data) can be found"
77
}
88
}

0 commit comments

Comments
 (0)