Implement visibility for the components groups. Closes #1892 Add functional test that asserts a guest can only see public items. * Fix tests not running due to hitting the Setup page. The missing `boostrap/cachet/testing.php` file is now generated the first time tests are ran. * Add a functional test that asserts logged in users can see all items. Add constants for possible values for the visible column/field of the ComponentGroup model. Code review changes. * Add API tests for component group visibility feature. * Implement the visibility hidden option for a component group. Fixes #1892. Add migration for the created_by column, in component_groups table. Add methods to the ComponentGroup and User models to be able to work with the created_by column. Hidden component groups are no longer displayed on the index page for loggedin users. Add functional test for the dashboard page. Save owner on create/edit component group. Update the API tests for Component group visibility feature. * Replace auth() usage with app(Guard::class). * Apply StyleCI fixes. * Drop the hidden visibility feature and fix all tests. Some code review fixes too. * Rename public to visible since it's a reserved keyword. Apply StyleCI fixes and correct typo. * Code review changes. * Tidy up component and component groups gathering. * Code review changes and StyleCI fixes. * Code review changes. * Remove extra whitespace * Remove useless method.
90 lines
1.9 KiB
PHP
90 lines
1.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Cachet.
|
|
*
|
|
* (c) Alt Three Services Limited
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace CachetHQ\Cachet\Bus\Commands\ComponentGroup;
|
|
|
|
use CachetHQ\Cachet\Models\ComponentGroup;
|
|
|
|
/**
|
|
* This is the update component group command.
|
|
*
|
|
* @author James Brooks <james@alt-three.com>
|
|
*/
|
|
final class UpdateComponentGroupCommand
|
|
{
|
|
/**
|
|
* The component group.
|
|
*
|
|
* @var \CachetHQ\Cachet\Models\ComponentGroup
|
|
*/
|
|
public $group;
|
|
|
|
/**
|
|
* The component group name.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $name;
|
|
|
|
/**
|
|
* The component group description.
|
|
*
|
|
* @var int
|
|
*/
|
|
public $order;
|
|
|
|
/**
|
|
* Is the component group collapsed?
|
|
*
|
|
* @var int
|
|
*/
|
|
public $collapsed;
|
|
|
|
/**
|
|
* Is the component visible to public?
|
|
*
|
|
* @var int
|
|
*/
|
|
public $visible;
|
|
|
|
/**
|
|
* The validation rules.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
public $rules = [
|
|
'name' => 'string',
|
|
'order' => 'int',
|
|
'collapsed' => 'int|between:0,3',
|
|
'visible' => 'bool',
|
|
];
|
|
|
|
/**
|
|
* Create a add component group command instance.
|
|
*
|
|
* @param \CachetHQ\Cachet\Models\ComponentGroup $group
|
|
* @param string $name
|
|
* @param int $order
|
|
* @param int $collapsed
|
|
* @param int $visible
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(ComponentGroup $group, $name, $order, $collapsed, $visible)
|
|
{
|
|
$this->group = $group;
|
|
$this->name = $name;
|
|
$this->order = (int) $order;
|
|
$this->collapsed = $collapsed;
|
|
$this->visible = (int) $visible;
|
|
}
|
|
}
|