Fix styling
This commit is contained in:
committed by
github-actions[bot]
parent
41fb6a1fc9
commit
d86274cc37
@@ -9,19 +9,24 @@ use Livewire\Component;
|
||||
class AdminView extends Component
|
||||
{
|
||||
public $users;
|
||||
public ?string $search = "";
|
||||
|
||||
public ?string $search = '';
|
||||
|
||||
public bool $lots_of_users = false;
|
||||
|
||||
private $number_of_users_to_show = 20;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (!isInstanceAdmin()) {
|
||||
if (! isInstanceAdmin()) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
$this->getUsers();
|
||||
}
|
||||
|
||||
public function submitSearch()
|
||||
{
|
||||
if ($this->search !== "") {
|
||||
if ($this->search !== '') {
|
||||
$this->users = User::where(function ($query) {
|
||||
$query->where('name', 'like', "%{$this->search}%")
|
||||
->orWhere('email', 'like', "%{$this->search}%");
|
||||
@@ -32,6 +37,7 @@ class AdminView extends Component
|
||||
$this->getUsers();
|
||||
}
|
||||
}
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
$users = User::where('id', '!=', auth()->id())->get();
|
||||
@@ -43,31 +49,33 @@ class AdminView extends Component
|
||||
$this->users = $users;
|
||||
}
|
||||
}
|
||||
|
||||
private function finalizeDeletion(User $user, Team $team)
|
||||
{
|
||||
$servers = $team->servers;
|
||||
foreach ($servers as $server) {
|
||||
$resources = $server->definedResources();
|
||||
foreach ($resources as $resource) {
|
||||
ray("Deleting resource: " . $resource->name);
|
||||
ray('Deleting resource: '.$resource->name);
|
||||
$resource->forceDelete();
|
||||
}
|
||||
ray("Deleting server: " . $server->name);
|
||||
ray('Deleting server: '.$server->name);
|
||||
$server->forceDelete();
|
||||
}
|
||||
|
||||
$projects = $team->projects;
|
||||
foreach ($projects as $project) {
|
||||
ray("Deleting project: " . $project->name);
|
||||
ray('Deleting project: '.$project->name);
|
||||
$project->forceDelete();
|
||||
}
|
||||
$team->members()->detach($user->id);
|
||||
ray('Deleting team: ' . $team->name);
|
||||
ray('Deleting team: '.$team->name);
|
||||
$team->delete();
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
if (!auth()->user()->isInstanceAdmin()) {
|
||||
if (! auth()->user()->isInstanceAdmin()) {
|
||||
return $this->dispatch('error', 'You are not authorized to delete users');
|
||||
}
|
||||
$user = User::find($id);
|
||||
@@ -78,12 +86,14 @@ class AdminView extends Component
|
||||
if ($team->id === 0) {
|
||||
if ($user_alone_in_team) {
|
||||
ray('user is alone in the root team, do nothing');
|
||||
|
||||
return $this->dispatch('error', 'User is alone in the root team, cannot delete');
|
||||
}
|
||||
}
|
||||
if ($user_alone_in_team) {
|
||||
ray('user is alone in the team');
|
||||
$this->finalizeDeletion($user, $team);
|
||||
|
||||
continue;
|
||||
}
|
||||
ray('user is not alone in the team');
|
||||
@@ -95,6 +105,7 @@ class AdminView extends Component
|
||||
if ($found_other_owner_or_admin) {
|
||||
ray('found other owner or admin');
|
||||
$team->members()->detach($user->id);
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$found_other_member_who_is_not_owner = $team->members->filter(function ($member) {
|
||||
@@ -110,6 +121,7 @@ class AdminView extends Component
|
||||
ray('found no other member who is not owner');
|
||||
$this->finalizeDeletion($user, $team);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -117,10 +129,11 @@ class AdminView extends Component
|
||||
$team->members()->detach($user->id);
|
||||
}
|
||||
}
|
||||
ray("Deleting user: " . $user->name);
|
||||
ray('Deleting user: '.$user->name);
|
||||
$user->delete();
|
||||
$this->getUsers();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.team.admin-view');
|
||||
|
||||
@@ -8,12 +8,14 @@ use Livewire\Component;
|
||||
class Create extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
public string|null $description = null;
|
||||
|
||||
public ?string $description = null;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|min:3|max:255',
|
||||
'description' => 'nullable|min:3|max:255',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'name' => 'name',
|
||||
'description' => 'description',
|
||||
@@ -30,6 +32,7 @@ class Create extends Component
|
||||
]);
|
||||
auth()->user()->teams()->attach($team, ['role' => 'admin']);
|
||||
refreshSession();
|
||||
|
||||
return redirect()->route('team.index');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
|
||||
@@ -10,22 +10,28 @@ use Livewire\Component;
|
||||
class Index extends Component
|
||||
{
|
||||
public $invitations = [];
|
||||
|
||||
public Team $team;
|
||||
|
||||
protected $rules = [
|
||||
'team.name' => 'required|min:3|max:255',
|
||||
'team.description' => 'nullable|min:3|max:255',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'team.name' => 'name',
|
||||
'team.description' => 'description',
|
||||
];
|
||||
public function mount() {
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->team = currentTeam();
|
||||
|
||||
if (auth()->user()->isAdminFromSession()) {
|
||||
$this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.team.index');
|
||||
@@ -60,6 +66,7 @@ class Index extends Component
|
||||
});
|
||||
|
||||
refreshSession();
|
||||
|
||||
return redirect()->route('team.index');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@ use Livewire\Component;
|
||||
class Invitations extends Component
|
||||
{
|
||||
public $invitations;
|
||||
|
||||
protected $listeners = ['refreshInvitations'];
|
||||
|
||||
public function deleteInvitation(int $invitation_id)
|
||||
{
|
||||
$initiation_found = TeamInvitation::find($invitation_id);
|
||||
if (!$initiation_found) {
|
||||
if (! $initiation_found) {
|
||||
return $this->dispatch('error', 'Invitation not found.');
|
||||
}
|
||||
$initiation_found->delete();
|
||||
|
||||
@@ -5,22 +5,23 @@ namespace App\Livewire\Team;
|
||||
use App\Models\TeamInvitation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
class InviteLink extends Component
|
||||
{
|
||||
public string $email;
|
||||
|
||||
public string $role = 'member';
|
||||
|
||||
protected $rules = [
|
||||
'email' => 'required|email',
|
||||
'role' => 'required|string',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->email = isDev() ? 'test3@example.com' : '';
|
||||
@@ -35,16 +36,17 @@ class InviteLink extends Component
|
||||
{
|
||||
$this->generate_invite_link(sendEmail: false);
|
||||
}
|
||||
|
||||
private function generate_invite_link(bool $sendEmail = false)
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
$member_emails = currentTeam()->members()->get()->pluck('email');
|
||||
if ($member_emails->contains($this->email)) {
|
||||
return handleError(livewire: $this, customErrorMessage: "$this->email is already a member of " . currentTeam()->name . ".");
|
||||
return handleError(livewire: $this, customErrorMessage: "$this->email is already a member of ".currentTeam()->name.'.');
|
||||
}
|
||||
$uuid = new Cuid2(32);
|
||||
$link = url('/') . config('constants.invitation.link.base_url') . $uuid;
|
||||
$link = url('/').config('constants.invitation.link.base_url').$uuid;
|
||||
$user = User::whereEmail($this->email)->first();
|
||||
|
||||
if (is_null($user)) {
|
||||
@@ -59,7 +61,7 @@ class InviteLink extends Component
|
||||
$link = route('auth.link', ['token' => $token]);
|
||||
}
|
||||
$invitation = TeamInvitation::whereEmail($this->email)->first();
|
||||
if (!is_null($invitation)) {
|
||||
if (! is_null($invitation)) {
|
||||
$invitationValid = $invitation->isValid();
|
||||
if ($invitationValid) {
|
||||
return handleError(livewire: $this, customErrorMessage: "Pending invitation already exists for $this->email.");
|
||||
@@ -82,10 +84,11 @@ class InviteLink extends Component
|
||||
'team' => currentTeam()->name,
|
||||
'invitation_link' => $link,
|
||||
]);
|
||||
$mail->subject('You have been invited to ' . currentTeam()->name . ' on ' . config('app.name') . '.');
|
||||
$mail->subject('You have been invited to '.currentTeam()->name.' on '.config('app.name').'.');
|
||||
send_user_an_email($mail, $this->email);
|
||||
$this->dispatch('success', 'Invitation sent via email.');
|
||||
$this->dispatch('refreshInvitations');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$this->dispatch('success', 'Invitation link generated.');
|
||||
@@ -96,6 +99,7 @@ class InviteLink extends Component
|
||||
if ($e->getCode() === '23505') {
|
||||
$error_message = 'Invitation already sent.';
|
||||
}
|
||||
|
||||
return handleError(error: $e, livewire: $this, customErrorMessage: $error_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class Member extends Component
|
||||
$this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'owner']);
|
||||
$this->dispatch('reloadWindow');
|
||||
}
|
||||
|
||||
public function makeReadonly()
|
||||
{
|
||||
$this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'member']);
|
||||
@@ -31,7 +32,7 @@ class Member extends Component
|
||||
{
|
||||
$this->member->teams()->detach(currentTeam());
|
||||
Cache::forget("team:{$this->member->id}");
|
||||
Cache::remember('team:' . $this->member->id, 3600, function () {
|
||||
Cache::remember('team:'.$this->member->id, 3600, function () {
|
||||
return $this->member->teams()->first();
|
||||
});
|
||||
$this->dispatch('reloadWindow');
|
||||
|
||||
@@ -8,11 +8,14 @@ use Livewire\Component;
|
||||
class Index extends Component
|
||||
{
|
||||
public $invitations = [];
|
||||
public function mount() {
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (auth()->user()->isAdminFromSession()) {
|
||||
$this->invitations = TeamInvitation::whereTeamId(currentTeam()->id)->get();
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.team.member.index');
|
||||
|
||||
@@ -8,13 +8,15 @@ use Livewire\Component;
|
||||
class Show extends Component
|
||||
{
|
||||
public $storage = null;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first();
|
||||
if (!$this->storage) {
|
||||
if (! $this->storage) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.storage.show');
|
||||
|
||||
Reference in New Issue
Block a user