mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
fix(plugins): Resolve plugin action button errors and config save permission issues (#162)
* fix(plugins): Resolve plugin ID determination error in action buttons
- Fix server-side template parameter order for executePluginAction
- Add data-plugin-id attributes to action buttons in all templates
- Enhance executePluginAction with comprehensive fallback logic
- Support retrieving pluginId from DOM, Alpine context, and config state
- Fixes 'Unable to determine plugin ID' error for Spotify/YouTube auth
* fix(plugins): Add missing button IDs and status divs in server-side action template
- Add action-{id}-{index} IDs to action buttons
- Add action-status-{id}-{index} status divs for each action
- Match client-side template structure for consistency
- Fixes 'Action elements not found' error
* fix(api): Fix indentation error in execute_plugin_action function
- Fix incorrect else block indentation that caused 500 errors
- Correct indentation for OAuth flow and simple script execution paths
- Resolves syntax error preventing plugin actions from executing
* fix(api): Improve error handling for plugin actions and config saves
- Add better JSON parsing error handling with request details
- Add detailed permission error messages for secrets file saves
- Include file path and permission status in error responses
- Helps diagnose 400 errors on action execution and 500 errors on config saves
* fix(api): Add detailed permission error handling for secrets config saves
- Add PermissionError-specific handling with permission checks
- Include directory and file permission status in error logs
- Provide more helpful error messages with file paths
- Helps diagnose permission issues when saving config_secrets.json
* fix(config): Add permission check and actionable error message for config saves
- Check file writability before attempting write
- Show file owner and current permissions in error message
- Provide exact command to fix permissions (chown + chmod)
- Helps diagnose and resolve permission issues with config_secrets.json
* fix(config): Preserve detailed permission error messages
- Handle PermissionError separately to preserve detailed error messages
- Ensure actionable permission fix commands are included in error response
- Prevents detailed error messages from being lost in exception chain
* fix(config): Remove overly strict pre-write permission check
- Remove pre-write file existence/writability check that was blocking valid writes
- Let actual file write operation determine success/failure
- Provide detailed error messages only when write actually fails
- Fixes regression where config_secrets.json saves were blocked unnecessarily
* fix(config): Use atomic writes for config_secrets.json to handle permission issues
- Write to temp file first, then atomically move to final location
- Works even when existing file isn't writable (as long as directory is writable)
- Matches pattern used elsewhere in codebase (disk_cache, atomic_manager)
- Fixes permission errors when saving secrets configuration
* chore: Update music plugin submodule to include live_priority fix
* fix(plugins): Improve plugin ID determination in dynamic button generation
- Update generateFormFromSchema to pass currentPluginConfig?.pluginId and add data attributes
- Update generateSimpleConfigForm to pass currentPluginConfig?.pluginId and add data attributes
- Scope fallback 6 DOM lookup to button context instead of document-wide search
- Ensures correct plugin tab selection when multiple plugins are present
- Maintains existing try/catch error handling and logging
---------
Co-authored-by: Chuck <chuck@example.com>
This commit is contained in:
@@ -2872,6 +2872,8 @@
|
||||
const statusId = `action-status-${action.id}-${index}`;
|
||||
const bgColor = action.color || 'blue';
|
||||
const colors = colorMap[bgColor] || colorMap['blue'];
|
||||
// Ensure pluginId is valid for template interpolation
|
||||
const safePluginId = pluginId || '';
|
||||
|
||||
formHtml += `
|
||||
<div class="${colors.bg} border ${colors.border} rounded-lg p-4">
|
||||
@@ -2884,7 +2886,9 @@
|
||||
</div>
|
||||
<button type="button"
|
||||
id="${actionId}"
|
||||
onclick="executePluginAction('${action.id}', ${index}, '${pluginId}')"
|
||||
onclick="executePluginAction('${action.id}', ${index}, '${safePluginId}')"
|
||||
data-plugin-id="${safePluginId}"
|
||||
data-action-id="${action.id}"
|
||||
class="btn ${colors.btn} text-white px-4 py-2 rounded-md whitespace-nowrap">
|
||||
${action.icon ? `<i class="${action.icon} mr-2"></i>` : ''}${action.button_text || action.title || 'Execute'}
|
||||
</button>
|
||||
@@ -2924,6 +2928,8 @@
|
||||
const statusId = `action-status-${action.id}-${index}`;
|
||||
const bgColor = action.color || 'blue';
|
||||
const colors = colorMap[bgColor] || colorMap['blue'];
|
||||
// Ensure pluginId is valid for template interpolation
|
||||
const safePluginId = pluginId || '';
|
||||
actionsHtml += `
|
||||
<div class="${colors.bg} border ${colors.border} rounded-lg p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
@@ -2935,7 +2941,9 @@
|
||||
</div>
|
||||
<button type="button"
|
||||
id="${actionId}"
|
||||
onclick="executePluginAction('${action.id}', ${index}, '${pluginId}')"
|
||||
onclick="executePluginAction('${action.id}', ${index}, '${safePluginId}')"
|
||||
data-plugin-id="${safePluginId}"
|
||||
data-action-id="${action.id}"
|
||||
class="btn ${colors.btn} text-white px-4 py-2 rounded-md">
|
||||
${action.icon ? `<i class="${action.icon} mr-2"></i>` : ''}${action.button_text || action.title || 'Execute'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user