Implement edit IncidentUpdate feature
This commit is contained in:
@@ -16,6 +16,7 @@ use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
|
|||||||
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
|
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
|
||||||
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
|
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
|
||||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
|
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
|
||||||
|
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
|
||||||
use CachetHQ\Cachet\Models\Component;
|
use CachetHQ\Cachet\Models\Component;
|
||||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||||
use CachetHQ\Cachet\Models\Incident;
|
use CachetHQ\Cachet\Models\Incident;
|
||||||
@@ -322,7 +323,7 @@ class IncidentController extends Controller
|
|||||||
public function createIncidentUpdateAction(Incident $incident)
|
public function createIncidentUpdateAction(Incident $incident)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$incident = dispatch(new CreateIncidentUpdateCommand(
|
$incidentUpdate = dispatch(new CreateIncidentUpdateCommand(
|
||||||
$incident,
|
$incident,
|
||||||
Binput::get('status'),
|
Binput::get('status'),
|
||||||
Binput::get('message'),
|
Binput::get('message'),
|
||||||
@@ -331,11 +332,55 @@ class IncidentController extends Controller
|
|||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id])
|
return cachet_redirect('dashboard.incidents.updates.create', ['id' => $incident->id])
|
||||||
->withInput(Binput::all())
|
->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());
|
->withErrors($e->getMessageBag());
|
||||||
}
|
}
|
||||||
|
|
||||||
return cachet_redirect('dashboard.incidents')
|
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')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,15 @@ class IncidentRoutes
|
|||||||
'as' => 'post:dashboard.incidents.updates.create',
|
'as' => 'post:dashboard.incidents.updates.create',
|
||||||
'uses' => 'IncidentController@createIncidentUpdateAction',
|
'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',
|
||||||
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ return [
|
|||||||
'updates' => [
|
'updates' => [
|
||||||
'title' => 'Incident updates for :incident',
|
'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,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' => [
|
'add' => [
|
||||||
'title' => 'Report an incident',
|
'title' => 'Report an incident',
|
||||||
@@ -39,11 +49,6 @@ return [
|
|||||||
'success' => 'The incident has been deleted and will not show on your status page.',
|
'success' => 'The incident has been deleted and will not show on your status page.',
|
||||||
'failure' => 'The incident could not be deleted, please try again.',
|
'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
|
// Incident templates
|
||||||
'templates' => [
|
'templates' => [
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
@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="icon ion-android-alert"></i> {{ trans('dashboard.incidents.incidents') }}
|
||||||
|
</span>
|
||||||
|
> <small>{{ trans('dashboard.incidents.update.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.updates.edit.title') }}</p>
|
||||||
|
<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
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<i class="ion ion-ios-information-outline"></i> {{ trans('dashboard.incidents.updates.title', ['incident' => Str::words($incident->name, 5)]) }}
|
<i class="ion ion-ios-information-outline"></i> {{ trans('dashboard.incidents.updates.title', ['incident' => Str::words($incident->name, 5)]) }}
|
||||||
</span>
|
</span>
|
||||||
<a class="btn btn-md btn-success pull-right" href="{{ cachet_route('dashboard.incidents.updates.create', [$incident->id]) }}">
|
<a class="btn btn-md btn-success pull-right" href="{{ cachet_route('dashboard.incidents.updates.create', [$incident->id]) }}">
|
||||||
{{ trans('dashboard.incidents.update.title') }}
|
{{ trans('dashboard.incidents.updates.add.title') }}
|
||||||
</a>
|
</a>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,7 +25,9 @@
|
|||||||
<p><small>{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}</small></p>
|
<p><small>{{ trans('cachet.incidents.posted', ['timestamp' => $update->created_at_diff]) }}</small></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 text-right">
|
<div class="col-xs-6 text-right">
|
||||||
<a href="{{ cachet_route('dashboard.incidents.edit', [$update->id]) }}" class="btn btn-default">{{ trans('forms.edit') }}</a>
|
<a href="{{ cachet_route('dashboard.incidents.updates.edit', ['incident' => $incident->id, 'incident_update' => $update->id]) }}" class="btn btn-default">
|
||||||
|
{{ trans('forms.edit') }}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
Reference in New Issue
Block a user