This commit is contained in:
Andras Bacsai 2023-06-08 11:43:14 +02:00
parent 9767ca47ff
commit 127d42d873
12 changed files with 34 additions and 19 deletions

View File

@ -31,7 +31,7 @@ public function dashboard()
}
public function settings()
{
if (auth()->user()->isAdmin()) {
if (auth()->user()->isInstanceAdmin()) {
$settings = InstanceSettings::get();
return view('settings.configuration', [
'settings' => $settings
@ -42,7 +42,7 @@ public function settings()
}
public function emails()
{
if (auth()->user()->isAdmin()) {
if (auth()->user()->isInstanceAdmin()) {
$settings = InstanceSettings::get();
return view('settings.emails', [
'settings' => $settings

View File

@ -8,8 +8,10 @@
class Member extends Component
{
public User $member;
public function render()
public function remove()
{
return view('livewire.team.member');
$this->member->teams()->detach(session('currentTeam'));
session(['currentTeam' => session('currentTeam')->fresh()]);
$this->emit('reloadWindow');
}
}

View File

@ -35,6 +35,11 @@ protected static function boot()
});
}
public function isAdmin()
{
ray(session('currentTeam'));
return session('currentTeam');
}
public function isInstanceAdmin()
{
$found_root_team = auth()->user()->teams->filter(function ($team) {
if ($team->id == 0) {
@ -49,10 +54,10 @@ public function teams()
return $this->belongsToMany(Team::class);
}
public function currentTeam()
{
return $this->belongsTo(Team::class);
}
// public function currentTeam()
// {
// return $this->belongsTo(Team::class);
// }
public function otherTeams()
{

View File

@ -27,6 +27,10 @@ public function run(): void
'name' => 'Normal Team',
'personal_team' => true,
]);
// $root_user->teams()->attach($root_user_personal_team);
// $root_user->teams()->attach($root_user_other_team);
// $normal_user->teams()->attach($normal_user_personal_team);
// $normal_user->teams()->attach($root_user_personal_team);
DB::table('team_user')->insert([
'team_id' => $root_user_personal_team->id,
'user_id' => $root_user->id,
@ -35,17 +39,14 @@ public function run(): void
DB::table('team_user')->insert([
'team_id' => $root_user_other_team->id,
'user_id' => $root_user->id,
'role' => 'admin',
]);
DB::table('team_user')->insert([
'team_id' => $normal_user_personal_team->id,
'user_id' => $normal_user->id,
'role' => 'admin',
]);
DB::table('team_user')->insert([
'team_id' => $root_user_personal_team->id,
'user_id' => $normal_user->id,
'role' => 'admin',
]);
}
}

View File

@ -32,7 +32,8 @@ class="w-4 h-4 stroke-current">
@endif
</span>
</label>
<select {{ $attributes }} wire:model.defer={{ $id }}>
<select {{ $attributes }}
@if ($id) name={{ $id }} wire:model.defer={{ $id }} @endif>
{{ $slot }}
</select>

View File

@ -41,7 +41,7 @@ class="{{ request()->is('project/*') || request()->is('projects') ? 'text-warnin
</li>
@if (auth()->user()->isAdmin())
@if (auth()->user()->isInstanceAdmin())
<li title="Command Center">
<a class="hover:bg-transparent" @if (!request()->is('command-center')) href="/command-center" @endif>
<svg xmlns="http://www.w3.org/2000/svg"

View File

@ -10,6 +10,5 @@
<button>Emails</button>
</a>
<div class="flex-1"></div>
<livewire:switch-team />
</nav>
</div>

View File

@ -5,7 +5,7 @@
<x-forms.button type="submit">
Save
</x-forms.button>
@if (auth()->user()->isAdmin())
@if (auth()->user()->isInstanceAdmin())
<x-forms.button wire:click='copySMTP'>
Copy from Instance Settings
</x-forms.button>

View File

@ -6,7 +6,7 @@
</div>
<x-forms.textarea id="value" rows="10" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
label="Private Key" required />
<x-forms.button type="submit" wire.click.prevent>
<x-forms.button type="submit">
Save Private Key
</x-forms.button>
</form>

View File

@ -1,5 +1,5 @@
<div class="w-64 -mt-9">
<x-forms.select id="selectedTeamId" class="pr-0 select-xs ">
<x-forms.select wire:model="selectedTeamId" class="pr-0 select-xs ">
<option value="default" disabled selected>Switch team</option>
@foreach (auth()->user()->teams as $team)
<option value="{{ $team->id }}">{{ $team->name }}</option>

View File

@ -3,8 +3,15 @@
<td>{{ $member->name }}</td>
<td>{{ $member->email }}</td>
<td>
{{-- @if (auth()->user()->isAdmin())
<x-forms.button wire:click="makeAdmin">Make admin</x-forms.button>
@else
<x-forms.button disabled>Make admin</x-forms.button>
@endif --}}
@if ($member->id !== auth()->user()->id)
<x-forms.button class="border-none">Remove</x-forms.button>
<x-forms.button wire:click="remove">Remove</x-forms.button>
@else
<x-forms.button disabled>Remove</x-forms.button>
@endif
</td>
</tr>

View File

@ -2,7 +2,7 @@
<x-settings.navbar />
<livewire:settings.configuration :settings="$settings" />
@if (auth()->user()->isAdmin())
@if (auth()->user()->isInstanceAdmin())
<livewire:force-upgrade />
@endif
</x-layout>