Skip to content

Configured order lifecycles and order presentation profiles - #346

Open
shivthakker wants to merge 6 commits into
release/v0.6.71from
feature/configured-order-lifecycle
Open

shivthakker wants to merge 6 commits into
release/v0.6.71from
feature/configured-order-lifecycle

Conversation

@shivthakker

@shivthakker shivthakker commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Lets an Order Config define its own lifecycle and lets extensions supply an order presentation profile, without changing behaviour for configs that don't opt in.

Configured lifecycle (order_config.meta.lifecycle)

{ "initial": "requested", "completed": "completed", "canceled": "cancelled",
  "terminal": ["completed","cancelled"], "dispatch": false, "strict_transitions": true }
  • OrderConfig: lifecycle(), hasConfiguredLifecycle(), getInitialActivity(), getInitialStatusCode(), allowsDispatch(), hasStrictTransitions(), getTerminalActivityCodes(), isTerminalActivityCode(), canTransition(). getCanceledActivity()/getCompletedActivity() honour configured codes.
  • OrderController::createRecord: starts at the configured initial activity; never dispatches when dispatch: false.
  • TrackingNumber::insertGetUuid: the owner may supply its initial tracking status (Order::getInitialTrackingStatus()), so no forced CREATED entry.
  • Order::cancel(): uses the config's canceled activity/code.
  • updateActivity: with strict_transitions, the target must be a configured child of the current activity and the server-side activity definition is used. dispatchOrder/bulkDispatch refuse configs with dispatch disabled.

Presentation profiles (frontend)

  • New order-presentation service. Extensions register profiles in the registry (fleet-ops:order-presentation / profiles), matched by order_config.meta.presentation_profile (+ optional isEnabled).
  • A profile can compose order/form and order/details sections (native section names or ExtensionComponents), hide fields in order/form/details and multi-drop routing, hide detail/table actions, and route "Edit details" to the profiled panel form. Draft order-type switches call the profile's prepare/release.
  • order/kanban: with a configured lifecycle, columns/labels come from the flow (graph order, activity status labels) instead of injected default columns.
  • Activity flow editor roots at the configured initial activity and no longer forces created/dispatched/started for such configs.

Compatibility

Every new branch is guarded by hasConfiguredLifecycle() / a matching profile. Configs without meta.lifecycle and orders without a profile render and behave exactly as before.

Tests

  • New server/tests/OrderConfigLifecycleTest.php (5 passing): default semantics unchanged, configured codes, graph-only transitions, config-only flow changes, dispatch disabling.
  • Full server suite locally: 2,557 passed; ReportSchemaContractsTest fails identically on main (pre-existing).
  • Frontend changes are syntax-checked only; not yet exercised in a running console.

Known follow-ups (not in this PR)

OrderFilter::status('active') alias, LiveOrderQuery and metrics still assume default codes; Order::attachFiles does not company-scope file ids.

shivthakker and others added 2 commits September 28, 2026 17:35
Opt-in via OrderConfig meta; orders whose config does not opt in keep
the default dispatch lifecycle and presentation.

Backend (meta.lifecycle):
- OrderConfig helpers: initial/completed/canceled/terminal codes,
  allowsDispatch, strict transitions, canTransition over the flow graph
- createRecord starts at the configured initial activity and never
  dispatches when dispatch is disabled
- Tracking number initial status comes from the owner when provided
- Order::cancel uses the config's canceled activity
- updateActivity validates targets against the configured graph when
  strict_transitions is set; dispatch endpoints refuse non-dispatch configs

Frontend:
- order-presentation service: extensions register profiles (by
  meta.presentation_profile) that compose the order form/details,
  hide fields/actions and route edits to the profiled form
- Kanban derives columns/labels from a configured lifecycle instead of
  injecting default dispatch columns
- Activity flow editor roots at the configured initial activity

Tests: OrderConfigLifecycleTest; existing suite unchanged
(ReportSchemaContractsTest fails on main as well).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roncodes
roncodes changed the base branch from main to release/v0.6.71 October 3, 2026 03:23
…nfigured-order-lifecycle

# Conflicts:
#	addon/controllers/operations/orders/index/details.js
- Profiles hide actions by the built-in ids the order table and details use in the
  resource view registries (assign-driver, unassign-driver, update-activity,
  edit-order-details, view-label, listen-to-socket-channel, view-metadata, ...).
  The details assign/unassign item now has those ids too.
- The orders table applies a profile's hidden.actions to every row action by id,
  as the details panel does, instead of only dispatch and assign driver.
- isClosed counts the configured completed and canceled codes as terminal,
  matching OrderConfig::getTerminalActivityCodes().
- bulkDispatch no longer fatals for an order without a config.
- Restore Order::config()'s docblock, which getInitialTrackingStatus() split off.
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (adffe39) to head (9ba5d0d).

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/v0.6.71      #346   +/-   ##
===================================================
  Coverage             100.00%   100.00%           
- Complexity             12329     12379   +50     
===================================================
  Files                    600       600           
  Lines                  46419     46496   +77     
===================================================
+ Hits                   46419     46496   +77     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants