From 20121b8989c0aec1822e8b70f5a31e6ae2d68913 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Mon, 5 Sep 2016 02:07:35 +0200 Subject: [PATCH] Rename var && fix form --- .../Incident/ReportIncidentCommand.php | 10 ++--- .../Incident/UpdateIncidentCommand.php | 10 ++--- .../Incident/ReportIncidentCommandHandler.php | 2 +- .../ReportMaintenanceCommandHandler.php | 2 +- .../Incident/UpdateIncidentCommandHandler.php | 2 +- app/Composers/Modules/StickedComposer.php | 41 ------------------- app/Console/Commands/DemoSeederCommand.php | 16 ++++---- .../Providers/ComposerServiceProvider.php | 4 +- .../Providers/ModuleServiceProvider.php | 2 +- .../Controllers/Api/IncidentController.php | 4 +- .../Dashboard/IncidentController.php | 4 +- app/Models/Incident.php | 16 ++++---- database/factories/ModelFactory.php | 2 +- ...00_AlterTableIncidentsAddStickedColumn.php | 8 ++-- resources/lang/en/cachet.php | 2 +- resources/lang/en/forms.php | 4 +- .../views/dashboard/incidents/add.blade.php | 6 +-- .../views/dashboard/incidents/edit.blade.php | 6 +-- .../views/partials/modules/sticked.blade.php | 8 ---- tests/Api/IncidentTest.php | 6 +-- .../Incident/ReportIncidentCommandTest.php | 4 +- .../Incident/UpdateIncidentCommandTest.php | 4 +- 22 files changed, 57 insertions(+), 106 deletions(-) delete mode 100644 app/Composers/Modules/StickedComposer.php delete mode 100644 resources/views/partials/modules/sticked.blade.php diff --git a/app/Bus/Commands/Incident/ReportIncidentCommand.php b/app/Bus/Commands/Incident/ReportIncidentCommand.php index c6a05413fd32..4963309b63f8 100644 --- a/app/Bus/Commands/Incident/ReportIncidentCommand.php +++ b/app/Bus/Commands/Incident/ReportIncidentCommand.php @@ -67,7 +67,7 @@ final class ReportIncidentCommand * * @var bool */ - public $sticked; + public $stickied; /** * The date at which the incident occurred. @@ -103,7 +103,7 @@ final class ReportIncidentCommand 'component_id' => 'int|required_with:component_status', 'component_status' => 'int|min:1|max:4|required_with:component_id', 'notify' => 'bool', - 'sticked' => 'bool', + 'stickied' => 'bool', 'incident_date' => 'string', 'template' => 'string', ]; @@ -118,14 +118,14 @@ final class ReportIncidentCommand * @param int $component_id * @param int $component_status * @param bool $notify - * @param bool $sticked + * @param bool $stickied * @param string|null $incident_date * @param string|null $template * @param array|null $template_vars * * @return void */ - public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $sticked, $incident_date, $template, array $template_vars = null) + public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $incident_date, $template, array $template_vars = null) { $this->name = $name; $this->status = $status; @@ -134,7 +134,7 @@ public function __construct($name, $status, $message, $visible, $component_id, $ $this->component_id = $component_id; $this->component_status = $component_status; $this->notify = $notify; - $this->sticked = $sticked; + $this->stickied = $stickied; $this->incident_date = $incident_date; $this->template = $template; $this->template_vars = $template_vars; diff --git a/app/Bus/Commands/Incident/UpdateIncidentCommand.php b/app/Bus/Commands/Incident/UpdateIncidentCommand.php index 811e61edff77..7f93afcdd227 100644 --- a/app/Bus/Commands/Incident/UpdateIncidentCommand.php +++ b/app/Bus/Commands/Incident/UpdateIncidentCommand.php @@ -76,7 +76,7 @@ final class UpdateIncidentCommand * * @var bool */ - public $sticked; + public $stickied; /** * The date that the incident occurred on. @@ -112,7 +112,7 @@ final class UpdateIncidentCommand 'component_id' => 'int', 'component_status' => 'int|min:1|max:4|required_with:component_id', 'notify' => 'bool', - 'sticked' => 'bool', + 'stickied' => 'bool', 'template' => 'string', ]; @@ -127,14 +127,14 @@ final class UpdateIncidentCommand * @param int $component_id * @param int $component_status * @param bool $notify - * @param bool $sticked + * @param bool $stickied * @param string|null $incident_date * @param string|null $template * @param array|null $template_vars * * @return void */ - public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $sticked, $incident_date, $template, array $template_vars = null) + public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $stickied, $incident_date, $template, array $template_vars = null) { $this->incident = $incident; $this->name = $name; @@ -144,7 +144,7 @@ public function __construct(Incident $incident, $name, $status, $message, $visib $this->component_id = $component_id; $this->component_status = $component_status; $this->notify = $notify; - $this->sticked = $sticked; + $this->stickied = $stickied; $this->incident_date = $incident_date; $this->template = $template; $this->template_vars = $template_vars; diff --git a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php b/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php index e3441c5e07bf..38fbaaffadeb 100644 --- a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php +++ b/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php @@ -68,7 +68,7 @@ public function handle(ReportIncidentCommand $command) 'name' => $command->name, 'status' => $command->status, 'visible' => $command->visible, - 'sticked' => $command->sticked, + 'stickied' => $command->stickied, ]; if ($command->template) { diff --git a/app/Bus/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php b/app/Bus/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php index ad47398ff10b..457aa7d95c34 100644 --- a/app/Bus/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php +++ b/app/Bus/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php @@ -54,7 +54,7 @@ public function handle(ReportMaintenanceCommand $command) 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ]); $maintenanceEvent->notify = (bool) $command->notify; diff --git a/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php b/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php index 0cb5593f315c..24af08894296 100644 --- a/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php +++ b/app/Bus/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php @@ -107,7 +107,7 @@ protected function filter(UpdateIncidentCommand $command) 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible, - 'sticked' => $command->sticked, + 'stickied' => $command->stickied, 'component_id' => $command->component_id, 'component_status' => $command->component_status, 'notify' => $command->notify, diff --git a/app/Composers/Modules/StickedComposer.php b/app/Composers/Modules/StickedComposer.php deleted file mode 100644 index fcbfbd7f1dcc..000000000000 --- a/app/Composers/Modules/StickedComposer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @author Connor S. Parks - * @author Antoine Girard - */ -class StickedComposer -{ - /** - * Index page view composer. - * - * @param \Illuminate\Contracts\View\View $view - * - * @return void - */ - public function compose(View $view) - { - $stickedIncidents = Incident::sticked()->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) { - return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->created_at)->toDateString(); - }); - $view->withStickedIncidents($stickedIncidents); - } -} diff --git a/app/Console/Commands/DemoSeederCommand.php b/app/Console/Commands/DemoSeederCommand.php index 9c72258c9d52..7067c5dd4af1 100644 --- a/app/Console/Commands/DemoSeederCommand.php +++ b/app/Console/Commands/DemoSeederCommand.php @@ -205,7 +205,7 @@ protected function seedIncidents() 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ 'name' => 'Awesome', @@ -214,7 +214,7 @@ protected function seedIncidents() 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ 'name' => 'Monitoring the fix', @@ -223,7 +223,7 @@ protected function seedIncidents() 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ 'name' => 'Update', @@ -232,7 +232,7 @@ protected function seedIncidents() 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ 'name' => 'Test Incident', @@ -241,7 +241,7 @@ protected function seedIncidents() 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ 'name' => 'Investigating the API', @@ -250,16 +250,16 @@ protected function seedIncidents() 'component_id' => 1, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ], [ - 'name' => 'Sticked to the top', + 'name' => 'Stickied to the top', 'message' => 'Will be forever hanged here.', 'status' => 1, 'component_id' => 1, 'scheduled_at' => null, 'visible' => 1, - 'sticked' => true, + 'stickied' => true, ], ]; diff --git a/app/Foundation/Providers/ComposerServiceProvider.php b/app/Foundation/Providers/ComposerServiceProvider.php index 1024c7c8eb7f..445d2e08a787 100644 --- a/app/Foundation/Providers/ComposerServiceProvider.php +++ b/app/Foundation/Providers/ComposerServiceProvider.php @@ -19,7 +19,7 @@ use CachetHQ\Cachet\Composers\Modules\MetricsComposer as MetricsModuleComposer; use CachetHQ\Cachet\Composers\Modules\ScheduledComposer as ScheduledModuleComposer; use CachetHQ\Cachet\Composers\Modules\StatusComposer as StatusModuleComposer; -use CachetHQ\Cachet\Composers\Modules\StickedComposer as StickedModuleComposer; +use CachetHQ\Cachet\Composers\Modules\StickiedComposer as StickiedModuleComposer; use CachetHQ\Cachet\Composers\Modules\TimelineComposer as TimelineModuleComposer; use CachetHQ\Cachet\Composers\ThemeComposer; use CachetHQ\Cachet\Composers\TimezoneLocaleComposer; @@ -44,7 +44,7 @@ public function boot(Factory $factory) $factory->composer('*', ModuleComposer::class); $factory->composer('partials.modules.components', ComponentsModuleComposer::class); $factory->composer('partials.modules.metrics', MetricsModuleComposer::class); - $factory->composer('partials.modules.sticked', StickedModuleComposer::class); + $factory->composer('partials.modules.stickied', StickiedModuleComposer::class); $factory->composer('partials.modules.scheduled', ScheduledModuleComposer::class); $factory->composer('partials.modules.status', StatusModuleComposer::class); $factory->composer('partials.modules.timeline', TimelineModuleComposer::class); diff --git a/app/Foundation/Providers/ModuleServiceProvider.php b/app/Foundation/Providers/ModuleServiceProvider.php index 89f0c2e4ccdc..87faea06656b 100644 --- a/app/Foundation/Providers/ModuleServiceProvider.php +++ b/app/Foundation/Providers/ModuleServiceProvider.php @@ -28,7 +28,7 @@ class ModuleServiceProvider extends ServiceProvider ['group' => 'status', 'partial' => 'partials.modules.status'], ['group' => 'components', 'partial' => 'partials.modules.components'], ['group' => 'metrics', 'partial' => 'partials.modules.metrics'], - ['group' => 'sticked', 'partial' => 'partials.modules.sticked'], + ['group' => 'stickied', 'partial' => 'partials.modules.stickied'], ['group' => 'scheduled', 'partial' => 'partials.modules.scheduled'], ['group' => 'timeline', 'partial' => 'partials.modules.timeline'], ], diff --git a/app/Http/Controllers/Api/IncidentController.php b/app/Http/Controllers/Api/IncidentController.php index e21097b8dc12..0d7c8993c682 100644 --- a/app/Http/Controllers/Api/IncidentController.php +++ b/app/Http/Controllers/Api/IncidentController.php @@ -75,7 +75,7 @@ public function postIncidents() Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), - Binput::get('sticked', false), + Binput::get('stickied', false), Binput::get('created_at'), Binput::get('template'), Binput::get('vars') @@ -106,7 +106,7 @@ public function putIncident(Incident $incident) Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), - Binput::get('sticked', false), + Binput::get('stickied', false), Binput::get('created_at'), Binput::get('template'), Binput::get('vars') diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 1fcd4a87c336..5a1284c86296 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -115,7 +115,7 @@ public function createIncidentAction() Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', false), - Binput::get('sticked', false), + Binput::get('stickied', false), Binput::get('created_at'), null, null @@ -241,7 +241,7 @@ public function editIncidentAction(Incident $incident) Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), - Binput::get('sticked', false), + Binput::get('stickied', false), Binput::get('created_at'), null, null diff --git a/app/Models/Incident.php b/app/Models/Incident.php index 74ee93a31739..82b235935c64 100644 --- a/app/Models/Incident.php +++ b/app/Models/Incident.php @@ -32,7 +32,7 @@ class Incident extends Model implements HasPresenter */ protected $casts = [ 'visible' => 'int', - 'sticked' => 'int', + 'stickied' => 'int', 'scheduled_at' => 'date', 'deleted_at' => 'date', ]; @@ -47,7 +47,7 @@ class Incident extends Model implements HasPresenter 'name', 'status', 'visible', - 'sticked', + 'stickied', 'message', 'scheduled_at', 'created_at', @@ -64,7 +64,7 @@ class Incident extends Model implements HasPresenter 'name' => 'required', 'status' => 'required|int', 'visible' => 'required|bool', - 'sticked' => 'bool', + 'stickied' => 'bool', 'message' => 'required', ]; @@ -79,7 +79,7 @@ class Incident extends Model implements HasPresenter 'name', 'status', 'visible', - 'sticked', + 'stickied', ]; /** @@ -92,7 +92,7 @@ class Incident extends Model implements HasPresenter 'name', 'status', 'visible', - 'sticked', + 'stickied', 'message', ]; @@ -119,15 +119,15 @@ public function scopeVisible(Builder $query) } /** - * Finds all sticked incidents. + * Finds all stickied incidents. * * @param \Illuminate\Database\Eloquent\Builder $query * * @return \Illuminate\Database\Eloquent\Builder */ - public function scopeSticked(Builder $query) + public function scopeStickied(Builder $query) { - return $query->where('sticked', true); + return $query->where('stickied', true); } /** diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 0aed361f39d0..7371c31b0665 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -44,7 +44,7 @@ 'message' => $faker->paragraph(), 'status' => random_int(1, 4), 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ]; }); diff --git a/database/migrations/2016_08_30_143400_AlterTableIncidentsAddStickedColumn.php b/database/migrations/2016_08_30_143400_AlterTableIncidentsAddStickedColumn.php index 49844a8018d8..056c21e1148f 100644 --- a/database/migrations/2016_08_30_143400_AlterTableIncidentsAddStickedColumn.php +++ b/database/migrations/2016_08_30_143400_AlterTableIncidentsAddStickedColumn.php @@ -13,7 +13,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AlterTableIncidentsAddStickedColumn extends Migration +class AlterTableIncidentsAddStickiedColumn extends Migration { /** * Run the migrations. @@ -21,9 +21,9 @@ class AlterTableIncidentsAddStickedColumn extends Migration public function up() { Schema::table('incidents', function (Blueprint $table) { - $table->boolean('sticked')->after('visible')->default(false); + $table->boolean('stickied')->after('visible')->default(false); - $table->index('sticked'); + $table->index('stickied'); }); } @@ -33,7 +33,7 @@ public function up() public function down() { Schema::table('incidents', function (Blueprint $table) { - $table->dropColumn('sticked'); + $table->dropColumn('stickied'); }); } } diff --git a/resources/lang/en/cachet.php b/resources/lang/en/cachet.php index 8edceeb18c74..e475b03cb052 100644 --- a/resources/lang/en/cachet.php +++ b/resources/lang/en/cachet.php @@ -28,7 +28,7 @@ 'incidents' => [ 'none' => 'No incidents reported', 'past' => 'Past Incidents', - 'sticked' => 'Sticked Incidents', + 'stickied' => 'Stickied Incidents', 'previous_week' => 'Previous Week', 'next_week' => 'Next Week', 'scheduled' => 'Scheduled Maintenance', diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index 9aad2e335d6c..c7dc61e57c69 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -54,8 +54,8 @@ 'notify_subscribers' => 'Notify subscribers?', 'visibility' => 'Incident Visibility', 'stick_status' => 'Stick Incident', - 'sticked' => 'Sticked', - 'not_sticked' => 'Not Sticked', + 'stickied' => 'Stickied', + 'not_stickied' => 'Not Stickied', 'public' => 'Viewable by public', 'logged_in_only' => 'Only visible to logged in users', 'templates' => [ diff --git a/resources/views/dashboard/incidents/add.blade.php b/resources/views/dashboard/incidents/add.blade.php index f56f60df391c..09c8c47eb813 100644 --- a/resources/views/dashboard/incidents/add.blade.php +++ b/resources/views/dashboard/incidents/add.blade.php @@ -64,9 +64,9 @@
- + +
@if(!$components_in_groups->isEmpty() || !$components_out_groups->isEmpty()) diff --git a/resources/views/dashboard/incidents/edit.blade.php b/resources/views/dashboard/incidents/edit.blade.php index 1894c5e4367d..30e15f52fbda 100644 --- a/resources/views/dashboard/incidents/edit.blade.php +++ b/resources/views/dashboard/incidents/edit.blade.php @@ -53,9 +53,9 @@
- + +
@if($incident->component) diff --git a/resources/views/partials/modules/sticked.blade.php b/resources/views/partials/modules/sticked.blade.php deleted file mode 100644 index 9fd8162124ef..000000000000 --- a/resources/views/partials/modules/sticked.blade.php +++ /dev/null @@ -1,8 +0,0 @@ -@if(!$sticked_incidents->isEmpty()) -
-

{{ trans('cachet.incidents.sticked') }}

- @foreach($sticked_incidents as $date => $incidents) - @include('partials.incidents', [compact($date), compact($incidents)]) - @endforeach -
-@endif diff --git a/tests/Api/IncidentTest.php b/tests/Api/IncidentTest.php index ec9b56282072..07eb5ef2d3fb 100644 --- a/tests/Api/IncidentTest.php +++ b/tests/Api/IncidentTest.php @@ -59,7 +59,7 @@ public function testPostIncident() 'message' => 'Lorem ipsum dolor sit amet', 'status' => 1, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ]); $this->seeJson(['name' => 'Foo']); $this->assertResponseOk(); @@ -78,7 +78,7 @@ public function testPostIncidentWithComponentStatus() 'component_id' => $component->id, 'component_status' => 1, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, ]); $this->seeJson(['name' => 'Foo']); $this->assertResponseOk(); @@ -93,7 +93,7 @@ public function testCreateIncidentWithTemplate() 'name' => 'Foo', 'status' => 1, 'visible' => 1, - 'sticked' => false, + 'stickied' => false, 'template' => $template->slug, 'vars' => [ 'name' => 'Foo', diff --git a/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php b/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php index 6419bc08c295..b9bce51c1f87 100644 --- a/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php +++ b/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php @@ -36,7 +36,7 @@ protected function getObjectAndParams() 'component_id' => 1, 'component_status' => 1, 'notify' => false, - 'sticked' => false, + 'stickied' => false, 'incident_date' => null, 'template' => null, 'template_vars' => null, @@ -50,7 +50,7 @@ protected function getObjectAndParams() $params['component_id'], $params['component_status'], $params['notify'], - $params['sticked'], + $params['stickied'], $params['incident_date'], $params['template'], $params['template_vars'] diff --git a/tests/Bus/Commands/Incident/UpdateIncidentCommandTest.php b/tests/Bus/Commands/Incident/UpdateIncidentCommandTest.php index f72107c62714..01d168cbaf1a 100644 --- a/tests/Bus/Commands/Incident/UpdateIncidentCommandTest.php +++ b/tests/Bus/Commands/Incident/UpdateIncidentCommandTest.php @@ -38,7 +38,7 @@ protected function getObjectAndParams() 'component_id' => 1, 'component_status' => 1, 'notify' => false, - 'sticked' => false, + 'stickied' => false, 'incident_date' => null, 'template' => null, 'template_vars' => null, @@ -53,7 +53,7 @@ protected function getObjectAndParams() $params['component_id'], $params['component_status'], $params['notify'], - $params['sticked'], + $params['stickied'], $params['incident_date'], $params['template'], $params['template_vars']