From 529d96340795148eb9cbdd6f06c0228f5cfb50f5 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 30 May 2025 16:32:54 +0800 Subject: [PATCH 1/3] v0.6.14 ~ add null default values on event, add activity to order triggered events --- composer.json | 2 +- extension.json | 2 +- package.json | 2 +- server/src/Events/EntityActivityChanged.php | 4 ++-- server/src/Events/EntityCompleted.php | 4 ++-- server/src/Events/OrderCanceled.php | 4 ++-- server/src/Events/OrderCompleted.php | 4 ++-- server/src/Events/OrderDispatched.php | 4 ++-- server/src/Events/OrderDriverAssigned.php | 2 +- server/src/Events/OrderFailed.php | 4 ++-- server/src/Events/OrderReady.php | 2 +- server/src/Events/OrderStarted.php | 2 +- server/src/Events/WaypointActivityChanged.php | 4 ++-- server/src/Events/WaypointCompleted.php | 4 ++-- server/src/Models/Order.php | 13 +++++++++++-- 15 files changed, 33 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index a186205f9..30da448ba 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/fleetops-api", - "version": "0.6.13", + "version": "0.6.14", "description": "Fleet & Transport Management Extension for Fleetbase", "keywords": [ "fleetbase-extension", diff --git a/extension.json b/extension.json index 7d227169b..9eb04d877 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Fleet-Ops", - "version": "0.6.13", + "version": "0.6.14", "description": "Fleet & Transport Management Extension for Fleetbase", "repository": "https://github.com/fleetbase/fleetops", "license": "AGPL-3.0-or-later", diff --git a/package.json b/package.json index b0273c533..6d83a68c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/fleetops-engine", - "version": "0.6.13", + "version": "0.6.14", "description": "Fleet & Transport Management Extension for Fleetbase", "fleetbase": { "route": "fleet-ops" diff --git a/server/src/Events/EntityActivityChanged.php b/server/src/Events/EntityActivityChanged.php index 1ac375406..c09349700 100644 --- a/server/src/Events/EntityActivityChanged.php +++ b/server/src/Events/EntityActivityChanged.php @@ -21,12 +21,12 @@ class EntityActivityChanged implements ShouldBroadcast /** * The entity which has new activity. */ - public Entity $entity; + public ?Entity $entity = null; /** * The activity which triggered the waypoint completed. */ - public Activity $activity; + public ?Activity $activity = null; /** * The event id. diff --git a/server/src/Events/EntityCompleted.php b/server/src/Events/EntityCompleted.php index b2a4de2d6..75463afe9 100644 --- a/server/src/Events/EntityCompleted.php +++ b/server/src/Events/EntityCompleted.php @@ -21,12 +21,12 @@ class EntityCompleted implements ShouldBroadcast /** * The entity which is completed. */ - public Entity $entity; + public ?Entity $entity = null; /** * The activity which triggered the waypoint completed. */ - public Activity $activity; + public ?Activity $activity = null; /** * The event id. diff --git a/server/src/Events/OrderCanceled.php b/server/src/Events/OrderCanceled.php index 719682929..6df6d3920 100644 --- a/server/src/Events/OrderCanceled.php +++ b/server/src/Events/OrderCanceled.php @@ -18,10 +18,10 @@ class OrderCanceled extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; /** * Assosciated order waypoint which event is for. */ - public ?Waypoint $waypoint; + public ?Waypoint $waypoint = null; } diff --git a/server/src/Events/OrderCompleted.php b/server/src/Events/OrderCompleted.php index 90dc4532a..39cd2da19 100644 --- a/server/src/Events/OrderCompleted.php +++ b/server/src/Events/OrderCompleted.php @@ -18,10 +18,10 @@ class OrderCompleted extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; /** * Assosciated order waypoint which event is for. */ - public ?Waypoint $waypoint; + public ?Waypoint $waypoint = null; } diff --git a/server/src/Events/OrderDispatched.php b/server/src/Events/OrderDispatched.php index c90f9e98f..86951e066 100644 --- a/server/src/Events/OrderDispatched.php +++ b/server/src/Events/OrderDispatched.php @@ -18,10 +18,10 @@ class OrderDispatched extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; /** * Assosciated order waypoint which event is for. */ - public ?Waypoint $waypoint; + public ?Waypoint $waypoint = null; } diff --git a/server/src/Events/OrderDriverAssigned.php b/server/src/Events/OrderDriverAssigned.php index 9235684c6..8cdbb7b67 100644 --- a/server/src/Events/OrderDriverAssigned.php +++ b/server/src/Events/OrderDriverAssigned.php @@ -17,5 +17,5 @@ class OrderDriverAssigned extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; } diff --git a/server/src/Events/OrderFailed.php b/server/src/Events/OrderFailed.php index df76a1051..49a90b661 100644 --- a/server/src/Events/OrderFailed.php +++ b/server/src/Events/OrderFailed.php @@ -18,10 +18,10 @@ class OrderFailed extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; /** * Assosciated order waypoint which event is for. */ - public ?Waypoint $waypoint; + public ?Waypoint $waypoint = null; } diff --git a/server/src/Events/OrderReady.php b/server/src/Events/OrderReady.php index af1acbe19..912b40f20 100644 --- a/server/src/Events/OrderReady.php +++ b/server/src/Events/OrderReady.php @@ -17,5 +17,5 @@ class OrderReady extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; } diff --git a/server/src/Events/OrderStarted.php b/server/src/Events/OrderStarted.php index 5351ca857..5e87dac34 100644 --- a/server/src/Events/OrderStarted.php +++ b/server/src/Events/OrderStarted.php @@ -17,5 +17,5 @@ class OrderStarted extends ResourceLifecycleEvent /** * Assosciated activity which triggered the event. */ - public ?Activity $activity; + public ?Activity $activity = null; } diff --git a/server/src/Events/WaypointActivityChanged.php b/server/src/Events/WaypointActivityChanged.php index 660d2f231..2467cb0bf 100644 --- a/server/src/Events/WaypointActivityChanged.php +++ b/server/src/Events/WaypointActivityChanged.php @@ -21,12 +21,12 @@ class WaypointActivityChanged implements ShouldBroadcast /** * The waypoint which is completed. */ - public Waypoint $waypoint; + public ?Waypoint $waypoint = null; /** * The activity which triggered the waypoint completed. */ - public Activity $activity; + public ?Activity $activity = null; /** * The event id. diff --git a/server/src/Events/WaypointCompleted.php b/server/src/Events/WaypointCompleted.php index e233fb5ed..700b3e9f0 100644 --- a/server/src/Events/WaypointCompleted.php +++ b/server/src/Events/WaypointCompleted.php @@ -21,12 +21,12 @@ class WaypointCompleted implements ShouldBroadcast /** * The waypoint which is completed. */ - public Waypoint $waypoint; + public ?Waypoint $waypoint = null; /** * The activity which triggered the waypoint completed. */ - public Activity $activity; + public ?Activity $activity = null; /** * The event id. diff --git a/server/src/Models/Order.php b/server/src/Models/Order.php index fc55a3574..9bc2f727f 100644 --- a/server/src/Models/Order.php +++ b/server/src/Models/Order.php @@ -1095,8 +1095,13 @@ public function dispatch(bool $save = true): static $this->flushAttributesCache(); } + // Prepare dispatch event + $dispatchActivity = $this->config()->getDispatchActivity(); + $dispatchEvent = new OrderDispatched($this); + $dispatchEvent->activity = $dispatchActivity; + // Queue the OrderDispatched event to run after the DB commit succeeds - dispatch(fn () => event(new OrderDispatched($this)))->afterCommit(); + dispatch(fn () => event($dispatchEvent))->afterCommit(); return $this; } @@ -1187,7 +1192,11 @@ public function cancel() } } - return event(new OrderCanceled($this)); + // Prepare cancel event + $cancelEvent = new OrderCanceled($this); + $cancelEvent->activity = $canceledActivity; + + return dispatch(fn () => event($cancelEvent))->afterCommit(); } /** From 496d2fd086acaaa4a2c48b9a1322cd38b965e20a Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 30 May 2025 16:35:50 +0800 Subject: [PATCH 2/3] remove activity attachment on order triggered events --- server/src/Listeners/NotifyOrderEvent.php | 1 + server/src/Models/Order.php | 13 ++----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/server/src/Listeners/NotifyOrderEvent.php b/server/src/Listeners/NotifyOrderEvent.php index 65b9370b9..224d473a5 100644 --- a/server/src/Listeners/NotifyOrderEvent.php +++ b/server/src/Listeners/NotifyOrderEvent.php @@ -34,6 +34,7 @@ public function handle($event) $reason = $event->activity ? $event->activity->get('details') : ''; NotificationRegistry::notify(OrderCanceled::class, $order, $reason, $event->waypoint); } + if ($event instanceof \Fleetbase\FleetOps\Events\OrderCompleted) { NotificationRegistry::notify(OrderCompleted::class, $order, $event->waypoint); } diff --git a/server/src/Models/Order.php b/server/src/Models/Order.php index 9bc2f727f..43296b856 100644 --- a/server/src/Models/Order.php +++ b/server/src/Models/Order.php @@ -1095,13 +1095,8 @@ public function dispatch(bool $save = true): static $this->flushAttributesCache(); } - // Prepare dispatch event - $dispatchActivity = $this->config()->getDispatchActivity(); - $dispatchEvent = new OrderDispatched($this); - $dispatchEvent->activity = $dispatchActivity; - // Queue the OrderDispatched event to run after the DB commit succeeds - dispatch(fn () => event($dispatchEvent))->afterCommit(); + dispatch(fn () => event(new OrderDispatched($this)))->afterCommit(); return $this; } @@ -1192,11 +1187,7 @@ public function cancel() } } - // Prepare cancel event - $cancelEvent = new OrderCanceled($this); - $cancelEvent->activity = $canceledActivity; - - return dispatch(fn () => event($cancelEvent))->afterCommit(); + return dispatch(fn () => event(new OrderCanceled($this)))->afterCommit(); } /** From 71cf3cf23d18cf5aa572919555f41846fb909661 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 30 May 2025 16:41:59 +0800 Subject: [PATCH 3/3] added create release workflow --- .github/workflows/create-release.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 000000000..c4016de2f --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,21 @@ +name: Create Release +on: + push: + tags: + - 'v*' + +jobs: + create: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Publish GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + generate_release_notes: true + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file