Skip to content

Commit

Permalink
Merge pull request #2884 from CachetHQ/edit-incident-component-status
Browse files Browse the repository at this point in the history
Edit incident component status
  • Loading branch information
jbrooksuk committed Jan 21, 2018
2 parents eade2aa + 5b1d9ef commit 529577b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 5 deletions.
26 changes: 21 additions & 5 deletions app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -55,10 +67,12 @@ final class CreateIncidentUpdateCommand
* @var string[]
*/
public $rules = [
'incident' => 'required',
'status' => 'required|int|min:1|max:4',
'message' => 'required|string',
'user' => 'required',
'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',
];

/**
Expand All @@ -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;
}
}
6 changes: 6 additions & 0 deletions app/Http/Controllers/Dashboard/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ public function createIncidentUpdateAction(Incident $incident)
$incident,
Binput::get('status'),
Binput::get('message'),
Binput::get('component_id'),
Binput::get('component_status'),
$this->auth->user()
));
} catch (ValidationException $e) {
Expand All @@ -348,6 +350,10 @@ public function createIncidentUpdateAction(Incident $incident)
->withErrors($e->getMessageBag());
}

if ($incident->component) {
$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')));
}
Expand Down
38 changes: 38 additions & 0 deletions resources/views/dashboard/incidents/updates/add.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,44 @@
{{ trans('cachet.incidents.status')[4] }}
</label>
</div>
@if($incident->component)
<div class="form-group hidden" id="component-status">
<input type="hidden" name="component_id" value="{{ $incident->component->id }}">
<div class="panel panel-default">
<div class="panel-body">
<div class="radio-items">
@foreach(trans('cachet.components.status') as $statusID => $status)
<div class="radio-inline">
<label>
<input type="radio" name="component_status" value="{{ $statusID }}">
{{ $status }}
</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
@endif
@if($incident->component)
<div class="form-group" id="component-status">
<div class="panel panel-default">
<div class="panel-heading"><strong>{{ $incident->component->name }}</strong></div>
<div class="panel-body">
<div class="radio-items">
@foreach(trans('cachet.components.status') as $statusID => $status)
<div class="radio-inline">
<label>
<input type="radio" name="component_status" value="{{ $statusID }}" {{ $incident->component->status == $statusID ? "checked='checked'" : "" }}>
{{ $status }}
</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
@endif
<div class="form-group">
<label>{{ trans('forms.incidents.message') }}</label>
<div class="markdown-control">
Expand Down
19 changes: 19 additions & 0 deletions resources/views/dashboard/incidents/updates/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@
{{ trans('cachet.incidents.status')[4] }}
</label>
</div>
@if($incident->component)
<div class="form-group" id="component-status">
<div class="panel panel-default">
<div class="panel-heading"><strong>{{ $incident->component->name }}</strong></div>
<div class="panel-body">
<div class="radio-items">
@foreach(trans('cachet.components.status') as $statusID => $status)
<div class="radio-inline">
<label>
<input type="radio" name="component_status" value="{{ $statusID }}" {{ $incident->component->status == $statusID ? "checked='checked'" : "" }}>
{{ $status }}
</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
@endif
<div class="form-group">
<label>{{ trans('forms.incidents.message') }}</label>
<div class="markdown-control">
Expand Down

0 comments on commit 529577b

Please sign in to comment.