Make sure end users know about the notification suppression when editing incidents

This commit is contained in:
Nico Stapelbroek
2018-01-21 14:14:03 +01:00
parent 53142e2c93
commit b4c721d042
6 changed files with 41 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ 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\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
use CachetHQ\Cachet\Integrations\Contracts\System;
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;
@@ -48,6 +49,13 @@ class IncidentController extends Controller
*/ */
protected $auth; protected $auth;
/**
* The system instance.
*
* @var \CachetHQ\Cachet\Integrations\Contracts\System
*/
protected $system;
/** /**
* Creates a new incident controller instance. * Creates a new incident controller instance.
* *
@@ -55,9 +63,10 @@ class IncidentController extends Controller
* *
* @return void * @return void
*/ */
public function __construct(Guard $auth) public function __construct(Guard $auth, System $system)
{ {
$this->auth = $auth; $this->auth = $auth;
$this->system = $system;
View::share('sub_title', trans('dashboard.incidents.title')); View::share('sub_title', trans('dashboard.incidents.title'));
} }
@@ -87,6 +96,7 @@ class IncidentController extends Controller
->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard')) ->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'))
->withComponentsInGroups(ComponentGroup::with('components')->get()) ->withComponentsInGroups(ComponentGroup::with('components')->get())
->withComponentsOutGroups(Component::where('group_id', '=', 0)->get()) ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get())
->withNotificationsEnabled($this->system->canNotifySubscribers())
->withIncidentTemplates(IncidentTemplate::all()); ->withIncidentTemplates(IncidentTemplate::all());
} }
@@ -225,7 +235,8 @@ class IncidentController extends Controller
->withPageTitle(trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard')) ->withPageTitle(trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'))
->withIncident($incident) ->withIncident($incident)
->withComponentsInGroups(ComponentGroup::with('components')->get()) ->withComponentsInGroups(ComponentGroup::with('components')->get())
->withComponentsOutGroups(Component::where('group_id', '=', 0)->get()); ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get())
->withNotificationsEnabled($this->system->canNotifySubscribers());
} }
/** /**
@@ -309,7 +320,9 @@ class IncidentController extends Controller
*/ */
public function showCreateIncidentUpdateAction(Incident $incident) public function showCreateIncidentUpdateAction(Incident $incident)
{ {
return View::make('dashboard.incidents.updates.add')->withIncident($incident); return View::make('dashboard.incidents.updates.add')
->withIncident($incident)
->withNotificationsEnabled($this->system->canNotifySubscribers());
} }
/** /**
@@ -351,7 +364,8 @@ class IncidentController extends Controller
{ {
return View::make('dashboard.incidents.updates.edit') return View::make('dashboard.incidents.updates.edit')
->withIncident($incident) ->withIncident($incident)
->withUpdate($incidentUpdate); ->withUpdate($incidentUpdate)
->withNotificationsEnabled($this->system->canNotifySubscribers());
} }
/** /**

View File

@@ -53,6 +53,7 @@ return [
'message-help' => 'You may also use Markdown.', 'message-help' => 'You may also use Markdown.',
'occurred_at' => 'When did this incident occur?', 'occurred_at' => 'When did this incident occur?',
'notify_subscribers' => 'Notify subscribers?', 'notify_subscribers' => 'Notify subscribers?',
'notify_disabled' => 'Due to scheduled maintenance, notifications about this incident or its components will be suppressed.',
'visibility' => 'Incident Visibility', 'visibility' => 'Incident Visibility',
'stick_status' => 'Stick Incident', 'stick_status' => 'Stick Incident',
'stickied' => 'Stickied', 'stickied' => 'Stickied',

View File

@@ -13,6 +13,11 @@
<div class="content-wrapper"> <div class="content-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@if(!$notifications_enabled)
<div class="alert alert-info" role="alert">
{{ trans('forms.incidents.notify_disabled') }}
</div>
@endif
@include('dashboard.partials.errors') @include('dashboard.partials.errors')
<report-incident inline-template> <report-incident inline-template>
<form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off"> <form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off">
@@ -115,6 +120,7 @@
<label>{{ trans('forms.incidents.occurred_at') }}</label> <small class="text-muted">{{ trans('forms.optional') }}</small> <label>{{ trans('forms.incidents.occurred_at') }}</label> <small class="text-muted">{{ trans('forms.optional') }}</small>
<input type="text" name="occurred_at" class="form-control" rel="datepicker-custom" data-date-format="YYYY-MM-DD HH:mm" placeholder="{{ trans('forms.optional') }}"> <input type="text" name="occurred_at" class="form-control" rel="datepicker-custom" data-date-format="YYYY-MM-DD HH:mm" placeholder="{{ trans('forms.optional') }}">
</div> </div>
@if($notifications_enabled)
<input type="hidden" name="notify" value="0"> <input type="hidden" name="notify" value="0">
<div class="checkbox"> <div class="checkbox">
<label> <label>
@@ -122,6 +128,7 @@
{{ trans('forms.incidents.notify_subscribers') }} {{ trans('forms.incidents.notify_subscribers') }}
</label> </label>
</div> </div>
@endif
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">

View File

@@ -13,6 +13,11 @@
<div class="content-wrapper"> <div class="content-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@if(!$notifications_enabled)
<div class="alert alert-info" role="alert">
{{ trans('forms.incidents.notify_disabled') }}
</div>
@endif
@include('dashboard.partials.errors') @include('dashboard.partials.errors')
<form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off"> <form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">

View File

@@ -13,6 +13,11 @@
<div class="content-wrapper"> <div class="content-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@if(!$notifications_enabled)
<div class="alert alert-info" role="alert">
{{ trans('forms.incidents.notify_disabled') }}
</div>
@endif
@include('dashboard.partials.errors') @include('dashboard.partials.errors')
<form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off"> <form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">

View File

@@ -13,6 +13,11 @@
<div class="content-wrapper"> <div class="content-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@if(!$notifications_enabled)
<div class="alert alert-info" role="alert">
{{ trans('forms.incidents.notify_disabled') }}
</div>
@endif
@include('dashboard.partials.errors') @include('dashboard.partials.errors')
<form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off"> <form class="form-vertical" name="IncidentUpdateForm" role="form" method="POST" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}">