coolify/app/View/Components/Forms/Button.php
Andras Bacsai 0217e2b0c0 feat(server): improve private key and cloud link flows
Add server private key generation from the dropdown, prevent deleting
private keys that are still in use, and close cloud provider link modals
after successful linking.
2026-07-08 13:35:09 +02:00

46 lines
1.2 KiB
PHP

<?php
namespace App\View\Components\Forms;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Gate;
use Illuminate\View\Component;
class Button extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public bool $disabled = false,
public bool $authDisabled = false,
public bool $noStyle = false,
public ?string $modalId = null,
public string $defaultClass = 'button',
public bool $showLoadingIndicator = true,
public ?string $canGate = null,
public mixed $canResource = null,
public bool $autoDisable = true,
public ?string $tooltip = null,
) {
// Handle authorization-based disabling
if ($this->canGate && $this->canResource && $this->autoDisable) {
$hasPermission = Gate::allows($this->canGate, $this->canResource);
if (! $hasPermission) {
$this->disabled = true;
$this->authDisabled = true;
}
}
if ($this->noStyle) {
$this->defaultClass = '';
}
}
public function render(): View|Closure|string
{
return view('components.forms.button');
}
}