feat: add deploy-only token permission

This commit is contained in:
Kael
2024-10-30 17:00:55 +11:00
parent 491b228580
commit d4d63ff273
3 changed files with 17 additions and 3 deletions

View File

@@ -12,10 +12,9 @@ class ApiTokens extends Component
public $tokens = [];
public bool $viewSensitiveData = false;
public bool $readOnly = true;
public bool $rootAccess = false;
public bool $triggerDeploy = false;
public array $permissions = ['read-only'];
@@ -62,12 +61,25 @@ class ApiTokens extends Component
$this->permissions = ['*'];
$this->readOnly = false;
$this->viewSensitiveData = false;
$this->triggerDeploy = false;
} else {
$this->readOnly = true;
$this->permissions = ['read-only'];
}
}
public function updatedTriggerDeploy()
{
if ($this->triggerDeploy) {
$this->permissions[] = 'trigger-deploy';
$this->permissions = array_diff($this->permissions, ['*']);
$this->rootAccess = false;
} else {
$this->permissions = array_diff($this->permissions, ['trigger-deploy']);
}
$this->makeSureOneIsSelected();
}
public function makeSureOneIsSelected()
{
if (count($this->permissions) == 0) {