From 364ab625f8fb097b51d80e9c5bc3b69495acc1ea Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Tue, 21 Jan 2025 14:12:42 -0800 Subject: [PATCH 01/10] update plugin modal form to support branch or ref, and local path --- .../renderer/components/PluginModal/index.jsx | 93 ++++++++++++++++--- 1 file changed, 79 insertions(+), 14 deletions(-) diff --git a/workbench/src/renderer/components/PluginModal/index.jsx b/workbench/src/renderer/components/PluginModal/index.jsx index d9b26a79d..87203a0f7 100644 --- a/workbench/src/renderer/components/PluginModal/index.jsx +++ b/workbench/src/renderer/components/PluginModal/index.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import Button from 'react-bootstrap/Button'; +import Col from 'react-bootstrap/Col'; import Form from 'react-bootstrap/Form'; import Modal from 'react-bootstrap/Modal'; import Spinner from 'react-bootstrap/Spinner'; @@ -15,20 +16,30 @@ export default function PluginModal(props) { const { updateInvestList } = props; const [showPluginModal, setShowPluginModal] = useState(false); const [url, setURL] = useState(undefined); + const [branch, setBranch] = useState(undefined); + const [path, setPath] = useState(undefined); const [err, setErr] = useState(undefined); const [pluginToRemove, setPluginToRemove] = useState(undefined); const [loading, setLoading] = useState(false); const [plugins, setPlugins] = useState({}); + const [installFrom, setInstallFrom] = useState('Git URL'); const handleModalClose = () => { setURL(undefined); + setBranch(undefined); setErr(false); setShowPluginModal(false); }; const handleModalOpen = () => setShowPluginModal(true); + const addPlugin = () => { setLoading(true); - ipcRenderer.invoke(ipcMainChannels.ADD_PLUGIN, url).then((addPluginErr) => { + ipcRenderer.invoke(ipcMainChannels.ADD_PLUGIN, { + installFrom: installFrom, + url: url, + branch: branch, + path: path, + }).then((addPluginErr) => { setLoading(false); updateInvestList(); if (addPluginErr) { @@ -61,20 +72,71 @@ export default function PluginModal(props) { const { t } = useTranslation(); + let pluginFields; + if (installFrom === 'Git URL') { + pluginFields = ( + <> + + + Git URL + setURL(event.currentTarget.value)} + /> + + + Branch or ref + setBranch(event.currentTarget.value)} + /> + + + + {t('Default branch is used unless a branch or ref is specified')} + + + ); + } else { + pluginFields = ( + + Local path + setPath(event.currentTarget.value)} + /> + + {t('Must be an absolute path')} + + + ); + } + let modalBody = (
- {t('Add a plugin')} - setURL(event.currentTarget.value)} - /> - - {t('This may take several minutes')} - + {t('Add a plugin')} + + + + setInstallFrom(event.target.value)} + className="w-auto" + > + + + + + + + {pluginFields} + + {t('This may take several minutes')} +
@@ -192,16 +195,15 @@ export default function PluginModal(props) { {t('Manage plugins')} - + {t('Manage plugins')} {loading && ( - - {t('Loading...')} - - {t('This may take several minutes')} - - + + + {t('Loading...')} + + )} {modalBody} From 26301f4bcc4504ad4eb657f06e16acb8d0548032 Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Wed, 22 Jan 2025 16:01:07 -0800 Subject: [PATCH 04/10] add platform-dependent placeholder text for local plugin path --- workbench/src/preload/api.js | 1 + .../src/renderer/components/PluginModal/index.jsx | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/workbench/src/preload/api.js b/workbench/src/preload/api.js index 82ef57a6b..740875876 100644 --- a/workbench/src/preload/api.js +++ b/workbench/src/preload/api.js @@ -32,6 +32,7 @@ export default { ELECTRON_LOG_PATH: electronLogPath, USERGUIDE_PATH: userguidePath, LANGUAGE: ipcRenderer.sendSync(ipcMainChannels.GET_LANGUAGE), + OS: process.platform, logger: { debug: (message) => ipcRenderer.send(ipcMainChannels.LOGGER, 'debug', message), info: (message) => ipcRenderer.send(ipcMainChannels.LOGGER, 'info', message), diff --git a/workbench/src/renderer/components/PluginModal/index.jsx b/workbench/src/renderer/components/PluginModal/index.jsx index ada3f3c44..413408dc6 100644 --- a/workbench/src/renderer/components/PluginModal/index.jsx +++ b/workbench/src/renderer/components/PluginModal/index.jsx @@ -82,7 +82,7 @@ export default function PluginModal(props) { setURL(event.currentTarget.value)} /> @@ -104,15 +104,15 @@ export default function PluginModal(props) { } else { pluginFields = ( - Local path + Local absolute path setPath(event.currentTarget.value)} /> - - {t('Must be an absolute path')} - ); } @@ -130,7 +130,7 @@ export default function PluginModal(props) { onChange={(event) => setInstallFrom(event.target.value)} className="w-auto" > - + From 8f9c9679628c03596bb9d2bfd0d39e15cac474be Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Fri, 24 Jan 2025 10:03:22 -0800 Subject: [PATCH 05/10] improve placeholder and label text in plugin modal form --- .../renderer/components/PluginModal/index.jsx | 58 +++++++++---------- workbench/src/renderer/styles/style.css | 5 ++ 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/workbench/src/renderer/components/PluginModal/index.jsx b/workbench/src/renderer/components/PluginModal/index.jsx index 413408dc6..99087e545 100644 --- a/workbench/src/renderer/components/PluginModal/index.jsx +++ b/workbench/src/renderer/components/PluginModal/index.jsx @@ -75,31 +75,31 @@ export default function PluginModal(props) { let pluginFields; if (installFrom === 'url') { pluginFields = ( - <> - - - Git URL - setURL(event.currentTarget.value)} - /> - - - Branch, tag, or commit - setRevision(event.currentTarget.value)} - /> - - - - {t('Default branch is used unless otherwise specified')} - - + + + Git URL + setURL(event.currentTarget.value)} + /> + + {t('Default branch used unless otherwise specified')} + + + + Branch, tag, or commit + setRevision(event.currentTarget.value)} + /> + + {t('Optional')} + + + ); } else { pluginFields = ( @@ -108,9 +108,9 @@ export default function PluginModal(props) { setPath(event.currentTarget.value)} /> @@ -195,7 +195,7 @@ export default function PluginModal(props) { {t('Manage plugins')} - + {t('Manage plugins')} {loading && ( diff --git a/workbench/src/renderer/styles/style.css b/workbench/src/renderer/styles/style.css index 138013b8b..f2c720b7e 100644 --- a/workbench/src/renderer/styles/style.css +++ b/workbench/src/renderer/styles/style.css @@ -637,3 +637,8 @@ input[type=text]::placeholder { background-size: 1rem 1rem; } } + +/* Manage Plugins modal */ +.plugin-modal { + width: 34rem; +} From 665d51115755284ae1e328e4971d01a8bf26274c Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Fri, 24 Jan 2025 10:35:07 -0800 Subject: [PATCH 06/10] fix labels and htmlFors in plugin modal form --- .../renderer/components/PluginModal/index.jsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/workbench/src/renderer/components/PluginModal/index.jsx b/workbench/src/renderer/components/PluginModal/index.jsx index 99087e545..6726122aa 100644 --- a/workbench/src/renderer/components/PluginModal/index.jsx +++ b/workbench/src/renderer/components/PluginModal/index.jsx @@ -77,7 +77,7 @@ export default function PluginModal(props) { pluginFields = ( - Git URL + Git URL - Branch, tag, or commit + Branch, tag, or commit - Local absolute path + Local absolute path - {t('Add a plugin')} +
{t('Add a plugin')}
- - setInstallFrom(event.target.value)} - className="w-auto" - > - - - - + {t('Install from')} + setInstallFrom(event.target.value)} + className="w-auto" + > + + + {pluginFields} @@ -150,7 +150,7 @@ export default function PluginModal(props) {

- {t('Remove a plugin')} +
{t('Remove a plugin')}
Date: Fri, 24 Jan 2025 10:36:15 -0800 Subject: [PATCH 07/10] update comment --- workbench/src/main/setupAddRemovePlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workbench/src/main/setupAddRemovePlugin.js b/workbench/src/main/setupAddRemovePlugin.js index a81c86553..529f0f51a 100644 --- a/workbench/src/main/setupAddRemovePlugin.js +++ b/workbench/src/main/setupAddRemovePlugin.js @@ -91,7 +91,7 @@ export function setupAddPlugin() { } else { // install from local path logger.info(`adding plugin from ${path}`); installString = path; - // Read in the plugin's pyproject.toml, then delete it + // Read in the plugin's pyproject.toml pyprojectTOML = toml.parse(fs.readFileSync( upath.join(path, 'pyproject.toml') ).toString()); From 4be6f50ba1088a40b4436b74539d2cb74ffbcffb Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Fri, 24 Jan 2025 14:41:25 -0800 Subject: [PATCH 08/10] stack plugin 'install from' label over dropdown; remove some unneeded styling --- .../renderer/components/PluginModal/index.jsx | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/workbench/src/renderer/components/PluginModal/index.jsx b/workbench/src/renderer/components/PluginModal/index.jsx index 6726122aa..01b19fca9 100644 --- a/workbench/src/renderer/components/PluginModal/index.jsx +++ b/workbench/src/renderer/components/PluginModal/index.jsx @@ -76,26 +76,26 @@ export default function PluginModal(props) { if (installFrom === 'url') { pluginFields = ( - - Git URL + + {t('Git URL')} setURL(event.currentTarget.value)} /> - + {t('Default branch used unless otherwise specified')} - - Branch, tag, or commit + + {t('Branch, tag, or commit')} setRevision(event.currentTarget.value)} /> - + {t('Optional')} @@ -103,8 +103,8 @@ export default function PluginModal(props) { ); } else { pluginFields = ( - - Local absolute path + + {t('Local absolute path')} - +
{t('Add a plugin')}
- - {t('Install from')} - setInstallFrom(event.target.value)} - className="w-auto" - > - - - - + {t('Install from')} + setInstallFrom(event.target.value)} + className="w-auto" + > + + + {pluginFields}