Add update all button to plugin list (#466)

This commit is contained in:
Jonas Dellinger
2023-05-29 18:29:36 +02:00
committed by GitHub
parent 5114bb5711
commit 010feddf36
7 changed files with 215 additions and 19 deletions
+20 -8
View File
@@ -49,7 +49,7 @@ class PluginBrowser:
logger.error(f"chown/chmod exited with a non-zero exit code")
return False
return True
async def _download_remote_binaries_for_plugin_with_name(self, pluginBasePath):
rv = False
try:
@@ -63,10 +63,8 @@ class PluginBrowser:
# create bin directory if needed.
chmod(pluginBasePath, 777)
if access(pluginBasePath, W_OK):
if not path.exists(pluginBinPath):
mkdir(pluginBinPath)
if not access(pluginBinPath, W_OK):
chmod(pluginBinPath, 777)
@@ -85,7 +83,7 @@ class PluginBrowser:
else:
rv = True
logger.debug(f"No Remote Binaries to Download")
except Exception as e:
rv = False
logger.debug(str(e))
@@ -174,7 +172,7 @@ class PluginBrowser:
if res_zip is None:
logger.fatal(f"Could not fetch {artifact}")
return
# If plugin is installed, uninstall it
if isInstalled:
try:
@@ -196,7 +194,7 @@ class PluginBrowser:
self.loader.plugins[name].stop()
self.loader.plugins.pop(name, None)
await sleep(1)
current_plugin_order = self.settings.getSetting("pluginOrder")
current_plugin_order.append(name)
self.settings.setSetting("pluginOrder", current_plugin_order)
@@ -216,9 +214,23 @@ class PluginBrowser:
await tab.open_websocket()
await tab.evaluate_js(f"DeckyPluginLoader.addPluginInstallPrompt('{name}', '{version}', '{request_id}', '{hash}', {install_type})")
async def request_multiple_plugin_installs(self, requests):
request_id = str(time())
self.install_requests[request_id] = [PluginInstallContext(req['artifact'], req['name'], req['version'], req['hash']) for req in requests]
js_requests_parameter = ','.join([
f"{{ name: '{req['name']}', version: '{req['version']}', hash: '{req['hash']}', install_type: {req['install_type']}}}" for req in requests
])
tab = await get_gamepadui_tab()
await tab.open_websocket()
await tab.evaluate_js(f"DeckyPluginLoader.addMultiplePluginsInstallPrompt('{request_id}', [{js_requests_parameter}])")
async def confirm_plugin_install(self, request_id):
request = self.install_requests.pop(request_id)
await self._install(request.artifact, request.name, request.version, request.hash)
requestOrRequests = self.install_requests.pop(request_id)
if isinstance(requestOrRequests, list):
[await self._install(req.artifact, req.name, req.version, req.hash) for req in requestOrRequests]
else:
await self._install(requestOrRequests.artifact, requestOrRequests.name, requestOrRequests.version, requestOrRequests.hash)
def cancel_plugin_install(self, request_id):
self.install_requests.pop(request_id)
+25 -1
View File
@@ -44,13 +44,37 @@
"title": "Update {{artifact}}"
}
},
"MultiplePluginsInstallModal": {
"title": {
"mixed_one": "Modify 1 plugin",
"mixed_other": "Modify {{count}} plugins",
"update_one": "Update 1 plugin",
"update_other": "Update {{count}} plugins",
"reinstall_one": "Reinstall 1 plugin",
"reinstall_other": "Reinstall {{count}} plugins",
"install_one": "Install 1 plugin",
"install_other": "Install {{count}} plugins"
},
"ok_button": {
"idle": "Confirm",
"loading": "Working"
},
"confirm": "Are you sure you want to make the following modifications?",
"description": {
"install": "Install {{name}} {{version}}",
"update": "Update {{name}} to {{version}}",
"reinstall": "Reinstall {{name}} {{version}}"
}
},
"PluginListIndex": {
"no_plugin": "No plugins installed!",
"plugin_actions": "Plugin Actions",
"reinstall": "Reinstall",
"reload": "Reload",
"uninstall": "Uninstall",
"update_to": "Update to {{name}}"
"update_to": "Update to {{name}}",
"update_all_one": "Update 1 plugin",
"update_all_other": "Update {{count}} plugins"
},
"PluginLoader": {
"decky_title": "Decky",
+7 -1
View File
@@ -19,6 +19,7 @@ class Utilities:
"ping": self.ping,
"http_request": self.http_request,
"install_plugin": self.install_plugin,
"install_plugins": self.install_plugins,
"cancel_plugin_install": self.cancel_plugin_install,
"confirm_plugin_install": self.confirm_plugin_install,
"uninstall_plugin": self.uninstall_plugin,
@@ -70,6 +71,11 @@ class Utilities:
install_type=install_type
)
async def install_plugins(self, requests):
return await self.context.plugin_browser.request_multiple_plugin_installs(
requests=requests
)
async def confirm_plugin_install(self, request_id):
return await self.context.plugin_browser.confirm_plugin_install(request_id)
@@ -266,7 +272,7 @@ class Utilities:
await close_old_tabs()
result = await tab.reload_and_evaluate(script)
self.logger.info(result)
except Exception:
self.logger.error("Failed to connect to React DevTools")
self.logger.error(format_exc())