Merge pull request #2867 from nstapelbroek/feature/2618-edit-incident-updates
Allow editing incident updates
This commit is contained in:
@@ -16,10 +16,12 @@ 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;
|
||||
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,9 +295,21 @@ class IncidentController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showIncidentUpdateAction(Incident $incident)
|
||||
public function showIncidentUpdates(Incident $incident)
|
||||
{
|
||||
return View::make('dashboard.incidents.update')->withIncident($incident);
|
||||
return View::make('dashboard.incidents.updates.index')->withIncident($incident);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.updates.add')->withIncident($incident);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,20 +322,63 @@ 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'),
|
||||
$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')))
|
||||
->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 update.
|
||||
*
|
||||
* @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')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +71,24 @@ 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',
|
||||
]);
|
||||
$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',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,20 @@ return [
|
||||
'logged' => '{0} There are no incidents, good work.|[1] You have logged one incident.|[2, Inf] You have reported <strong>:count</strong> 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 for :incident',
|
||||
'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.',
|
||||
'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',
|
||||
'success' => 'Incident added.',
|
||||
@@ -36,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 <strong>:incident</strong>',
|
||||
'success' => 'Update added.',
|
||||
],
|
||||
|
||||
// Incident templates
|
||||
'templates' => [
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
@foreach($incidents as $incident)
|
||||
<div class="row striped-list-item">
|
||||
<div class="col-xs-6">
|
||||
<i class="{{ $incident->icon }}"></i> <a href="{{ cachet_route('dashboard.incidents.edit', [$incident->id]) }}"><strong>{{ $incident->name }}</strong></a> <span class="badge badge-info">{{ trans_choice('dashboard.incidents.updates', $incident->updates()->count()) }}</span>
|
||||
<i class="{{ $incident->icon }}"></i> <strong>{{ $incident->name }}</strong> <span class="badge badge-info">{{ trans_choice('dashboard.incidents.updates.count', $incident->updates()->count()) }}</span>
|
||||
@if($incident->message)
|
||||
<p><small>{{ Str::words($incident->message, 5) }}</small></p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<a href="{{ cachet_route('dashboard.incidents.updates', [$incident->id]) }}" class="btn btn-info">{{ trans('forms.manage_updates') }}</a>
|
||||
<a href="{{ cachet_route('dashboard.incidents.edit', [$incident->id]) }}" class="btn btn-default">{{ trans('forms.edit') }}</a>
|
||||
<a href="{{ cachet_route('dashboard.incidents.updates', [$incident->id]) }}" class="btn btn-info">{{ trans('forms.update') }}</a>
|
||||
<a href="{{ cachet_route('dashboard.incidents.delete', [$incident->id], 'delete') }}" class="btn btn-danger confirm-action" data-method='DELETE'>{{ trans('forms.delete') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,15 +6,14 @@
|
||||
<i class="icon ion-navicon"></i>
|
||||
</div>
|
||||
<span class="uppercase">
|
||||
<i class="icon ion-android-alert"></i> {{ trans('dashboard.incidents.incidents') }}
|
||||
<i class="ion ion-ios-information-outline"></i> {{ trans('dashboard.incidents.incidents') }}
|
||||
</span>
|
||||
> <small>{{ trans('dashboard.incidents.update.title') }}</small>
|
||||
> <small>{{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }}</small> > <small>{{ trans('dashboard.incidents.updates.add.title') }}</small>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@include('dashboard.partials.errors')
|
||||
<p class="lead">{!! trans('dashboard.incidents.update.subtitle', ['incident' => $incident->name]) !!}</p>
|
||||
<form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
<fieldset>
|
||||
61
resources/views/dashboard/incidents/updates/edit.blade.php
Normal file
61
resources/views/dashboard/incidents/updates/edit.blade.php
Normal file
@@ -0,0 +1,61 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<div class="sidebar-toggler visible-xs">
|
||||
<i class="icon ion-navicon"></i>
|
||||
</div>
|
||||
<span class="uppercase">
|
||||
<i class="ion ion-ios-information-outline"></i> {{ trans('dashboard.incidents.incidents') }}
|
||||
</span>
|
||||
> <small>{{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }}</small> > <small>{{ trans('dashboard.incidents.updates.edit.title') }}</small>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@include('dashboard.partials.errors')
|
||||
<form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.incidents.status') }}</label><br>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="status" value="1" required {{ ($update->status == 1) ? "checked='checked'" : "" }}>
|
||||
<i class="icon ion-flag"></i>
|
||||
{{ trans('cachet.incidents.status')[1] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="status" value="2" required {{ ($update->status == 2) ? "checked='checked'" : "" }}>
|
||||
<i class="icon ion-alert-circled"></i>
|
||||
{{ trans('cachet.incidents.status')[2] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="status" value="3" required {{ ($update->status == 3) ? "checked='checked'" : "" }}>
|
||||
<i class="icon ion-eye"></i>
|
||||
{{ trans('cachet.incidents.status')[3] }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="status" value="4" required {{ ($update->status == 4) ? "checked='checked'" : "" }}>
|
||||
<i class="icon ion-checkmark"></i>
|
||||
{{ trans('cachet.incidents.status')[4] }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.incidents.message') }}</label>
|
||||
<div class="markdown-control">
|
||||
<textarea name="message" class="form-control autosize" rows="5" required>{{ $update->message }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button>
|
||||
<a class="btn btn-default" href="{{ cachet_route('dashboard.incidents') }}">{{ trans('forms.cancel') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
42
resources/views/dashboard/incidents/updates/index.blade.php
Normal file
42
resources/views/dashboard/incidents/updates/index.blade.php
Normal file
@@ -0,0 +1,42 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<div class="sidebar-toggler visible-xs">
|
||||
<i class="icon ion-navicon"></i>
|
||||
</div>
|
||||
<span class="uppercase">
|
||||
<i class="ion ion-ios-information-outline"></i> {{ trans('dashboard.incidents.incidents') }}
|
||||
</span>
|
||||
> <small>{{ trans('dashboard.incidents.updates.title', ['incident' => $incident->name]) }}</small>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="header sub-header">
|
||||
<a class="btn btn-md btn-success pull-right" href="{{ cachet_route('dashboard.incidents.updates.create', [$incident->id]) }}">
|
||||
{{ trans('dashboard.incidents.updates.add.title') }}
|
||||
</a>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@include('dashboard.partials.errors')
|
||||
|
||||
<div class="striped-list">
|
||||
@foreach($incident->updates as $update)
|
||||
<div class="row striped-list-item">
|
||||
<div class="col-xs-6">
|
||||
<strong>{{ Str::words($update->message, 8) }}</strong>
|
||||
<p><small>{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}</small></p>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<a href="{{ cachet_route('dashboard.incidents.updates.edit', ['incident' => $incident->id, 'incident_update' => $update]) }}" class="btn btn-default">
|
||||
{{ trans('forms.edit') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
@@ -31,6 +31,11 @@
|
||||
<div class="col-xs-10 col-xs-offset-2 col-sm-11 col-sm-offset-0">
|
||||
<div class="panel panel-message incident">
|
||||
<div class="panel-body">
|
||||
@if($current_user)
|
||||
<div class="pull-right btn-group">
|
||||
<a href="{{ cachet_route('dashboard.incidents.updates.edit', ['incident' => $incident, 'incident_update' => $update]) }}" class="btn btn-default">{{ trans('forms.edit') }}</a>
|
||||
</div>
|
||||
@endif
|
||||
<div class="markdown-body">
|
||||
{!! $update->formatted_message !!}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user