diff --git a/src/backend/InvenTree/plugin/base/ui/tests.py b/src/backend/InvenTree/plugin/base/ui/tests.py index f372374bb4..e38e64a856 100644 --- a/src/backend/InvenTree/plugin/base/ui/tests.py +++ b/src/backend/InvenTree/plugin/base/ui/tests.py @@ -111,7 +111,7 @@ class UserInterfaceMixinTests(InvenTreeAPITestCase): # Request custom panel information for a part instance response = self.get(url, data=query_data) - # There should be 4 active panels for the part by default + # There should be 3 active panels for the part by default self.assertEqual(3, len(response.data)) _part.active = False @@ -119,8 +119,8 @@ class UserInterfaceMixinTests(InvenTreeAPITestCase): response = self.get(url, data=query_data) - # As the part is not active, only 3 panels left - self.assertEqual(3, len(response.data)) + # As the part is not active, only 2 panels left + self.assertEqual(2, len(response.data)) # Disable the "ENABLE_PART_PANELS" setting, and try again plugin.set_setting('ENABLE_PART_PANELS', False) diff --git a/src/backend/InvenTree/plugin/samples/integration/user_interface_sample.py b/src/backend/InvenTree/plugin/samples/integration/user_interface_sample.py index ba906cf225..8bb11692d5 100644 --- a/src/backend/InvenTree/plugin/samples/integration/user_interface_sample.py +++ b/src/backend/InvenTree/plugin/samples/integration/user_interface_sample.py @@ -93,13 +93,17 @@ class SampleUserInterfacePlugin(SettingsMixin, UserInterfaceMixin, InvenTreePlug except (Part.DoesNotExist, ValueError): part = None - panels.append({ - 'key': 'part-panel', - 'title': _('Part Panel'), - 'source': self.plugin_static_file('sample_panel.js:renderPartPanel'), - 'icon': 'ti:package_outline', - 'context': {'part_name': part.name if part else ''}, - }) + # Only display this panel for "active" parts + if part and part.active: + panels.append({ + 'key': 'part-panel', + 'title': _('Part Panel'), + 'source': self.plugin_static_file( + 'sample_panel.js:renderPartPanel' + ), + 'icon': 'ti:package:outline', + 'context': {'part_name': part.name if part else ''}, + }) # Next, add a custom panel which will appear on the 'purchaseorder' page if target_model == 'purchaseorder' and self.get_setting( diff --git a/src/frontend/src/hooks/UsePluginPanels.tsx b/src/frontend/src/hooks/UsePluginPanels.tsx index 2dcc367e10..c8559703e3 100644 --- a/src/frontend/src/hooks/UsePluginPanels.tsx +++ b/src/frontend/src/hooks/UsePluginPanels.tsx @@ -52,7 +52,7 @@ export function usePluginPanels({ // API query to fetch initial information on available plugin panels const pluginQuery = useQuery({ enabled: pluginPanelsEnabled && !!model && id !== undefined, - queryKey: ['custom-plugin-panels', model, id], + queryKey: ['custom-plugin-panels', model, id, instance], throwOnError: (error: any) => { console.error('ERR: Failed to fetch plugin panels'); return false;