2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-15 21:52:21 +00:00

UI panels fix (#10341)

* Tweak sample plugin

* Re-fetch panels when instance changes

* Unit test fix
This commit is contained in:
Oliver
2025-09-18 13:19:47 +10:00
committed by GitHub
parent 21cb488eef
commit df0e27bed2
3 changed files with 15 additions and 11 deletions

View File

@@ -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)

View File

@@ -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(