mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-16 20:49:28 +00:00
chore: Refactor API Tokens component to use isApiEnabled flag
This commit is contained in:
@@ -17,18 +17,16 @@ class ApiTokens extends Component
|
||||
|
||||
public array $permissions = ['read-only'];
|
||||
|
||||
public $instanceSettings;
|
||||
public $isApiEnabled;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.security.api-tokens', [
|
||||
'instanceSettings' => $this->instanceSettings,
|
||||
]);
|
||||
return view('livewire.security.api-tokens');
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->instanceSettings = InstanceSettings::get();
|
||||
$this->isApiEnabled = InstanceSettings::get()->is_api_enabled;
|
||||
$this->tokens = auth()->user()->tokens->sortByDesc('created_at');
|
||||
}
|
||||
|
||||
|
||||
@@ -5,21 +5,22 @@
|
||||
<x-security.navbar />
|
||||
<div class="pb-4">
|
||||
<h2>API Tokens</h2>
|
||||
@if (!$instanceSettings->is_api_enabled)
|
||||
<strong>API is disabled. If you want to use the API, please enable it in the Coolify Instance Settings.</strong>
|
||||
@if (!$isApiEnabled)
|
||||
<div>API is disabled. If you want to use the API, please enable it in the Settings menu.</div>
|
||||
@else
|
||||
<div>Tokens are created with the current team as scope. You will only have access to this team's resources.
|
||||
</div>
|
||||
</div>
|
||||
<h3>New Token</h3>
|
||||
<form class="flex flex-col gap-2 pt-4" wire:submit='addNewToken'>
|
||||
<div class="flex items-end gap-2">
|
||||
<div class="flex gap-2 items-end">
|
||||
<x-forms.input required id="description" label="Description" />
|
||||
<x-forms.button type="submit">Create New Token</x-forms.button>
|
||||
</div>
|
||||
<div class="flex">
|
||||
Permissions
|
||||
<x-helper class="px-1" helper="These permissions will be granted to the token." /><span class="pr-1">:</span>
|
||||
<x-helper class="px-1" helper="These permissions will be granted to the token." /><span
|
||||
class="pr-1">:</span>
|
||||
<div class="flex gap-1 font-bold dark:text-white">
|
||||
@if ($permissions)
|
||||
@foreach ($permissions as $permission)
|
||||
@@ -59,7 +60,15 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<x-modal-confirmation title="Confirm API Token Revocation?" isErrorButton buttonTitle="Revoke token" submitAction="revoke({{ data_get($token, 'id') }})" :actions="['This API Token will be revoked and permanently deleted.', 'Any API call made with this token will fail.']" confirmationText="{{ $token->name }}" confirmationLabel="Please confirm the execution of the actions by entering the API Token Description below" shortConfirmationLabel="API Token Description" :confirmWithPassword="false" step2ButtonText="Revoke API Token" />
|
||||
<x-modal-confirmation title="Confirm API Token Revocation?" isErrorButton buttonTitle="Revoke token"
|
||||
submitAction="revoke({{ data_get($token, 'id') }})" :actions="[
|
||||
'This API Token will be revoked and permanently deleted.',
|
||||
'Any API call made with this token will fail.',
|
||||
]"
|
||||
confirmationText="{{ $token->name }}"
|
||||
confirmationLabel="Please confirm the execution of the actions by entering the API Token Description below"
|
||||
shortConfirmationLabel="API Token Description" :confirmWithPassword="false"
|
||||
step2ButtonText="Revoke API Token" />
|
||||
</div>
|
||||
@empty
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user