Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
388 stars 48 forks source link

[Feature] Adjust fields of standard components #185

Closed pozylon closed 6 months ago

pozylon commented 7 months ago

For our needs we now had to add a "Button customized" component taking a select of "primary", "secondary" and "tertiary". Issue is we can still see the "Button" in every Layout Builder where as we don't want to allow the use of that Button, they should use "Button customized" instead.

Standard components can not be adjusted through the "Layout Components" and can't be hidden either

pozylon commented 7 months ago

related to https://github.com/Cockpit-HQ/Cockpit/issues/179 but it's not quite the same

aheinze commented 7 months ago

a quick fix regarding the unwanted standard components:

in /config/bootstrap.php:

<?php

$app->on('layout.components.collect', function($components) {

    foreach (array_keys($components->getArrayCopy()) as $component) {

        //disable specific components
        if (in_array($component, ['button'])) {
            unset($components[$component]);
        }
    }
});
aheinze commented 7 months ago

For the next version I plan a setting in the pages addon for allowed components that can be used in the layout page type. Would that help you?

pozylon commented 6 months ago

That is amazing, thank you!