Skip to content

Commit 8e48f60

Browse files
committed
In progress
1 parent 7e24e35 commit 8e48f60

25 files changed

+151
-13
lines changed

app/Bus/Commands/Incident/ReportIncidentCommand.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ final class ReportIncidentCommand
6262
*/
6363
public $notify;
6464

65+
/**
66+
* Whether to stick the incident on top.
67+
*
68+
* @var bool
69+
*/
70+
public $sticked;
71+
6572
/**
6673
* The date at which the incident occurred.
6774
*
@@ -96,6 +103,7 @@ final class ReportIncidentCommand
96103
'component_id' => 'int|required_with:component_status',
97104
'component_status' => 'int|min:1|max:4|required_with:component_id',
98105
'notify' => 'bool',
106+
'sticked' => 'bool',
99107
'incident_date' => 'string',
100108
'template' => 'string',
101109
];
@@ -110,13 +118,14 @@ final class ReportIncidentCommand
110118
* @param int $component_id
111119
* @param int $component_status
112120
* @param bool $notify
121+
* @param bool $sticked
113122
* @param string|null $incident_date
114123
* @param string|null $template
115124
* @param array|null $template_vars
116125
*
117126
* @return void
118127
*/
119-
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, array $template_vars = null)
128+
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $sticked, $incident_date, $template, array $template_vars = null)
120129
{
121130
$this->name = $name;
122131
$this->status = $status;
@@ -125,6 +134,7 @@ public function __construct($name, $status, $message, $visible, $component_id, $
125134
$this->component_id = $component_id;
126135
$this->component_status = $component_status;
127136
$this->notify = $notify;
137+
$this->sticked = $sticked;
128138
$this->incident_date = $incident_date;
129139
$this->template = $template;
130140
$this->template_vars = $template_vars;

app/Bus/Commands/Incident/UpdateIncidentCommand.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ final class UpdateIncidentCommand
7171
*/
7272
public $notify;
7373

74+
/**
75+
* Whether to stick the incident on top.
76+
*
77+
* @var bool
78+
*/
79+
public $sticked;
80+
7481
/**
7582
* The date that the incident occurred on.
7683
*
@@ -105,6 +112,7 @@ final class UpdateIncidentCommand
105112
'component_id' => 'int',
106113
'component_status' => 'int|min:1|max:4|required_with:component_id',
107114
'notify' => 'bool',
115+
'sticked' => 'bool',
108116
'template' => 'string',
109117
];
110118

@@ -119,13 +127,14 @@ final class UpdateIncidentCommand
119127
* @param int $component_id
120128
* @param int $component_status
121129
* @param bool $notify
130+
* @param bool $sticked
122131
* @param string|null $incident_date
123132
* @param string|null $template
124133
* @param array|null $template_vars
125134
*
126135
* @return void
127136
*/
128-
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, array $template_vars = null)
137+
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $sticked, $incident_date, $template, array $template_vars = null)
129138
{
130139
$this->incident = $incident;
131140
$this->name = $name;
@@ -135,6 +144,7 @@ public function __construct(Incident $incident, $name, $status, $message, $visib
135144
$this->component_id = $component_id;
136145
$this->component_status = $component_status;
137146
$this->notify = $notify;
147+
$this->sticked = $sticked;
138148
$this->incident_date = $incident_date;
139149
$this->template = $template;
140150
$this->template_vars = $template_vars;

app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -68,6 +68,7 @@ public function handle(ReportIncidentCommand $command)
6868
'name' => $command->name,
6969
'status' => $command->status,
7070
'visible' => $command->visible,
71+
'sticked' => $command->sticked,
7172
];
7273

7374
if ($command->template) {

app/Bus/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -54,6 +54,7 @@ public function handle(ReportMaintenanceCommand $command)
5454
'scheduled_at' => $scheduledAt,
5555
'status' => 0,
5656
'visible' => 1,
57+
'sticked' => 0,
5758
]);
5859

5960
$maintenanceEvent->notify = (bool) $command->notify;

app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -107,9 +107,11 @@ protected function filter(UpdateIncidentCommand $command)
107107
'status' => $command->status,
108108
'message' => $command->message,
109109
'visible' => $command->visible,
110+
'sticked' => $command->sticked,
110111
'component_id' => $command->component_id,
111112
'component_status' => $command->component_status,
112113
'notify' => $command->notify,
114+
'sticked' => $command->sticked,
113115
];
114116

115117
return array_filter($params, function ($val) {

app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*

app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*

app/Composers/StatusPageComposer.php

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public function compose(View $view)
5757
// Scheduled maintenance code.
5858
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
5959

60+
// Sticked incidents.
61+
$stickedIncidents = Incident::sticked()->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get();
62+
6063
// Component & Component Group lists.
6164
$usedComponentGroups = Component::enabled()->where('group_id', '>', 0)->groupBy('group_id')->pluck('group_id');
6265
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
@@ -65,6 +68,7 @@ public function compose(View $view)
6568
$view->with($status)
6669
->withComponentGroups($componentGroups)
6770
->withUngroupedComponents($ungroupedComponents)
71+
->withStickedIncidents($stickedIncidents);
6872
->withScheduledMaintenance($scheduledMaintenance);
6973
}
7074
}

app/Console/Commands/DemoSeederCommand.php

+15
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ protected function seedIncidents()
205205
'component_id' => 0,
206206
'scheduled_at' => null,
207207
'visible' => 1,
208+
'sticked' => 0,
208209
],
209210
[
210211
'name' => 'Awesome',
@@ -213,6 +214,7 @@ protected function seedIncidents()
213214
'component_id' => 0,
214215
'scheduled_at' => null,
215216
'visible' => 1,
217+
'sticked' => 0,
216218
],
217219
[
218220
'name' => 'Monitoring the fix',
@@ -221,6 +223,7 @@ protected function seedIncidents()
221223
'component_id' => 0,
222224
'scheduled_at' => null,
223225
'visible' => 1,
226+
'sticked' => 0,
224227
],
225228
[
226229
'name' => 'Update',
@@ -229,6 +232,7 @@ protected function seedIncidents()
229232
'component_id' => 0,
230233
'scheduled_at' => null,
231234
'visible' => 1,
235+
'sticked' => 0,
232236
],
233237
[
234238
'name' => 'Test Incident',
@@ -237,6 +241,7 @@ protected function seedIncidents()
237241
'component_id' => 0,
238242
'scheduled_at' => null,
239243
'visible' => 1,
244+
'sticked' => 0,
240245
],
241246
[
242247
'name' => 'Investigating the API',
@@ -245,6 +250,16 @@ protected function seedIncidents()
245250
'component_id' => 1,
246251
'scheduled_at' => null,
247252
'visible' => 1,
253+
'sticked' => 0,
254+
],
255+
[
256+
'name' => 'Sticked to the top',
257+
'message' => 'Will be forever hanged here.',
258+
'status' => 1,
259+
'component_id' => 1,
260+
'scheduled_at' => null,
261+
'visible' => 1,
262+
'sticked' => 1,
248263
],
249264
];
250265

app/Http/Controllers/Api/IncidentController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -75,6 +75,7 @@ public function postIncidents()
7575
Binput::get('component_id'),
7676
Binput::get('component_status'),
7777
Binput::get('notify', true),
78+
Binput::get('sticked', false),
7879
Binput::get('created_at'),
7980
Binput::get('template'),
8081
Binput::get('vars')
@@ -105,6 +106,7 @@ public function putIncident(Incident $incident)
105106
Binput::get('component_id'),
106107
Binput::get('component_status'),
107108
Binput::get('notify', true),
109+
Binput::get('sticked', false),
108110
Binput::get('created_at'),
109111
Binput::get('template'),
110112
Binput::get('vars')

app/Http/Controllers/Dashboard/IncidentController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -115,6 +115,7 @@ public function createIncidentAction()
115115
Binput::get('component_id'),
116116
Binput::get('component_status'),
117117
Binput::get('notify', false),
118+
Binput::get('sticked', false),
118119
Binput::get('created_at'),
119120
null,
120121
null
@@ -240,6 +241,7 @@ public function editIncidentAction(Incident $incident)
240241
Binput::get('component_id'),
241242
Binput::get('component_status'),
242243
Binput::get('notify', true),
244+
Binput::get('sticked', false),
243245
Binput::get('created_at'),
244246
null,
245247
null

app/Http/Controllers/StatusPageController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*

app/Models/Incident.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*
@@ -32,6 +32,7 @@ class Incident extends Model implements HasPresenter
3232
*/
3333
protected $casts = [
3434
'visible' => 'int',
35+
'sticked' => 'int',
3536
'scheduled_at' => 'date',
3637
'deleted_at' => 'date',
3738
];
@@ -46,6 +47,7 @@ class Incident extends Model implements HasPresenter
4647
'name',
4748
'status',
4849
'visible',
50+
'sticked',
4951
'message',
5052
'scheduled_at',
5153
'created_at',
@@ -62,6 +64,7 @@ class Incident extends Model implements HasPresenter
6264
'name' => 'required',
6365
'status' => 'required|int',
6466
'visible' => 'required|bool',
67+
'sticked' => 'required|bool',
6568
'message' => 'required',
6669
];
6770

@@ -76,6 +79,7 @@ class Incident extends Model implements HasPresenter
7679
'name',
7780
'status',
7881
'visible',
82+
'sticked',
7983
];
8084

8185
/**
@@ -88,6 +92,7 @@ class Incident extends Model implements HasPresenter
8892
'name',
8993
'status',
9094
'visible',
95+
'sticked',
9196
'message',
9297
];
9398

@@ -113,6 +118,18 @@ public function scopeVisible(Builder $query)
113118
return $query->where('visible', 1);
114119
}
115120

121+
/**
122+
* Finds all visible sticked.
123+
*
124+
* @param \Illuminate\Database\Eloquent\Builder $query
125+
*
126+
* @return \Illuminate\Database\Eloquent\Builder
127+
*/
128+
public function scopeSticked(Builder $query)
129+
{
130+
return $query->where('sticked', 1);
131+
}
132+
116133
/**
117134
* Finds all scheduled incidents (maintenance).
118135
*

app/Models/IncidentTemplate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*

app/Presenters/IncidentPresenter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//TODO analyze
33
/*
44
* This file is part of Cachet.
55
*

database/factories/ModelFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'message' => $faker->paragraph(),
4545
'status' => random_int(1, 4),
4646
'visible' => 1,
47+
'sticked' => 0,
4748
];
4849
});
4950

0 commit comments

Comments
 (0)