diff --git a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx index 74dd2d827..595239ead 100644 --- a/web/screens/Settings/CorePlugins/PluginsCatalog.tsx +++ b/web/screens/Settings/CorePlugins/PluginsCatalog.tsx @@ -19,6 +19,7 @@ const PluginCatalog = () => { const [pluginCatalog, setPluginCatalog] = useState([]) const [isLoading, setIsLoading] = useState(false) const experimentRef = useRef(null) + const fileInputRef = useRef(null) /** * Loads the plugin catalog module from a CDN and sets it as the plugin catalog state. @@ -63,8 +64,7 @@ const PluginCatalog = () => { */ const install = async (e: any) => { e.preventDefault() - //@ts-ignore - const pluginFile = new FormData(e.target).get('plugin-file').path + const pluginFile = e.target.files?.[0].path // Send the filename of the to be installed plugin // to the main process for installation @@ -116,65 +116,97 @@ const PluginCatalog = () => { * Its to be used to display the plugin file name of the selected file. * @param event - The change event object. */ - // const handleFileChange = (event: React.ChangeEvent) => { - // const file = event.target.files?.[0] - // if (file) { - // setFileName(file.name) - // } else { - // setFileName('') - // } - // } + const handleFileChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0] + if (file) { + install(event) + } + } return (
- {pluginCatalog?.map((item, i) => { - const isActivePlugin = activePlugins.some((x) => x.name === item.name) - const updateVersionPlugins = Number( - activePlugins - .filter((p) => p.name === item.name)[0] - ?.version.replaceAll('.', '') + {(pluginCatalog ?? []) + .concat( + activePlugins?.filter( + (e) => !(pluginCatalog ?? []).some((p) => p.name === e.name) + ) ?? [] ) - return ( -
-
-
-
- {formatPluginsName(item.name)} -
-

- v{item.version} + .map((item, i) => { + const isActivePlugin = activePlugins.some((x) => x.name === item.name) + const updateVersionPlugins = Number( + activePlugins + .filter((p) => p.name === item.name)[0] + ?.version.replaceAll('.', '') + ) + return ( +

+
+
+
+ {formatPluginsName(item.name)} +
+

+ v{item.version} +

+
+

+ {item.description}

+ {isActivePlugin && + item.version.replaceAll('.', '') < updateVersionPlugins && ( + + )}
-

- {item.description} -

- {isActivePlugin && - item.version.replaceAll('.', '') < updateVersionPlugins && ( - - )} + { + if (e === true) { + downloadTarball(item.name) + } else { + uninstall(item.name) + } + }} + />
- { - if (e === true) { - downloadTarball(item.name) - } else { - uninstall(item.name) - } - }} - /> + ) + })} + {/* Manual Installation */} +
+
+
+
+ Manual Installation +
- ) - })} +

+ Select a plugin file to install (.tgz) +

+
+
+ + +
+
{isLoading && (
diff --git a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx index 713ecc01b..841acc38a 100644 --- a/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx +++ b/web/screens/Settings/CorePlugins/PreferencePlugins/index.tsx @@ -39,12 +39,12 @@ const PreferencePlugins = (props: Props) => { Setting: {e.preferenceName}
- + {e.preferenceDescription}
v.key === e.preferenceKey