Accept + implement ADR-010 frontend plugin hooks (contract 0.7.0)
Four data-only hooks on BasePlugin (get_settings_cards, get_asset_panels, get_map_overlays, get_asset_presentation) with a GET-only /api/pluginui consumer surface copying the dashboard-widgets semantics. Pilots: warranty declares its asset panel; measuringtools supplies its settings card, presentation, and calibration overlay - the last hardcoded settings-nav entry is now hook-sourced. Generic renderers for panels/overlays/presentation deferred per the ADR's incremental adoption plan (documented in CONTRACT-STABILITY.md). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,46 @@ class MeasuringToolsPlugin(BasePlugin):
|
||||
# plugin guide as the intentional empty-schema case.
|
||||
return []
|
||||
|
||||
def get_settings_cards(self) -> List[Dict]:
|
||||
# ADR-010 pilot. Contributes the Measuring Tools settings card that used
|
||||
# to be hardcoded in the core settingsNav.js catalog.
|
||||
return [
|
||||
{
|
||||
'group': 'Measuring Tools',
|
||||
'to': '/settings/measuringtooltypes',
|
||||
'icon': 'ruler',
|
||||
'title': 'Measuring Tool Types',
|
||||
'description': 'Manage measuring-tool subtypes (caliper, '
|
||||
'micrometer, thread gage...) + map colors',
|
||||
'position': 22,
|
||||
},
|
||||
]
|
||||
|
||||
def get_asset_presentation(self) -> List[Dict]:
|
||||
# ADR-010 pilot. Tells core how to render + link the measuring_tool
|
||||
# asset type in global-search rows and cross-links.
|
||||
return [
|
||||
{
|
||||
'assettype': 'measuring_tool',
|
||||
'icon': 'ruler',
|
||||
'label': 'Measuring Tool',
|
||||
'route': '/measuringtools/{assetid}',
|
||||
},
|
||||
]
|
||||
|
||||
def get_map_overlays(self) -> List[Dict]:
|
||||
# ADR-010 pilot. Declares a calibration-due badge overlay for the
|
||||
# shop-floor map; the map fetches the endpoint to decorate markers.
|
||||
return [
|
||||
{
|
||||
'id': 'calibration-due',
|
||||
'label': 'Calibration due',
|
||||
'endpoint': '/api/measuringtools/map-overlay',
|
||||
'style': 'badge',
|
||||
'legend': True,
|
||||
},
|
||||
]
|
||||
|
||||
def init_app(self, app: Flask, db_instance) -> None:
|
||||
logger.info(f"Measuring-tools plugin initialized (v{self.meta.version})")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user