From 532d8a20c5af1a19975c3c23e8d9aa8b74e61bee Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 15:34:26 +0100 Subject: [PATCH 01/11] Create an incident updates overview page --- .../Dashboard/IncidentController.php | 18 ++++++++- app/Http/Routes/Dashboard/IncidentRoutes.php | 10 +++-- app/Models/IncidentUpdate.php | 14 +++++++ resources/lang/en/dashboard.php | 5 ++- .../views/dashboard/incidents/index.blade.php | 2 +- .../incidents/updates/index.blade.php | 37 +++++++++++++++++++ 6 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 resources/views/dashboard/incidents/updates/index.blade.php diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 9d3be7bc..61e6c499 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -20,6 +20,7 @@ use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\IncidentTemplate; +use CachetHQ\Cachet\Models\IncidentUpdate; use GrahamCampbell\Binput\Facades\Binput; use Illuminate\Contracts\Auth\Guard; use Illuminate\Routing\Controller; @@ -293,7 +294,20 @@ class IncidentController extends Controller * * @return \Illuminate\View\View */ - public function showIncidentUpdateAction(Incident $incident) + public function showIncidentUpdates(Incident $incident) + { + $updates = IncidentUpdate::byIncident($incident)->orderBy('created_at', 'desc')->get(); + return View::make('dashboard.incidents.updates.index')->withIncident($incident)->withUpdates($updates); + } + + /** + * Shows the incident update form. + * + * @param \CachetHQ\Cachet\Models\Incident $incident + * + * @return \Illuminate\View\View + */ + public function showCreateIncidentUpdateAction(Incident $incident) { return View::make('dashboard.incidents.update')->withIncident($incident); } @@ -315,7 +329,7 @@ class IncidentController extends Controller $this->auth->user() )); } catch (ValidationException $e) { - return cachet_redirect('dashboard.incidents.updates', ['id' => $incident->id]) + return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id]) ->withInput(Binput::all()) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) ->withErrors($e->getMessageBag()); diff --git a/app/Http/Routes/Dashboard/IncidentRoutes.php b/app/Http/Routes/Dashboard/IncidentRoutes.php index c312bc08..ed9294eb 100644 --- a/app/Http/Routes/Dashboard/IncidentRoutes.php +++ b/app/Http/Routes/Dashboard/IncidentRoutes.php @@ -71,10 +71,14 @@ class IncidentRoutes $router->get('{incident}/updates', [ 'as' => 'get:dashboard.incidents.updates', - 'uses' => 'IncidentController@showIncidentUpdateAction', + 'uses' => 'IncidentController@showIncidentUpdates', ]); - $router->post('{incident}/updates', [ - 'as' => 'post:dashboard.incidents.updates', + $router->get('{incident}/updates/create', [ + 'as' => 'get:dashboard.incidents.updates.create', + 'uses' => 'IncidentController@showCreateIncidentUpdateAction', + ]); + $router->post('{incident}/updates/create', [ + 'as' => 'post:dashboard.incidents.updates.create', 'uses' => 'IncidentController@createIncidentUpdateAction', ]); }); diff --git a/app/Models/IncidentUpdate.php b/app/Models/IncidentUpdate.php index 207e129e..846b48a0 100644 --- a/app/Models/IncidentUpdate.php +++ b/app/Models/IncidentUpdate.php @@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Models; use AltThree\Validator\ValidatingTrait; use CachetHQ\Cachet\Models\Traits\SortableTrait; use CachetHQ\Cachet\Presenters\IncidentUpdatePresenter; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use McCool\LaravelAutoPresenter\HasPresenter; @@ -73,6 +74,19 @@ class IncidentUpdate extends Model implements HasPresenter 'user_id', ]; + /** + * Scope all by incident. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \CachetHQ\Cachet\Models\Incident $incident + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeByIncident(Builder $query, Incident $incident) + { + return $query->where('incident_id', '=', $incident->id); + } + /** * Get the incident relation. * diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index 2d452d09..ec84ef4a 100644 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -21,7 +21,10 @@ return [ 'logged' => '{0} There are no incidents, good work.|[1] You have logged one incident.|[2, Inf] You have reported :count incidents.', 'incident-create-template' => 'Create Template', 'incident-templates' => 'Incident Templates', - 'updates' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', + 'updates' => [ + 'title' => 'Incident updates', + 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', + ], 'add' => [ 'title' => 'Report an incident', 'success' => 'Incident added.', diff --git a/resources/views/dashboard/incidents/index.blade.php b/resources/views/dashboard/incidents/index.blade.php index dcfb2a72..70a7bb81 100644 --- a/resources/views/dashboard/incidents/index.blade.php +++ b/resources/views/dashboard/incidents/index.blade.php @@ -22,7 +22,7 @@ @foreach($incidents as $incident)
- {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates', $incident->updates()->count()) }} + {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }} @if($incident->message)

{{ Str::words($incident->message, 5) }}

@endif diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php new file mode 100644 index 00000000..392dd759 --- /dev/null +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -0,0 +1,37 @@ +@extends('layout.dashboard') + +@section('content') +
+ @includeWhen(isset($sub_menu), 'dashboard.partials.sub-sidebar') +
+
+ + {{ trans('dashboard.incidents.updates.title') }} + + + {{ trans('dashboard.incidents.update.title') }} + +
+
+
+
+ @include('dashboard.partials.errors') + +
+ @foreach($updates as $update) +
+
+ {{ Str::words($update->message, 8) }} +

{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}

+
+ +
+ @endforeach +
+
+
+
+
+@stop From 700c9366627a1341bd17cb0f4e5e5a535b7a66dc Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 15:47:31 +0100 Subject: [PATCH 02/11] Restore add incident update functionality --- app/Http/Controllers/Dashboard/IncidentController.php | 2 +- .../incidents/{update.blade.php => updates/add.blade.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename resources/views/dashboard/incidents/{update.blade.php => updates/add.blade.php} (100%) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 61e6c499..0bd37646 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -309,7 +309,7 @@ class IncidentController extends Controller */ public function showCreateIncidentUpdateAction(Incident $incident) { - return View::make('dashboard.incidents.update')->withIncident($incident); + return View::make('dashboard.incidents.updates.add')->withIncident($incident); } /** diff --git a/resources/views/dashboard/incidents/update.blade.php b/resources/views/dashboard/incidents/updates/add.blade.php similarity index 100% rename from resources/views/dashboard/incidents/update.blade.php rename to resources/views/dashboard/incidents/updates/add.blade.php From 3a9688c510ca1d18221454a8cf7e2bbbb665dcd3 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 16:01:58 +0100 Subject: [PATCH 03/11] Change navigation flow from incidents to incident updates page Clicking on the incident title will now navigate to the incident updates page rather than editing the incident. To prevent confusion I've also removed the "update" button from the incidents overview page and added the incident name to the page title of the incident updates page. --- resources/lang/en/dashboard.php | 2 +- resources/views/dashboard/incidents/index.blade.php | 3 +-- resources/views/dashboard/incidents/updates/index.blade.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index ec84ef4a..3fde4675 100644 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -22,7 +22,7 @@ return [ 'incident-create-template' => 'Create Template', 'incident-templates' => 'Incident Templates', 'updates' => [ - 'title' => 'Incident updates', + 'title' => 'Incident updates for :incident', 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', ], 'add' => [ diff --git a/resources/views/dashboard/incidents/index.blade.php b/resources/views/dashboard/incidents/index.blade.php index 70a7bb81..c11bdab9 100644 --- a/resources/views/dashboard/incidents/index.blade.php +++ b/resources/views/dashboard/incidents/index.blade.php @@ -22,14 +22,13 @@ @foreach($incidents as $incident)
- {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }} + {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }} @if($incident->message)

{{ Str::words($incident->message, 5) }}

@endif
diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php index 392dd759..b7f8d6fb 100644 --- a/resources/views/dashboard/incidents/updates/index.blade.php +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -6,9 +6,9 @@
- {{ trans('dashboard.incidents.updates.title') }} + {{ trans('dashboard.incidents.updates.title', ['incident' => Str::words($incident->name, 5)]) }} - + {{ trans('dashboard.incidents.update.title') }}
From 569b15000a8a79f856c5d94093412e70a4b8ab23 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 17:24:10 +0100 Subject: [PATCH 04/11] Implement edit IncidentUpdate feature --- .../Dashboard/IncidentController.php | 51 ++++++++++++++- app/Http/Routes/Dashboard/IncidentRoutes.php | 9 +++ resources/lang/en/dashboard.php | 15 +++-- .../incidents/updates/edit.blade.php | 62 +++++++++++++++++++ .../incidents/updates/index.blade.php | 6 +- 5 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 resources/views/dashboard/incidents/updates/edit.blade.php diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 0bd37646..5938f84c 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -16,6 +16,7 @@ use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand; +use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand; use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\Incident; @@ -322,7 +323,7 @@ class IncidentController extends Controller public function createIncidentUpdateAction(Incident $incident) { try { - $incident = dispatch(new CreateIncidentUpdateCommand( + $incidentUpdate = dispatch(new CreateIncidentUpdateCommand( $incident, Binput::get('status'), Binput::get('message'), @@ -331,11 +332,55 @@ class IncidentController extends Controller } catch (ValidationException $e) { return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id]) ->withInput(Binput::all()) - ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure'))) + ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.add.failure'))) ->withErrors($e->getMessageBag()); } return cachet_redirect('dashboard.incidents') - ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.update.success'))); + ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.success'))); + } + + + /** + * Shows the edit incident view. + * + * @param \CachetHQ\Cachet\Models\Incident $incident + * @param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate + * + * @return \Illuminate\View\View + */ + public function showEditIncidentUpdateAction(Incident $incident, IncidentUpdate $incidentUpdate) + { + return View::make('dashboard.incidents.updates.edit') + ->withIncident($incident) + ->withUpdate($incidentUpdate); + } + + /** + * Edit an incident. + * + * @param \CachetHQ\Cachet\Models\Incident $incident + * @param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate + * + * @return \Illuminate\Http\RedirectResponse + */ + public function editIncidentUpdateAction(Incident $incident, IncidentUpdate $incidentUpdate) + { + try { + $incidentUpdate = dispatch(new UpdateIncidentUpdateCommand( + $incidentUpdate, + Binput::get('status'), + Binput::get('message'), + $this->auth->user() + )); + } catch (ValidationException $e) { + return cachet_redirect('dashboard.incidents.updates.edit', ['incident' => $incident->id, 'incident_update' => $incidentUpdate->id]) + ->withInput(Binput::all()) + ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.updates.edit.failure'))) + ->withErrors($e->getMessageBag()); + } + + return cachet_redirect('dashboard.incidents.updates', ['incident' => $incident->id]) + ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.edit.success'))); } } diff --git a/app/Http/Routes/Dashboard/IncidentRoutes.php b/app/Http/Routes/Dashboard/IncidentRoutes.php index ed9294eb..e822247c 100644 --- a/app/Http/Routes/Dashboard/IncidentRoutes.php +++ b/app/Http/Routes/Dashboard/IncidentRoutes.php @@ -81,6 +81,15 @@ class IncidentRoutes 'as' => 'post:dashboard.incidents.updates.create', 'uses' => 'IncidentController@createIncidentUpdateAction', ]); + $router->get('{incident}/updates/{incident_update}', [ + 'as' => 'get:dashboard.incidents.updates.edit', + 'uses' => 'IncidentController@showEditIncidentUpdateAction', + ]); + $router->post('{incident}/updates/{incident_update}', [ + 'as' => 'post:dashboard.incidents.updates.edit', + 'uses' => 'IncidentController@editIncidentUpdateAction', + ]); + }); } } diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index 3fde4675..873955bb 100644 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -24,6 +24,16 @@ return [ 'updates' => [ 'title' => 'Incident updates for :incident', 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', + 'add' => [ + 'title' => 'Create new incident update', + 'success' => 'Your new incident update has been created.', + 'failure' => 'Something went wrong with the incident update.', + ], + 'edit' => [ + 'title' => 'Edit incident update', + 'success' => 'The incident update has been updated.', + 'failure' => 'Something went wrong updating the incident update', + ], ], 'add' => [ 'title' => 'Report an incident', @@ -39,11 +49,6 @@ return [ 'success' => 'The incident has been deleted and will not show on your status page.', 'failure' => 'The incident could not be deleted, please try again.', ], - 'update' => [ - 'title' => 'Create new incident update', - 'subtitle' => 'Add an update to :incident', - 'success' => 'Update added.', - ], // Incident templates 'templates' => [ diff --git a/resources/views/dashboard/incidents/updates/edit.blade.php b/resources/views/dashboard/incidents/updates/edit.blade.php new file mode 100644 index 00000000..8de47d59 --- /dev/null +++ b/resources/views/dashboard/incidents/updates/edit.blade.php @@ -0,0 +1,62 @@ +@extends('layout.dashboard') + +@section('content') +
+ + + {{ trans('dashboard.incidents.incidents') }} + + > {{ trans('dashboard.incidents.update.title') }} +
+
+
+
+ @include('dashboard.partials.errors') +

{{ trans('dashboard.incidents.updates.edit.title') }}

+
+ +
+
+
+ + + + +
+
+ +
+ +
+
+
+ +
+
+ + {{ trans('forms.cancel') }} +
+
+
+
+
+
+@stop diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php index b7f8d6fb..b19d645a 100644 --- a/resources/views/dashboard/incidents/updates/index.blade.php +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -9,7 +9,7 @@ {{ trans('dashboard.incidents.updates.title', ['incident' => Str::words($incident->name, 5)]) }} - {{ trans('dashboard.incidents.update.title') }} + {{ trans('dashboard.incidents.updates.add.title') }}
@@ -25,7 +25,9 @@

{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}

@endforeach From 0849bc65439f8767387bdecffd0b54c1029f56fa Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 17:45:13 +0100 Subject: [PATCH 05/11] Add link to edit IncidentUpdate to the front-end --- resources/views/single-incident.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/single-incident.blade.php b/resources/views/single-incident.blade.php index 912b6334..1c410f51 100644 --- a/resources/views/single-incident.blade.php +++ b/resources/views/single-incident.blade.php @@ -31,6 +31,11 @@
+ @if($current_user) + + @endif
{!! $update->formatted_message !!}
From 0af68e755f33969ad2dbc981e3ddc29bb3e62f3d Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 18:11:59 +0100 Subject: [PATCH 06/11] Re-align the breadcrumbs in the IncidentUpdates view templates --- .../dashboard/incidents/updates/add.blade.php | 5 +- .../incidents/updates/edit.blade.php | 5 +- .../incidents/updates/index.blade.php | 59 ++++++++++--------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/resources/views/dashboard/incidents/updates/add.blade.php b/resources/views/dashboard/incidents/updates/add.blade.php index 5fb9dc6a..7fe831fd 100644 --- a/resources/views/dashboard/incidents/updates/add.blade.php +++ b/resources/views/dashboard/incidents/updates/add.blade.php @@ -6,15 +6,14 @@
- {{ trans('dashboard.incidents.incidents') }} + {{ trans('dashboard.incidents.incidents') }} - > {{ trans('dashboard.incidents.update.title') }} + > {{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }} > {{ trans('dashboard.incidents.updates.add.title') }}
@include('dashboard.partials.errors') -

{!! trans('dashboard.incidents.update.subtitle', ['incident' => $incident->name]) !!}

diff --git a/resources/views/dashboard/incidents/updates/edit.blade.php b/resources/views/dashboard/incidents/updates/edit.blade.php index 8de47d59..a65e11ff 100644 --- a/resources/views/dashboard/incidents/updates/edit.blade.php +++ b/resources/views/dashboard/incidents/updates/edit.blade.php @@ -6,15 +6,14 @@
- {{ trans('dashboard.incidents.incidents') }} + {{ trans('dashboard.incidents.incidents') }} - > {{ trans('dashboard.incidents.update.title') }} + > {{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }} > {{ trans('dashboard.incidents.updates.edit.title') }}
@include('dashboard.partials.errors') -

{{ trans('dashboard.incidents.updates.edit.title') }}

diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php index b19d645a..997a0570 100644 --- a/resources/views/dashboard/incidents/updates/index.blade.php +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -1,37 +1,40 @@ @extends('layout.dashboard') @section('content') -
- @includeWhen(isset($sub_menu), 'dashboard.partials.sub-sidebar') -
-
- - {{ trans('dashboard.incidents.updates.title', ['incident' => Str::words($incident->name, 5)]) }} - - - {{ trans('dashboard.incidents.updates.add.title') }} - -
-
-
-
- @include('dashboard.partials.errors') +
+ + + {{ trans('dashboard.incidents.incidents') }} + + > {{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }} +
+
+ +
+
+ @include('dashboard.partials.errors') -
- @foreach($updates as $update) -
-
- {{ Str::words($update->message, 8) }} -

{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}

-
- +
+ @foreach($updates as $update) +
+
+ {{ Str::words($update->message, 8) }} +

{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}

+
+ - @endforeach
+ @endforeach
From 55f6ee7dc7c2bb9c7454b3003de4b16f97e3b905 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 18:30:43 +0100 Subject: [PATCH 07/11] Fix styleci violations --- app/Http/Controllers/Dashboard/IncidentController.php | 8 ++++---- app/Http/Routes/Dashboard/IncidentRoutes.php | 1 - app/Models/IncidentUpdate.php | 2 +- resources/lang/en/dashboard.php | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 5938f84c..0b9e9758 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -298,6 +298,7 @@ class IncidentController extends Controller public function showIncidentUpdates(Incident $incident) { $updates = IncidentUpdate::byIncident($incident)->orderBy('created_at', 'desc')->get(); + return View::make('dashboard.incidents.updates.index')->withIncident($incident)->withUpdates($updates); } @@ -340,11 +341,10 @@ class IncidentController extends Controller ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.updates.success'))); } - /** * Shows the edit incident view. * - * @param \CachetHQ\Cachet\Models\Incident $incident + * @param \CachetHQ\Cachet\Models\Incident $incident * @param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate * * @return \Illuminate\View\View @@ -357,9 +357,9 @@ class IncidentController extends Controller } /** - * Edit an incident. + * Edit an incident update. * - * @param \CachetHQ\Cachet\Models\Incident $incident + * @param \CachetHQ\Cachet\Models\Incident $incident * @param \CachetHQ\Cachet\Models\IncidentUpdate $incidentUpdate * * @return \Illuminate\Http\RedirectResponse diff --git a/app/Http/Routes/Dashboard/IncidentRoutes.php b/app/Http/Routes/Dashboard/IncidentRoutes.php index e822247c..3519cf49 100644 --- a/app/Http/Routes/Dashboard/IncidentRoutes.php +++ b/app/Http/Routes/Dashboard/IncidentRoutes.php @@ -89,7 +89,6 @@ class IncidentRoutes 'as' => 'post:dashboard.incidents.updates.edit', 'uses' => 'IncidentController@editIncidentUpdateAction', ]); - }); } } diff --git a/app/Models/IncidentUpdate.php b/app/Models/IncidentUpdate.php index 846b48a0..2a8bc194 100644 --- a/app/Models/IncidentUpdate.php +++ b/app/Models/IncidentUpdate.php @@ -78,7 +78,7 @@ class IncidentUpdate extends Model implements HasPresenter * Scope all by incident. * * @param \Illuminate\Database\Eloquent\Builder $query - * @param \CachetHQ\Cachet\Models\Incident $incident + * @param \CachetHQ\Cachet\Models\Incident $incident * * @return \Illuminate\Database\Eloquent\Builder */ diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index 873955bb..5d1e5a42 100644 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -24,7 +24,7 @@ return [ 'updates' => [ 'title' => 'Incident updates for :incident', 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', - 'add' => [ + 'add' => [ 'title' => 'Create new incident update', 'success' => 'Your new incident update has been created.', 'failure' => 'Something went wrong with the incident update.', From 5dc595d55ba6089bfddc61b8ba63296f9f61c2d0 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sat, 13 Jan 2018 18:51:21 +0100 Subject: [PATCH 08/11] Replace Inf with asterisk when using pluralization in touched translations @see https://github.com/CachetHQ/Cachet/pull/2868 --- resources/lang/en/dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index 5d1e5a42..a4894d3c 100644 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -23,7 +23,7 @@ return [ 'incident-templates' => 'Incident Templates', 'updates' => [ 'title' => 'Incident updates for :incident', - 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,Inf] Several Updates', + 'count' => '{0} Zero Updates|[1] One Update|[2] Two Updates|[3,*] Several Updates', 'add' => [ 'title' => 'Create new incident update', 'success' => 'Your new incident update has been created.', From 72b029e0e94201680c435a5546d033cd5bcfae19 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sun, 14 Jan 2018 22:09:00 +0100 Subject: [PATCH 09/11] Add a button to Manage Incident updates Also removed the link on the overview pages to re-align them with other components --- resources/lang/en/forms.php | 23 ++++++++++--------- .../views/dashboard/incidents/index.blade.php | 3 ++- .../incidents/updates/index.blade.php | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index b057b053..aacc8e03 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -224,17 +224,18 @@ return [ ], // Buttons - 'add' => 'Add', - 'save' => 'Save', - 'update' => 'Update', - 'create' => 'Create', - 'edit' => 'Edit', - 'delete' => 'Delete', - 'submit' => 'Submit', - 'cancel' => 'Cancel', - 'remove' => 'Remove', - 'invite' => 'Invite', - 'signup' => 'Sign Up', + 'add' => 'Add', + 'save' => 'Save', + 'update' => 'Update', + 'create' => 'Create', + 'edit' => 'Edit', + 'delete' => 'Delete', + 'submit' => 'Submit', + 'cancel' => 'Cancel', + 'remove' => 'Remove', + 'invite' => 'Invite', + 'signup' => 'Sign Up', + 'manage_updates' => 'Manage Updates', // Other 'optional' => '* Optional', diff --git a/resources/views/dashboard/incidents/index.blade.php b/resources/views/dashboard/incidents/index.blade.php index c11bdab9..78e62cf4 100644 --- a/resources/views/dashboard/incidents/index.blade.php +++ b/resources/views/dashboard/incidents/index.blade.php @@ -22,12 +22,13 @@ @foreach($incidents as $incident)
- {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }} + {{ $incident->name }} {{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }} @if($incident->message)

{{ Str::words($incident->message, 5) }}

@endif
diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php index 997a0570..5d0a41fa 100644 --- a/resources/views/dashboard/incidents/updates/index.blade.php +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -25,7 +25,7 @@ @foreach($updates as $update)
- {{ Str::words($update->message, 8) }} + {{ Str::words($update->message, 8) }}

{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}

From 1da6764b6359feedbdc5ae6e7386bc96d5ba7cd1 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sun, 14 Jan 2018 22:17:26 +0100 Subject: [PATCH 10/11] Fetch updates using the eloquent relationship instead of re-querying --- .../Controllers/Dashboard/IncidentController.php | 4 +--- app/Models/IncidentUpdate.php | 13 ------------- .../dashboard/incidents/updates/index.blade.php | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 0b9e9758..94494386 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -297,9 +297,7 @@ class IncidentController extends Controller */ public function showIncidentUpdates(Incident $incident) { - $updates = IncidentUpdate::byIncident($incident)->orderBy('created_at', 'desc')->get(); - - return View::make('dashboard.incidents.updates.index')->withIncident($incident)->withUpdates($updates); + return View::make('dashboard.incidents.updates.index')->withIncident($incident); } /** diff --git a/app/Models/IncidentUpdate.php b/app/Models/IncidentUpdate.php index 2a8bc194..c266d057 100644 --- a/app/Models/IncidentUpdate.php +++ b/app/Models/IncidentUpdate.php @@ -74,19 +74,6 @@ class IncidentUpdate extends Model implements HasPresenter 'user_id', ]; - /** - * Scope all by incident. - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param \CachetHQ\Cachet\Models\Incident $incident - * - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeByIncident(Builder $query, Incident $incident) - { - return $query->where('incident_id', '=', $incident->id); - } - /** * Get the incident relation. * diff --git a/resources/views/dashboard/incidents/updates/index.blade.php b/resources/views/dashboard/incidents/updates/index.blade.php index 5d0a41fa..cbc58b34 100644 --- a/resources/views/dashboard/incidents/updates/index.blade.php +++ b/resources/views/dashboard/incidents/updates/index.blade.php @@ -22,7 +22,7 @@ @include('dashboard.partials.errors')
- @foreach($updates as $update) + @foreach($incident->updates as $update)
{{ Str::words($update->message, 8) }} From fe90f1aa7dffe8baacfef5726f16c5163f0a4c42 Mon Sep 17 00:00:00 2001 From: Nico Stapelbroek Date: Sun, 14 Jan 2018 22:17:58 +0100 Subject: [PATCH 11/11] Remove indentation inside blade conditionals --- app/Models/IncidentUpdate.php | 1 - resources/views/single-incident.blade.php | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Models/IncidentUpdate.php b/app/Models/IncidentUpdate.php index c266d057..207e129e 100644 --- a/app/Models/IncidentUpdate.php +++ b/app/Models/IncidentUpdate.php @@ -14,7 +14,6 @@ namespace CachetHQ\Cachet\Models; use AltThree\Validator\ValidatingTrait; use CachetHQ\Cachet\Models\Traits\SortableTrait; use CachetHQ\Cachet\Presenters\IncidentUpdatePresenter; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use McCool\LaravelAutoPresenter\HasPresenter; diff --git a/resources/views/single-incident.blade.php b/resources/views/single-incident.blade.php index 1c410f51..519d5d83 100644 --- a/resources/views/single-incident.blade.php +++ b/resources/views/single-incident.blade.php @@ -32,9 +32,9 @@
@if($current_user) - + @endif
{!! $update->formatted_message !!}