Fix coding style

This commit is contained in:
brufdev
2025-04-17 11:52:55 +01:00
parent bdb142c22a
commit a78877ecc6
9 changed files with 17 additions and 4 deletions
+1
View File
@@ -61,6 +61,7 @@ final readonly class CreateVaultNode
// Save node to disk
$nodePath = new GetPathFromVaultNode()->handle($node);
if ($node->is_file) {
Storage::disk('local')->put($nodePath, $attributes['content'] ?? '');
} else {
@@ -14,6 +14,7 @@ final readonly class DeleteCollaborationInvite
{
$vault->collaborators()->detach($user);
$notifications = $user->notifications()->where('type', CollaborationInvited::class)->get();
foreach ($notifications as $notification) {
if ($notification->data['vault_id'] === $vault->id) {
$notification->delete();
+1
View File
@@ -44,6 +44,7 @@ final readonly class DeleteVault
DB::commit();
} catch (Throwable) {
DB::rollBack();
throw new Exception(__('Something went wrong'));
}
+3
View File
@@ -21,10 +21,13 @@ final readonly class DeleteVaultNode
{
try {
DB::beginTransaction();
$deletedNodes = $this->deleteFromDatabase($node);
DB::commit();
} catch (Throwable) {
DB::rollBack();
throw new Exception(__('Something went wrong'));
}
+1
View File
@@ -26,6 +26,7 @@ final readonly class ExportVault
}
Storage::disk('local')->put($relativePath, '');
if ($zip->open($path, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
throw new Exception(__('Something went wrong'));
}
+4 -2
View File
@@ -13,10 +13,10 @@ final readonly class ProcessImportedVault
{
public function handle(string $fileName, string $filePath): void
{
$nodeIds = ['.' => null];
$vaultName = pathinfo($fileName, PATHINFO_FILENAME);
/** @var User $currentUser */
$currentUser = auth()->user();
$nodeIds = ['.' => null];
$vaultName = pathinfo($fileName, PATHINFO_FILENAME);
$vault = new CreateVault()->handle($currentUser, [
'name' => $vaultName,
]);
@@ -24,6 +24,7 @@ final readonly class ProcessImportedVault
// Create vault nodes with valid zip files and folders
$zip = new ZipArchive();
$zip->open($filePath);
for ($i = 0, $zipCount = $zip->count(); $i < $zipCount; $i++) {
$entryName = $zip->getNameIndex($i);
@@ -62,6 +63,7 @@ final readonly class ProcessImportedVault
$attributes['content'] = (string) $zip->getFromIndex($i);
}
$node = new CreateVaultNode()->handle($vault, $attributes);
if (!array_key_exists($entryDirName, $nodeIds)) {
-1
View File
@@ -50,7 +50,6 @@ final readonly class ProcessVaultNodeLinks
*/
$fullPath = $node->ancestorsAndSelf()->get()->last()->full_path;
$path = new ResolveTwoPaths()->handle($fullPath, $link['path']);
$destinationNode = new GetVaultNodeFromPath()->handle($node->vault_id, $path);
if (is_null($destinationNode)) {
+2
View File
@@ -34,6 +34,7 @@ final class UserMenu extends Component
public function editProfile(): void
{
$this->profileForm->update();
$this->dispatch('close-modal');
$this->dispatch('toast', message: __('Profile updated'), type: 'success');
}
@@ -41,6 +42,7 @@ final class UserMenu extends Component
public function editPassword(): void
{
$this->passwordForm->update();
$this->dispatch('close-modal');
$this->dispatch('toast', message: __('Password updated'), type: 'success');
}
+4 -1
View File
@@ -30,13 +30,16 @@ final class ImportVault extends Component
public function updatedFile(): void
{
$this->validate();
/** @var TemporaryUploadedFile $file */
$file = $this->file;
$fileName = $file->getClientOriginalName();
$filePath = $file->getRealPath();
new ProcessImportedVault()->handle($fileName, $filePath);
$this->dispatch('vault-imported');
$this->closeModal();
$this->dispatch('vault-imported');
$this->dispatch('toast', message: __('Vault imported'), type: 'success');
}