From 9da7cd4f700a14a608815989411b42c1483a4c25 Mon Sep 17 00:00:00 2001
From: rly
Date: Sat, 11 Nov 2023 23:33:18 -0500
Subject: [PATCH 01/13] Change git clone link, format OS instructions
---
docs/developer_guide.rst | 56 +++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/docs/developer_guide.rst b/docs/developer_guide.rst
index 21fa9cda5..fc5272318 100644
--- a/docs/developer_guide.rst
+++ b/docs/developer_guide.rst
@@ -14,7 +14,7 @@ Start by cloning the repository
.. code-block:: bash
- git clone https://github.com/catalystneuro/nwb-guide
+ git clone https://github.com/NeurodataWithoutBorders/nwb-guide
Install Python Dependencies
@@ -24,27 +24,25 @@ Install Python Dependencies
Install the appropriate Python dependencies for your operating system.
Windows
-"""""""
+
.. code-block:: bash
conda env create -f ./environments/environment-Windows.yml
+Mac with x64 architecture
-Mac
-"""
.. code-block:: bash
conda env create -f ./environments/environment-MAC.yml
+Mac with arm64 architecture
-M1 Mac
-""""""
.. code-block:: bash
conda env create -f ./environments/environment-MAC-arm64.yml
Linux
-"""""
+
.. code-block:: bash
conda env create -f ./environments/environment-Linux.yml
@@ -84,8 +82,8 @@ Repo Structure
- `pages.js` - The main code that controls which pages are rendered and how they are linked together
- `stories` - Contains all the Web Components and related Storybook stories
- `electron` - Contains all the Electron-related code to enable conditional inclusion for development mode
- - `assets` - Contains all the frontend-facing assets (e.g. images, css, etc.)
-2. **pyflask** - Contains all the source code for the backend
+2. **src/renderer/assets** - Contains all the frontend-facing assets (e.g. images, css, etc.)
+3. **pyflask** - Contains all the source code for the backend
@@ -118,7 +116,8 @@ Starting a New Feature
Adding a New Page
^^^^^^^^^^^^^^^^^
-New pages can be added by linking a component in the ``src/pages.js`` file. For example, if you wanted to add a new page called ``NewPage``, you would add the following to the configuration file:
+New pages can be added by linking a component in the ``src/pages.js`` file. For example, if you wanted to
+add a new page called ``NewPage``, you would add the following to the configuration file:
.. code-block:: javascript
@@ -155,7 +154,9 @@ New pages can be added by linking a component in the ``src/pages.js`` file. For
// ...
-This will automatically add the new page to the sidebar. The page itself can be defined in the ``src/stories/pages/NewPage.js`` file. For example, if you wanted to add a new page that displays a simple message, you could add the following to the ``src/stories/pages/NewPage.js`` file:
+This will automatically add the new page to the sidebar. The page itself can be defined in the
+``src/stories/pages/NewPage.js`` file. For example, if you wanted to add a new page that displays
+a simple message, you could add the following to the ``src/stories/pages/NewPage.js`` file:
.. code-block:: javascript
@@ -180,17 +181,23 @@ This will automatically add the new page to the sidebar. The page itself can be
}
}
-Extending the ``Page`` class rather than the ``LitElement`` class provides each page with standard properties and methods that allow for uniform handling across the application.
+Extending the ``Page`` class rather than the ``LitElement`` class provides each page with standard properties and
+methods that allow for uniform handling across the application.
Discover Existing Components
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-While developing NWB GUIDE, you may find that you need to use a component that already exists in the codebase. To find a component, you can manually peruse the ``src/stories`` directory or run the project's Storybook instance to see all of the components in action.
+While developing NWB GUIDE, you may find that you need to use a component that already exists in the codebase. To
+find a component, you can manually peruse the ``src/stories`` directory or run the project's Storybook instance to
+see all of the components in action.
-To run Storybook, simply run ``npm run storybook`` in the root directory of the repository. This will start a local server that you can access using the link provided on the command line.
+To run Storybook, simply run ``npm run storybook`` in the root directory of the repository. This will start a local
+server that you can access using the link provided on the command line.
-To see if someone else has developed a third-party component to fit your needs, you can refer to :web-components:`WebComponents.org <>` and search based on your particular needs. :npm:`NPM` may also be useful to search for third-party packages (e.g. Handsontable) that implement the feature you need.
+To see if someone else has developed a third-party component to fit your needs, you can refer to
+:web-components:`WebComponents.org <>` and search based on your particular needs. :npm:`NPM` may also be
+useful to search for third-party packages (e.g. Handsontable) that implement the feature you need.
@@ -199,25 +206,32 @@ To see if someone else has developed a third-party component to fit your needs,
Testing
-------
-We use Chromatic on the Storybook to test changes to front-end components as well as to demonstrate example cases of what those components would look like on a real project.
+We use Chromatic on the Storybook to test changes to front-end components as well as to demonstrate example cases of
+what those components would look like on a real project.
-We use :pytest:`pytest <>` for testing the back-end manager and REST API. To run the tests, simply run ``pytest`` in the root directory of the repository.
+We use :pytest:`pytest <>` for testing the back-end manager and REST API. To run the tests, simply run ``pytest`` in
+the root directory of the repository.
.. _style:
Coding Style
------------
-For all JavaScript code on the frontend, we use the :prettier-code-formatter:`prettier code formatter <>` with parameters defined in the ``prettier.config.js`` configuration file.
+For all JavaScript code on the frontend, we use the :prettier-code-formatter:`prettier code formatter <>` with
+parameters defined in the ``prettier.config.js`` configuration file.
-For all Python code on the backend, we use the :black-coding-style:`black coding style <>` with parameters defined in the ``pyproject.toml`` configuration file.
+For all Python code on the backend, we use the :black-coding-style:`black coding style <>` with parameters defined
+in the ``pyproject.toml`` configuration file.
Pre-Commit
^^^^^^^^^^
-We use an automated pre-commit bot to enforce these on the main repo, but contributions from external forks would either have to grant bot permissions on their own fork (via :pre-commit-bot:`the pre-commit bot website <>`) or run pre-commit manually.
+We use an automated pre-commit bot to enforce these on the main repo, but contributions from external forks would
+either have to grant bot permissions on their own fork (via :pre-commit-bot:`the pre-commit bot website <>`) or
+run pre-commit manually.
-For instructions to install pre-commit, as well as some other minor coding styles we follow, refer to the :neuroconv-coding-style:`NeuroConv style guide <>`.
+For instructions to install pre-commit, as well as some other minor coding styles we follow, refer to the
+:neuroconv-coding-style:`NeuroConv style guide <>`.
Code signing on Mac OS
----------------------
From 56fc0cdd3324756031938b14d2d8dc98dec20a0b Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Sun, 12 Nov 2023 04:36:20 +0000
Subject: [PATCH 02/13] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
src/renderer/src/stories/JSONSchemaForm.js | 1 -
src/renderer/src/stories/pages/guided-mode/data/utils.js | 1 -
2 files changed, 2 deletions(-)
diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js
index f850f2bc1..beb5e86d1 100644
--- a/src/renderer/src/stories/JSONSchemaForm.js
+++ b/src/renderer/src/stories/JSONSchemaForm.js
@@ -282,7 +282,6 @@ export class JSONSchemaForm extends LitElement {
// Track resolved values for the form (data only)
updateData(localPath, value, forceUpdate = false) {
-
const path = [...localPath];
const name = path.pop();
diff --git a/src/renderer/src/stories/pages/guided-mode/data/utils.js b/src/renderer/src/stories/pages/guided-mode/data/utils.js
index 60b38f93e..4618e17ba 100644
--- a/src/renderer/src/stories/pages/guided-mode/data/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/data/utils.js
@@ -40,7 +40,6 @@ export function resolveProperties(properties = {}, target, globals = {}) {
const props = info.properties;
if (!(name in target)) {
-
if (target.__disabled?.[name]) continue; // Skip disabled properties
if (props) target[name] = {}; // Regisiter new interfaces in results
From 3be660116f5d17fa594c4895e469ff9a6c4916ba Mon Sep 17 00:00:00 2001
From: rly
Date: Sat, 11 Nov 2023 23:39:32 -0500
Subject: [PATCH 03/13] Adjust formatting
---
docs/developer_guide.rst | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/docs/developer_guide.rst b/docs/developer_guide.rst
index fc5272318..fae1468cf 100644
--- a/docs/developer_guide.rst
+++ b/docs/developer_guide.rst
@@ -23,29 +23,29 @@ Install Python Dependencies
Install the appropriate Python dependencies for your operating system.
-Windows
+**Windows**
-.. code-block:: bash
+ .. code-block:: bash
- conda env create -f ./environments/environment-Windows.yml
+ conda env create -f ./environments/environment-Windows.yml
-Mac with x64 architecture
+**Mac with x64 architecture**
-.. code-block:: bash
+ .. code-block:: bash
- conda env create -f ./environments/environment-MAC.yml
+ conda env create -f ./environments/environment-MAC.yml
-Mac with arm64 architecture
+**Mac with arm64 architecture**
-.. code-block:: bash
+ .. code-block:: bash
- conda env create -f ./environments/environment-MAC-arm64.yml
+ conda env create -f ./environments/environment-MAC-arm64.yml
-Linux
+**Linux**
-.. code-block:: bash
+ .. code-block:: bash
- conda env create -f ./environments/environment-Linux.yml
+ conda env create -f ./environments/environment-Linux.yml
Before starting NWB GUIDE, you'll need to ensure that the Python environment is activated.
From 796ea99657ea6cc88109ce31b00b884df8f8731d Mon Sep 17 00:00:00 2001
From: rly
Date: Sat, 11 Nov 2023 23:41:13 -0500
Subject: [PATCH 04/13] Adjust formatting
---
docs/developer_guide.rst | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/developer_guide.rst b/docs/developer_guide.rst
index fae1468cf..ab7b43bc4 100644
--- a/docs/developer_guide.rst
+++ b/docs/developer_guide.rst
@@ -25,27 +25,27 @@ Install the appropriate Python dependencies for your operating system.
**Windows**
- .. code-block:: bash
+.. code-block:: bash
- conda env create -f ./environments/environment-Windows.yml
+ conda env create -f ./environments/environment-Windows.yml
**Mac with x64 architecture**
- .. code-block:: bash
+.. code-block:: bash
- conda env create -f ./environments/environment-MAC.yml
+ conda env create -f ./environments/environment-MAC.yml
**Mac with arm64 architecture**
- .. code-block:: bash
+.. code-block:: bash
- conda env create -f ./environments/environment-MAC-arm64.yml
+ conda env create -f ./environments/environment-MAC-arm64.yml
**Linux**
- .. code-block:: bash
+.. code-block:: bash
- conda env create -f ./environments/environment-Linux.yml
+ conda env create -f ./environments/environment-Linux.yml
Before starting NWB GUIDE, you'll need to ensure that the Python environment is activated.
From 1098da814afd581636f3a2768852bafad8937208 Mon Sep 17 00:00:00 2001
From: Garrett Michael Flynn
Date: Sun, 12 Nov 2023 08:38:55 -0500
Subject: [PATCH 05/13] Add ability to cancel conversion
---
src/renderer/assets/css/global.css | 4 +++
src/renderer/src/stories/pages/Page.js | 25 +++++++++++++++----
.../pages/guided-mode/options/utils.js | 8 +++---
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/renderer/assets/css/global.css b/src/renderer/assets/css/global.css
index 936161b96..3d303d974 100755
--- a/src/renderer/assets/css/global.css
+++ b/src/renderer/assets/css/global.css
@@ -8,6 +8,10 @@
/* src: local('Source Code Pro'), local('SourceCodePro'), url(fonts/SourceCodePro-Regular.ttf) format('truetype'); */
}
+.swal-conversion-actions {
+ margin-top: 0px !important;
+}
+
/* Notfy */
.notyf__toast {
max-width: 40vw !important;
diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js
index ed26fed0b..8256d8da5 100644
--- a/src/renderer/src/stories/pages/Page.js
+++ b/src/renderer/src/stories/pages/Page.js
@@ -150,7 +150,16 @@ export class Page extends LitElement {
const results = {};
- const popup = await openProgressSwal({ title: `Running conversion`, ...options });
+ if (!('showCancelButton' in options)) {
+ options.showCancelButton = true;
+ options.customClass = { actions: 'swal-conversion-actions' }
+ }
+
+ const cancelController = new AbortController()
+
+ const popup = await openProgressSwal({ title: `Running conversion`, ...options }, (result) => {
+ if (!result.isConfirmed) cancelController.abort()
+ });
const isMultiple = toRun.length > 1;
@@ -165,9 +174,8 @@ export class Page extends LitElement {
element.append(progressBar);
element.insertAdjacentHTML(
"beforeend",
- `Note: This may take a while to complete...`
+ `Note: This may take a while to complete...
`
);
- // }
let completed = 0;
elements.progress.value = { b: completed, tsize: toRun.length };
@@ -195,9 +203,16 @@ export class Page extends LitElement {
interfaces: globalState.interfaces,
},
- { swal: popup, ...options }
+ { swal: popup, fetch: { signal: cancelController.signal }, ...options }
).catch((e) => {
- this.notify(e.message, "error");
+ let message = e.message
+
+ if (message.includes('The user aborted a request.')) {
+ this.notify("Conversion was cancelled.", "warning");
+ throw e
+ }
+
+ this.notify(message, "error");
popup.close();
throw e;
});
diff --git a/src/renderer/src/stories/pages/guided-mode/options/utils.js b/src/renderer/src/stories/pages/guided-mode/options/utils.js
index 3eb939744..8a7230a86 100644
--- a/src/renderer/src/stories/pages/guided-mode/options/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/options/utils.js
@@ -2,10 +2,10 @@ import Swal from "sweetalert2";
import { baseUrl } from "../../../../globals.js";
import { sanitize } from "../../utils.js";
-export const openProgressSwal = (options) => {
+export const openProgressSwal = (options, callback) => {
return new Promise((resolve) => {
Swal.fire({
- title: options.title ?? "Requesting data from server",
+ title: "Requesting data from server",
html: `Please wait...`,
allowEscapeKey: false,
allowOutsideClick: false,
@@ -17,7 +17,8 @@ export const openProgressSwal = (options) => {
Swal.showLoading();
resolve(Swal);
},
- });
+ ...options
+ }).then(result => callback?.(result));
});
};
@@ -34,6 +35,7 @@ export const run = async (url, payload, options = {}) => {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
+ ...(options.fetch ?? {})
}).then((res) => res.json());
if (needsSwal) Swal.close();
From 578dab571b98d931f93cebad4cacf8e74660bf1f Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Sun, 12 Nov 2023 13:39:46 +0000
Subject: [PATCH 06/13] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
src/renderer/src/stories/JSONSchemaForm.js | 1 -
src/renderer/src/stories/pages/Page.js | 14 +++++++-------
.../src/stories/pages/guided-mode/data/utils.js | 1 -
.../src/stories/pages/guided-mode/options/utils.js | 6 +++---
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js
index f850f2bc1..beb5e86d1 100644
--- a/src/renderer/src/stories/JSONSchemaForm.js
+++ b/src/renderer/src/stories/JSONSchemaForm.js
@@ -282,7 +282,6 @@ export class JSONSchemaForm extends LitElement {
// Track resolved values for the form (data only)
updateData(localPath, value, forceUpdate = false) {
-
const path = [...localPath];
const name = path.pop();
diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js
index 8256d8da5..45c987524 100644
--- a/src/renderer/src/stories/pages/Page.js
+++ b/src/renderer/src/stories/pages/Page.js
@@ -150,15 +150,15 @@ export class Page extends LitElement {
const results = {};
- if (!('showCancelButton' in options)) {
+ if (!("showCancelButton" in options)) {
options.showCancelButton = true;
- options.customClass = { actions: 'swal-conversion-actions' }
+ options.customClass = { actions: "swal-conversion-actions" };
}
- const cancelController = new AbortController()
+ const cancelController = new AbortController();
const popup = await openProgressSwal({ title: `Running conversion`, ...options }, (result) => {
- if (!result.isConfirmed) cancelController.abort()
+ if (!result.isConfirmed) cancelController.abort();
});
const isMultiple = toRun.length > 1;
@@ -205,11 +205,11 @@ export class Page extends LitElement {
},
{ swal: popup, fetch: { signal: cancelController.signal }, ...options }
).catch((e) => {
- let message = e.message
+ let message = e.message;
- if (message.includes('The user aborted a request.')) {
+ if (message.includes("The user aborted a request.")) {
this.notify("Conversion was cancelled.", "warning");
- throw e
+ throw e;
}
this.notify(message, "error");
diff --git a/src/renderer/src/stories/pages/guided-mode/data/utils.js b/src/renderer/src/stories/pages/guided-mode/data/utils.js
index 60b38f93e..4618e17ba 100644
--- a/src/renderer/src/stories/pages/guided-mode/data/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/data/utils.js
@@ -40,7 +40,6 @@ export function resolveProperties(properties = {}, target, globals = {}) {
const props = info.properties;
if (!(name in target)) {
-
if (target.__disabled?.[name]) continue; // Skip disabled properties
if (props) target[name] = {}; // Regisiter new interfaces in results
diff --git a/src/renderer/src/stories/pages/guided-mode/options/utils.js b/src/renderer/src/stories/pages/guided-mode/options/utils.js
index 8a7230a86..d8c4bf818 100644
--- a/src/renderer/src/stories/pages/guided-mode/options/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/options/utils.js
@@ -17,8 +17,8 @@ export const openProgressSwal = (options, callback) => {
Swal.showLoading();
resolve(Swal);
},
- ...options
- }).then(result => callback?.(result));
+ ...options,
+ }).then((result) => callback?.(result));
});
};
@@ -35,7 +35,7 @@ export const run = async (url, payload, options = {}) => {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
- ...(options.fetch ?? {})
+ ...(options.fetch ?? {}),
}).then((res) => res.json());
if (needsSwal) Swal.close();
From 3e698e8e6de0c0c69d89850581ba73a0e8ed98b2 Mon Sep 17 00:00:00 2001
From: Garrett Michael Flynn
Date: Sun, 12 Nov 2023 09:11:30 -0500
Subject: [PATCH 07/13] Ensure space between input and errors. Always trigger
change and block at the validation level
---
src/renderer/src/stories/JSONSchemaInput.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js
index 4ad9a8742..b77595e24 100644
--- a/src/renderer/src/stories/JSONSchemaInput.js
+++ b/src/renderer/src/stories/JSONSchemaInput.js
@@ -166,7 +166,7 @@ export class JSONSchemaInput extends LitElement {
updated() {
const el = this.getElement();
if (el) {
- if (this.validateEmptyValue || (el.value ?? el.checked) !== "") el.dispatchEvent(new Event("change"));
+ el.dispatchEvent(new Event("change"));
}
}
@@ -174,13 +174,14 @@ export class JSONSchemaInput extends LitElement {
const { info } = this;
const input = this.#render();
+
return html`
${input}
+
${info.description
- ? html`
- ${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "." ? "" : "."}
-
`
+ ? html`${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "." ? "" : "."}`
: ""}
+
`;
}
From 5341820ac49e68b1b89a2589e12d618c16068971 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Sun, 12 Nov 2023 15:06:42 +0000
Subject: [PATCH 08/13] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
src/renderer/src/stories/JSONSchemaInput.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js
index b77595e24..b48f91b48 100644
--- a/src/renderer/src/stories/JSONSchemaInput.js
+++ b/src/renderer/src/stories/JSONSchemaInput.js
@@ -178,9 +178,11 @@ export class JSONSchemaInput extends LitElement {
return html`
${input}
- ${info.description
- ? html`${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "." ? "" : "."}`
- : ""}
+ ${info.description
+ ? html`${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "."
+ ? ""
+ : "."}`
+ : ""}
`;
}
From 0a9970e6822b46a657a9ba7fa1366ec2d5100b7a Mon Sep 17 00:00:00 2001
From: Garrett Michael Flynn
Date: Sun, 12 Nov 2023 11:04:11 -0500
Subject: [PATCH 09/13] Fix list editing
---
src/renderer/src/stories/List.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/renderer/src/stories/List.ts b/src/renderer/src/stories/List.ts
index 1a77e666c..bb7521baa 100644
--- a/src/renderer/src/stories/List.ts
+++ b/src/renderer/src/stories/List.ts
@@ -266,7 +266,8 @@ export class List extends LitElement {
}
if (typeof content === 'string') {
- const valueEl = editableElement = document.createElement("span");
+ const valueEl = document.createElement("span");
+ if (!key) editableElement = valueEl
valueEl.innerText = content;
div.appendChild(valueEl);
}
From ffd4a9b414e98b3c5028d282fbc6a795d47b9681 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Mon, 13 Nov 2023 17:54:57 +0000
Subject: [PATCH 10/13] [pre-commit.ci] pre-commit autoupdate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
updates:
- [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0)
- [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0)
---
.pre-commit-config.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 64f8e6e4c..d7749ada0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -6,12 +6,12 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
- rev: 23.10.1
+ rev: 23.11.0
hooks:
- id: black
exclude: ^docs/
- repo: https://github.com/pre-commit/mirrors-prettier
- rev: "v3.0.3"
+ rev: "v3.1.0"
hooks:
- id: prettier
types_or: [css, javascript]
From b14301331305d0a63ba54bccffbaceeec025d01d Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Mon, 13 Nov 2023 17:55:13 +0000
Subject: [PATCH 11/13] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
src/renderer/src/stories/FileSystemSelector.js | 4 ++--
src/renderer/src/stories/JSONSchemaForm.js | 5 ++---
src/renderer/src/stories/JSONSchemaInput.js | 12 +++++++-----
.../src/stories/pages/guided-mode/data/utils.js | 1 -
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/renderer/src/stories/FileSystemSelector.js b/src/renderer/src/stories/FileSystemSelector.js
index 8eab4c6e1..1f6caac21 100644
--- a/src/renderer/src/stories/FileSystemSelector.js
+++ b/src/renderer/src/stories/FileSystemSelector.js
@@ -15,8 +15,8 @@ function getObjectTypeReferenceString(type, multiple, { nested, native } = {}) {
? "directories"
: "files"
: nested
- ? type
- : `a ${type}`;
+ ? type
+ : `a ${type}`;
}
const componentCSS = css`
diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js
index f850f2bc1..259f0644f 100644
--- a/src/renderer/src/stories/JSONSchemaForm.js
+++ b/src/renderer/src/stories/JSONSchemaForm.js
@@ -282,7 +282,6 @@ export class JSONSchemaForm extends LitElement {
// Track resolved values for the form (data only)
updateData(localPath, value, forceUpdate = false) {
-
const path = [...localPath];
const name = path.pop();
@@ -377,8 +376,8 @@ export class JSONSchemaForm extends LitElement {
let message = isValid
? ""
: requiredButNotSpecified.length === 1
- ? `${requiredButNotSpecified[0]} is not defined`
- : `${requiredButNotSpecified.length} required inputs are not specified properly`;
+ ? `${requiredButNotSpecified[0]} is not defined`
+ : `${requiredButNotSpecified.length} required inputs are not specified properly`;
if (requiredButNotSpecified.length !== nMissingRequired)
console.warn("Disagreement about the correct error to throw...");
diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js
index b77595e24..97ea5729e 100644
--- a/src/renderer/src/stories/JSONSchemaInput.js
+++ b/src/renderer/src/stories/JSONSchemaInput.js
@@ -178,9 +178,11 @@ export class JSONSchemaInput extends LitElement {
return html`
${input}
- ${info.description
- ? html`${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "." ? "" : "."}`
- : ""}
+ ${info.description
+ ? html`${unsafeHTML(capitalize(info.description))}${info.description.slice(-1)[0] === "."
+ ? ""
+ : "."}`
+ : ""}
`;
}
@@ -237,8 +239,8 @@ export class JSONSchemaInput extends LitElement {
(this.onValidate
? this.onValidate()
: this.form
- ? this.form.validateOnChange(key, parent, [...this.form.base, ...fullPath], v)
- : "")
+ ? this.form.validateOnChange(key, parent, [...this.form.base, ...fullPath], v)
+ : "")
);
},
diff --git a/src/renderer/src/stories/pages/guided-mode/data/utils.js b/src/renderer/src/stories/pages/guided-mode/data/utils.js
index 60b38f93e..4618e17ba 100644
--- a/src/renderer/src/stories/pages/guided-mode/data/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/data/utils.js
@@ -40,7 +40,6 @@ export function resolveProperties(properties = {}, target, globals = {}) {
const props = info.properties;
if (!(name in target)) {
-
if (target.__disabled?.[name]) continue; // Skip disabled properties
if (props) target[name] = {}; // Regisiter new interfaces in results
From 1e33cfd8513f44cab598726db4f957e49858b69b Mon Sep 17 00:00:00 2001
From: Garrett Michael Flynn
Date: Tue, 14 Nov 2023 08:41:23 -0500
Subject: [PATCH 12/13] Fix Table.js to not delete global properties not
defined at the subject level
---
src/renderer/src/stories/Table.js | 96 +++++++++++++++----------------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/src/renderer/src/stories/Table.js b/src/renderer/src/stories/Table.js
index e88abb036..3037eba08 100644
--- a/src/renderer/src/stories/Table.js
+++ b/src/renderer/src/stories/Table.js
@@ -406,8 +406,6 @@ export class Table extends LitElement {
if (this.table) this.table.destroy();
- console.log("Rendered data", this.#getRenderedData(data));
-
const table = new Handsontable(div, {
data: this.#getRenderedData(data),
// rowHeaders: rowHeaders.map(v => `sub-${v}`),
@@ -434,65 +432,67 @@ export class Table extends LitElement {
const initialCellsToUpdate = data.reduce((acc, v) => acc + v.length, 0);
table.addHook("afterValidate", (isValid, value, row, prop) => {
- const header = typeof prop === "number" ? colHeaders[prop] : prop;
- let rowName = this.keyColumn ? rowHeaders[row] : row;
-
- // NOTE: We would like to allow invalid values to mutate the results
- // if (isValid) {
- const isResolved = rowName in this.data;
- let target = this.data;
-
- if (!isResolved) {
- if (!this.keyColumn) this.data[rowName] = {}; // Add new row to array
- else {
- rowName = row;
- if (!unresolved[rowName]) unresolved[rowName] = {}; // Ensure row exists
- target = unresolved;
- }
- }
const isUserUpdate = initialCellsToUpdate <= validated;
-
- value = this.#getValue(value, entries[header]);
-
- // Transfer data to object (if valid)
- if (header === this.keyColumn) {
- if (isValid && value && value !== rowName) {
- const old = target[rowName] ?? {};
- this.data[value] = old;
- delete target[rowName];
- delete unresolved[row];
- rowHeaders[row] = value;
+
+ if (isUserUpdate) {
+ const header = typeof prop === "number" ? colHeaders[prop] : prop;
+ let rowName = this.keyColumn ? rowHeaders[row] : row;
+
+ // NOTE: We would like to allow invalid values to mutate the results
+ // if (isValid) {
+ const isResolved = rowName in this.data;
+ let target = this.data;
+
+ if (!isResolved) {
+ if (!this.keyColumn) this.data[rowName] = {}; // Add new row to array
+ else {
+ rowName = row;
+ if (!unresolved[rowName]) unresolved[rowName] = {}; // Ensure row exists
+ target = unresolved;
+ }
}
- }
- // Update data on passed object
- else {
- const globalValue = this.globals[header];
+ value = this.#getValue(value, entries[header]);
- if (value == undefined || value === "") {
- if (globalValue) {
- value = target[rowName][header] = globalValue;
- table.setDataAtCell(row, prop, value);
- this.onOverride(header, value, rowName);
- }
- target[rowName][header] = undefined;
- } else {
- // Correct for expected arrays (copy-paste issue)
- if (entries[header]?.type === "array") {
- if (value && !Array.isArray(value)) value = value.split(",").map((v) => v.trim());
+ // Transfer data to object (if valid)
+ if (header === this.keyColumn) {
+ if (isValid && value && value !== rowName) {
+ const old = target[rowName] ?? {};
+ this.data[value] = old;
+ delete target[rowName];
+ delete unresolved[row];
+ rowHeaders[row] = value;
}
+ }
- target[rowName][header] = value === globalValue ? undefined : value;
+ // Update data on passed object
+ else {
+ const globalValue = this.globals[header];
+
+ if (value == undefined || value === "") {
+ if (globalValue) {
+ value = target[rowName][header] = globalValue;
+ table.setDataAtCell(row, prop, value);
+ this.onOverride(header, value, rowName);
+ }
+ target[rowName][header] = undefined;
+ } else {
+ // Correct for expected arrays (copy-paste issue)
+ if (entries[header]?.type === "array") {
+ if (value && !Array.isArray(value)) value = value.split(",").map((v) => v.trim());
+ }
+
+ target[rowName][header] = value === globalValue ? undefined : value;
+ }
}
+
+ this.onUpdate(rowName, header, value);
}
validated++;
- if (isUserUpdate) this.onUpdate(rowName, header, value);
-
if (typeof isValid === "function") isValid();
- // }
});
// If only one row, do not allow deletion
From 0e4a595bf5e84d1bfd817355130b2b9f40afcdef Mon Sep 17 00:00:00 2001
From: Garrett Michael Flynn
Date: Wed, 15 Nov 2023 08:53:57 -0500
Subject: [PATCH 13/13] Cancel DANDI upload
---
.../pages/guided-mode/options/utils.js | 51 +++++++++++++++++--
.../src/stories/pages/uploads/UploadsPage.js | 4 +-
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/src/renderer/src/stories/pages/guided-mode/options/utils.js b/src/renderer/src/stories/pages/guided-mode/options/utils.js
index d8c4bf818..7057f83e0 100644
--- a/src/renderer/src/stories/pages/guided-mode/options/utils.js
+++ b/src/renderer/src/stories/pages/guided-mode/options/utils.js
@@ -1,12 +1,12 @@
import Swal from "sweetalert2";
import { baseUrl } from "../../../../globals.js";
import { sanitize } from "../../utils.js";
+import { Loader } from "../../../Loader";
export const openProgressSwal = (options, callback) => {
return new Promise((resolve) => {
Swal.fire({
title: "Requesting data from server",
- html: `Please wait...`,
allowEscapeKey: false,
allowOutsideClick: false,
showConfirmButton: false,
@@ -24,7 +24,50 @@ export const openProgressSwal = (options, callback) => {
export const run = async (url, payload, options = {}) => {
const needsSwal = !options.swal && options.swal !== false;
- if (needsSwal) openProgressSwal(options).then((swal) => (options.onOpen ? options.onOpen(swal) : undefined));
+
+ if (needsSwal) {
+
+ if (!("showCancelButton" in options)) {
+ options.showCancelButton = true;
+ options.customClass = { actions: "swal-conversion-actions" };
+ }
+
+ const cancelController = new AbortController();
+
+ options.fetch = {
+ signal: cancelController.signal,
+ }
+
+ const popup = await openProgressSwal(options, (result) => {
+ if (!result.isConfirmed) cancelController.abort();
+ }).then(async (swal) => {
+ if (options.onOpen) await options.onOpen(swal)
+ return swal
+ });
+
+ const element = popup.getHtmlContainer();
+ const actions = popup.getActions()
+ const loader = actions.querySelector(".swal2-loader")
+ const container = document.createElement("div");
+ container.append(loader)
+ element.innerText = "";
+ Object.assign(container.style, {
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ justifyContent: 'center',
+ marginBottom: '25px'
+ })
+
+ element.appendChild(container);
+
+ element.insertAdjacentHTML(
+ "beforeend",
+ `
`
+ );
+
+
+ }
if (!("base" in options)) options.base = "/neuroconv";
@@ -36,8 +79,8 @@ export const run = async (url, payload, options = {}) => {
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
...(options.fetch ?? {}),
- }).then((res) => res.json());
-
+ }).then((res) => res.json())
+
if (needsSwal) Swal.close();
if (results?.message) throw new Error(`Request to ${url} failed: ${results.message}`);
diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js
index 9aadcf8ea..a1b3adc5b 100644
--- a/src/renderer/src/stories/pages/uploads/UploadsPage.js
+++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js
@@ -120,8 +120,6 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
document.body.append(modal);
});
-
- console.log(api_key);
}
const result = await run(
@@ -131,7 +129,7 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
staging,
api_key,
},
- { title: "Uploading to DANDI" }
+ { title: "Uploading your files to DANDI" }
).catch((e) => {
this.notify(e.message, "error");
throw e;