Repository navigation
feat(descriptors): share the core FleetOps resource identity descriptors with every extension - #86
Conversation
…e, order, vendor and fleet identity descriptors with every extension The resource identity descriptors for the resources every extension can see through this package's models now live here, together with the thin pill, summary, identity-cell and select-option wrappers that name the resource type for ember-ui's generic components, and the styled placeholder silhouettes they fall back to. An instance initializer registers the descriptors whenever the host or an engine boots, filling in only keys nobody has registered, so a Storefront or Ledger table renders a driver as an identity cell on a deep link without loading the FleetOps engine. Opening a resource loads FleetOps on demand and hands the record to its action service, so the engine bundle is only fetched on click. FleetOps replaces these with its own openers when it boots. Covered at 100% by unit tests for the helpers, descriptors, placeholder images and initializer, and a rendering test that proves every wrapper resolves and passes its resource type through.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v0.2.3 #86 +/- ##
=================================================
Coverage 100.00% 100.00%
=================================================
Files 116 120 +4
Lines 2936 3123 +187
Branches 698 765 +67
=================================================
+ Hits 2936 3123 +187
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
Follow-up commits since opening:
Validation on the final commit: 1107 tests, 0 failures. Every eligible file under |
What change does this PR introduce?
Moves the resource identity descriptors for the eight resources every extension can see through this package's models into this package, so they are available wherever the models are:
addon/utils/resource-descriptors/shared.jsbuilds descriptors fordriver,vehicle,customer,contact,place,order,vendorandfleet. They are the same descriptors FleetOps registers today, minus the FleetOps-only openers.addon/utils/resource-descriptors/helpers.jsholds the building blocks (first,relation,photo,fact,dateLabel, ...) without importing anything from@fleetbase/ember-ui, which already depends on this package.engineOpenerandengineInstalledare new: opening a resource loads the FleetOps engine on demand through the universe extension manager and hands the record to its action service, so the FleetOps bundle is only fetched when someone clicks.addon/utils/placeholder-images.jsis the styled placeholder set, moved from FleetOps verbatim.<Key::Pill>,<Key::Summary>,<Cell::KeyIdentity>and<SelectOption::Key>wrappers for those eight keys move here, so they resolve inside any engine that depends on this package.instance-initializers/register-shared-resource-descriptors.jsregisters the descriptors with ember-ui'sresource-registryservice on every host and engine boot, but only for keys nobody has registered yet. FleetOps registers richer versions of the same keys when it boots and a later engine must not replace them.A companion FleetOps PR deletes the moved wrappers and placeholder set there, re-exports the helpers, and builds its own driver, vehicle, customer, contact, place, order, vendor and fleet descriptors from the shared ones with its panel openers. The two are safe to land in either order: FleetOps keeps working on the published fleetops-data until its PR lands, and this package has no FleetOps dependency.
Why was this change needed?
Storefront, and any other extension, lists drivers, customers and places but cannot invoke FleetOps' identity cells, pills or summaries: an engine's components only exist in its own namespace. Duplicating them in each extension was ruled out, and eagerly loading the FleetOps engine from Storefront costs its whole bundle just to get descriptor data. Putting the descriptors and wrappers in the package every extension already depends on gives them the same rendering on a deep link, with no engine load until a click.
Other information
Validation, run locally:
New tests: unit coverage of the helpers, the eight descriptors, the placeholder images and the initializer, plus a rendering test that stubs ember-ui's generic components and proves every wrapper resolves and passes its resource type through.
Documentation: the README gains a "Shared resource descriptors" section. The extension developer docs in
fleetbase/fleetbase.ioshould mention that these descriptors and wrappers come from this package; no API behaviour orfleetbase/postmanspec changes.Follow-up: the package will likely be renamed to
@fleetbase/fleetops-sharedin a separate PR, with a finalfleetops-datarelease that re-exports every module under the old paths.