Skip to content

Commit

Permalink
Merge pull request #14831 from marcusmoore/chore/sc-23725/livewire3
Browse files Browse the repository at this point in the history
Updated Livewire to v3
  • Loading branch information
snipe authored Jun 27, 2024
2 parents f23a221 + 8a562f1 commit 54fb91c
Show file tree
Hide file tree
Showing 30 changed files with 21,039 additions and 267 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use Livewire\Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use Livewire\Component;

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Livewire/Importer.php → app/Livewire/Importer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use App\Models\CustomField;
use Livewire\Component;
Expand Down Expand Up @@ -59,7 +59,7 @@ class Importer extends Component
];

/**
* This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for
* This is used in resources/views/livewire.importer.blade.php, and we kinda shouldn't need to check for
* activeFile here, but there's some UI goofiness that allows this to crash out on some imports.
*
* @return string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
Expand All @@ -19,21 +19,11 @@ class OauthClients extends Component

public $authorizationError;

protected $clientRepository;
protected $tokenRepository;

public function __construct()
{
$this->clientRepository = app(ClientRepository::class);
$this->tokenRepository = app(TokenRepository::class);
parent::__construct();
}

public function render()
{
return view('livewire.oauth-clients', [
'clients' => $this->clientRepository->activeForUser(auth()->user()->id),
'authorized_tokens' => $this->tokenRepository->forUser(auth()->user()->id)->where('revoked', false),
'clients' => app(ClientRepository::class)->activeForUser(auth()->user()->id),
'authorized_tokens' => app(TokenRepository::class)->forUser(auth()->user()->id)->where('revoked', false),
]);
}

Expand All @@ -44,21 +34,21 @@ public function createClient(): void
'redirect' => 'required|url|max:255',
]);

$newClient = $this->clientRepository->create(
app(ClientRepository::class)->create(
auth()->user()->id,
$this->name,
$this->redirect,
);

$this->dispatchBrowserEvent('clientCreated');
$this->dispatch('clientCreated');
}

public function deleteClient(Client $clientId): void
{
// test for safety
// ->delete must be of type Client - thus the model binding
if ($clientId->user_id == auth()->user()->id) {
$this->clientRepository->delete($clientId);
app(ClientRepository::class)->delete($clientId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->user_id);
$this->authorizationError = 'You are not authorized to delete this client.';
Expand All @@ -67,9 +57,9 @@ public function deleteClient(Client $clientId): void

public function deleteToken($tokenId): void
{
$token = $this->tokenRepository->find($tokenId);
$token = app(TokenRepository::class)->find($tokenId);
if ($token->user_id == auth()->user()->id) {
$this->tokenRepository->revokeAccessToken($tokenId);
app(TokenRepository::class)->revokeAccessToken($tokenId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->user_id);
$this->authorizationError = 'You are not authorized to delete this token.';
Expand All @@ -83,7 +73,7 @@ public function editClient(Client $editClientId): void

$this->editClientId = $editClientId->id;

$this->dispatchBrowserEvent('editClient');
$this->dispatch('editClient');
}

public function updateClient(Client $editClientId): void
Expand All @@ -93,7 +83,7 @@ public function updateClient(Client $editClientId): void
'editRedirect' => 'required|url|max:255',
]);

$client = $this->clientRepository->find($editClientId->id);
$client = app(ClientRepository::class)->find($editClientId->id);
if ($client->user_id == auth()->user()->id) {
$client->name = $this->editName;
$client->redirect = $this->editRedirect;
Expand All @@ -103,7 +93,7 @@ public function updateClient(Client $editClientId): void
$this->authorizationError = 'You are not authorized to edit this client.';
}

$this->dispatchBrowserEvent('clientUpdated');
$this->dispatch('clientUpdated');

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
Expand All @@ -17,7 +17,7 @@ class PersonalAccessTokens extends Component
//this is just an annoying thing to make the modal input autofocus
public function autoFocusModalEvent(): void
{
$this->dispatchBrowserEvent('autoFocusModal');
$this->dispatch('autoFocusModal');
}

public function render()
Expand All @@ -42,7 +42,7 @@ public function createToken(): void

$this->newTokenString = $newToken->accessToken;

$this->dispatchBrowserEvent('tokenCreated', $newToken->accessToken);
$this->dispatch('tokenCreated', token: $newToken->accessToken);
}

public function deleteToken($tokenId): void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Livewire;
namespace App\Livewire;

use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
Expand All @@ -23,15 +23,17 @@ class SlackSettingsForm extends Component

public Setting $setting;

public $webhook_endpoint_rules;
public $save_button;

public $webhook_test;

public $webhook_endpoint_rules;
protected $rules = [
'webhook_endpoint' => 'required_with:webhook_channel|starts_with:http://,https://,ftp://,irc://,https://hooks.slack.com/services/|url|nullable',
'webhook_channel' => 'required_with:webhook_endpoint|starts_with:#|nullable',
'webhook_botname' => 'string|nullable',
];


public function mount() {
$this->webhook_text= [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"laravelcollective/html": "^6.2",
"league/csv": "^9.7",
"league/flysystem-aws-s3-v3": "^3.0",
"livewire/livewire": "^2.4",
"livewire/livewire": "^3.5",
"neitanod/forceutf8": "^2.0",
"nesbot/carbon": "^2.32",
"nunomaduro/collision": "^6.1",
Expand Down
37 changes: 20 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 54fb91c

Please sign in to comment.