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]) }}

- {{ trans('forms.edit') }} + + {{ trans('forms.edit') }} +
@endforeach