From 364ab625f8fb097b51d80e9c5bc3b69495acc1ea Mon Sep 17 00:00:00 2001 From: Emily Soth Date: Tue, 21 Jan 2025 14:12:42 -0800 Subject: [PATCH] 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}