From ab01609bb591b64d766f9db1dff0f7b8145ebb01 Mon Sep 17 00:00:00 2001 From: Knight Tan Date: Sun, 22 Oct 2017 16:27:06 +0800 Subject: [PATCH 1/4] allow incident update to update component status, bug fix #2767 --- .../Dashboard/IncidentController.php | 4 ++ .../dashboard/incidents/updates/add.blade.php | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 3822a812..09b8a7b2 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -348,6 +348,10 @@ class IncidentController extends Controller ->withErrors($e->getMessageBag()); } + if ($incident->incident->component) { + $incident->incident->component->update(['status' => Binput::get('component_status')]); + } + return cachet_redirect('dashboard.incidents') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.success'))); } diff --git a/resources/views/dashboard/incidents/updates/add.blade.php b/resources/views/dashboard/incidents/updates/add.blade.php index 9569bfcc..3783018d 100644 --- a/resources/views/dashboard/incidents/updates/add.blade.php +++ b/resources/views/dashboard/incidents/updates/add.blade.php @@ -45,6 +45,44 @@ {{ trans('cachet.incidents.status')[4] }} + @if($incident->component) + + @endif + @if($incident->component) +
+
+
{{ $incident->component->name }}
+
+
+ @foreach(trans('cachet.components.status') as $statusID => $status) +
+ +
+ @endforeach +
+
+
+
+ @endif
From d2975cd1eb7db4109ad3a996fe1419e686656172 Mon Sep 17 00:00:00 2001 From: Knight Tan Date: Thu, 26 Oct 2017 09:16:20 +0800 Subject: [PATCH 2/4] added component and status to CreateIncidentUpdateCommand --- .../CreateIncidentUpdateCommand.php | 18 +++++++++++++++++- .../Dashboard/IncidentController.php | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php index 048465b8..fed281c3 100644 --- a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php +++ b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php @@ -41,7 +41,19 @@ final class CreateIncidentUpdateCommand * @var string */ public $message; + /** + * The incident component. + * + * @var int + */ + public $component_id; + /** + * The component status. + * + * @var int + */ + public $component_status; /** * The user. * @@ -58,6 +70,8 @@ final class CreateIncidentUpdateCommand 'incident' => 'required', 'status' => 'required|int|min:1|max:4', 'message' => 'required|string', + 'component_id' => 'nullable|required_with:component_status|int', + 'component_status' => 'nullable|required_with:component_id|int|min:0|max:4', 'user' => 'required', ]; @@ -71,11 +85,13 @@ final class CreateIncidentUpdateCommand * * @return void */ - public function __construct(Incident $incident, $status, $message, User $user) + public function __construct(Incident $incident, $status, $message, $component_id, $component_status, User $user) { $this->incident = $incident; $this->status = $status; $this->message = $message; + $this->component_id = $component_id; + $this->component_status = $component_status; $this->user = $user; } } diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 09b8a7b2..865a8145 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -339,6 +339,8 @@ class IncidentController extends Controller $incident, Binput::get('status'), Binput::get('message'), + Binput::get('component_id'), + Binput::get('component_status'), $this->auth->user() )); } catch (ValidationException $e) { From 14366df3c4acb23e993940439331ba6cd8da7cea Mon Sep 17 00:00:00 2001 From: Knight Tan Date: Thu, 26 Oct 2017 09:18:36 +0800 Subject: [PATCH 3/4] align the rules for styleci --- .../IncidentUpdate/CreateIncidentUpdateCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php index fed281c3..caa65a75 100644 --- a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php +++ b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php @@ -67,12 +67,12 @@ final class CreateIncidentUpdateCommand * @var string[] */ public $rules = [ - 'incident' => 'required', - 'status' => 'required|int|min:1|max:4', - 'message' => 'required|string', + 'incident' => 'required', + 'status' => 'required|int|min:1|max:4', + 'message' => 'required|string', 'component_id' => 'nullable|required_with:component_status|int', 'component_status' => 'nullable|required_with:component_id|int|min:0|max:4', - 'user' => 'required', + 'user' => 'required', ]; /** From 5b1d9ef0f6e1f2ec18da92b36753544780abf53d Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sun, 21 Jan 2018 22:03:15 +0000 Subject: [PATCH 4/4] Fix up --- .../Dashboard/IncidentController.php | 4 ++-- .../incidents/updates/edit.blade.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 865a8145..cc03457d 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -350,8 +350,8 @@ class IncidentController extends Controller ->withErrors($e->getMessageBag()); } - if ($incident->incident->component) { - $incident->incident->component->update(['status' => Binput::get('component_status')]); + if ($incident->component) { + $incident->component->update(['status' => Binput::get('component_status')]); } return cachet_redirect('dashboard.incidents') diff --git a/resources/views/dashboard/incidents/updates/edit.blade.php b/resources/views/dashboard/incidents/updates/edit.blade.php index 6832e223..5df75656 100644 --- a/resources/views/dashboard/incidents/updates/edit.blade.php +++ b/resources/views/dashboard/incidents/updates/edit.blade.php @@ -45,6 +45,25 @@ {{ trans('cachet.incidents.status')[4] }}
+ @if($incident->component) +
+
+
{{ $incident->component->name }}
+
+
+ @foreach(trans('cachet.components.status') as $statusID => $status) +
+ +
+ @endforeach +
+
+
+
+ @endif