Components can now be supplied meta data
This commit is contained in:
@@ -62,6 +62,13 @@ final class AddComponentCommand
|
||||
*/
|
||||
public $enabled;
|
||||
|
||||
/**
|
||||
* JSON meta data for the component.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $meta;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
@@ -75,22 +82,24 @@ final class AddComponentCommand
|
||||
'order' => 'nullable|int',
|
||||
'group_id' => 'nullable|int',
|
||||
'enabled' => 'nullable|bool',
|
||||
'meta' => 'nullable|string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new add component command instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param int $status
|
||||
* @param string $link
|
||||
* @param int $order
|
||||
* @param int $group_id
|
||||
* @param bool $enabled
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param int $status
|
||||
* @param string $link
|
||||
* @param int $order
|
||||
* @param int $group_id
|
||||
* @param bool $enabled
|
||||
* @param string|null $meta
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $description, $status, $link, $order, $group_id, $enabled)
|
||||
public function __construct($name, $description, $status, $link, $order, $group_id, $enabled, $meta)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
@@ -99,5 +108,6 @@ final class AddComponentCommand
|
||||
$this->order = $order;
|
||||
$this->group_id = $group_id;
|
||||
$this->enabled = $enabled;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,13 @@ final class UpdateComponentCommand
|
||||
*/
|
||||
public $enabled;
|
||||
|
||||
/**
|
||||
* JSON meta data for the component.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $meta;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
@@ -84,6 +91,7 @@ final class UpdateComponentCommand
|
||||
'order' => 'nullable|int',
|
||||
'group_id' => 'nullable|int',
|
||||
'enabled' => 'nullable|bool',
|
||||
'meta' => 'nullable|string',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -97,10 +105,11 @@ final class UpdateComponentCommand
|
||||
* @param int $order
|
||||
* @param int $group_id
|
||||
* @param bool $enabled
|
||||
* @param string|null $meta
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component, $name, $description, $status, $link, $order, $group_id, $enabled)
|
||||
public function __construct(Component $component, $name, $description, $status, $link, $order, $group_id, $enabled, $meta)
|
||||
{
|
||||
$this->component = $component;
|
||||
$this->name = $name;
|
||||
@@ -110,5 +119,6 @@ final class UpdateComponentCommand
|
||||
$this->order = $order;
|
||||
$this->group_id = $group_id;
|
||||
$this->enabled = $enabled;
|
||||
$this->meta = $meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class AddComponentCommandHandler
|
||||
'enabled' => $command->enabled,
|
||||
'order' => $command->order,
|
||||
'group_id' => $command->group_id,
|
||||
'meta' => $command->meta,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
|
||||
@@ -56,6 +56,7 @@ class UpdateComponentCommandHandler
|
||||
'enabled' => $command->enabled,
|
||||
'order' => $command->order,
|
||||
'group_id' => $command->group_id,
|
||||
'meta' => $command->meta,
|
||||
];
|
||||
|
||||
return array_filter($params, function ($val) {
|
||||
|
||||
@@ -100,6 +100,7 @@ class ReportIncidentCommandHandler
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ class ComponentController extends AbstractApiController
|
||||
Binput::get('link'),
|
||||
Binput::get('order'),
|
||||
Binput::get('group_id'),
|
||||
(bool) Binput::get('enabled', true)
|
||||
(bool) Binput::get('enabled', true),
|
||||
Binput::get('meta', null)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
@@ -118,7 +119,8 @@ class ComponentController extends AbstractApiController
|
||||
Binput::get('link'),
|
||||
Binput::get('order'),
|
||||
Binput::get('group_id'),
|
||||
(bool) Binput::get('enabled', true)
|
||||
(bool) Binput::get('enabled', true),
|
||||
Binput::get('meta', null)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
|
||||
@@ -134,7 +134,8 @@ class ComponentController extends Controller
|
||||
$componentData['link'],
|
||||
$componentData['order'],
|
||||
$componentData['group_id'],
|
||||
$componentData['enabled']
|
||||
$componentData['enabled'],
|
||||
null // Meta data cannot be supplied through the dashboard yet.
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('dashboard.components.edit', [$component->id])
|
||||
@@ -187,7 +188,8 @@ class ComponentController extends Controller
|
||||
$componentData['link'],
|
||||
$componentData['order'],
|
||||
$componentData['group_id'],
|
||||
$componentData['enabled']
|
||||
$componentData['enabled'],
|
||||
null // Meta data cannot be supplied through the dashboard yet.
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('dashboard.components.create')
|
||||
|
||||
@@ -35,6 +35,7 @@ class Component extends Model implements HasPresenter
|
||||
'description' => '',
|
||||
'link' => '',
|
||||
'enabled' => true,
|
||||
'meta' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -50,6 +51,7 @@ class Component extends Model implements HasPresenter
|
||||
'link' => 'string',
|
||||
'group_id' => 'int',
|
||||
'enabled' => 'bool',
|
||||
'meta' => 'json',
|
||||
'deleted_at' => 'date',
|
||||
];
|
||||
|
||||
@@ -67,6 +69,7 @@ class Component extends Model implements HasPresenter
|
||||
'order',
|
||||
'group_id',
|
||||
'enabled',
|
||||
'meta',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user