From 9e06f2d17fdcdb709a9feada88f2ab7088459f08 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 11 Jul 2024 13:22:10 -0700 Subject: [PATCH 01/19] Remove commented code --- app/Livewire/Importer.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index e164af36d6..1ffdd941fe 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -161,10 +161,6 @@ class Importer extends Component } } - public function boot() { // FIXME - delete or undelete. - ///////$this->activeFile = null; // I do *not* understand why I have to do this, but, well, whatever. - } - public function mount() { From 9793016603cb35524e3e421edf0fe4044e6a42e3 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 11 Jul 2024 13:32:16 -0700 Subject: [PATCH 02/19] Remove unneeded AuthorizesRequests --- app/Livewire/Importer.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 1ffdd941fe..71637f61e3 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -3,18 +3,12 @@ namespace App\Livewire; use App\Models\CustomField; -use Livewire\Component; - use App\Models\Import; use Illuminate\Support\Facades\Storage; - -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; - +use Livewire\Component; class Importer extends Component { - use AuthorizesRequests; - public $files; public $progress; //upload progress - '-1' means don't show @@ -75,8 +69,6 @@ class Importer extends Component } - - private function getColumns($type) { switch ($type) { @@ -161,7 +153,6 @@ class Importer extends Component } } - public function mount() { $this->authorize('import'); From 256e989ba113650fbe5624bc00735e9329a2795d Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 15 Jul 2024 15:49:18 -0700 Subject: [PATCH 03/19] Add test for importer --- database/factories/UserFactory.php | 5 +++++ tests/Feature/Livewire/ImporterTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/Feature/Livewire/ImporterTest.php diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 5c885666df..10bb22e4eb 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -296,6 +296,11 @@ class UserFactory extends Factory return $this->appendPermission(['reports.view' => '1']); } + public function canImport() + { + return $this->appendPermission(['import' => '1']); + } + private function appendPermission(array $permission) { return $this->state(function ($currentState) use ($permission) { diff --git a/tests/Feature/Livewire/ImporterTest.php b/tests/Feature/Livewire/ImporterTest.php new file mode 100644 index 0000000000..b8af8f9bc0 --- /dev/null +++ b/tests/Feature/Livewire/ImporterTest.php @@ -0,0 +1,25 @@ +canImport()->create()) + ->test(Importer::class) + ->assertStatus(200); + } + + public function testRequiresPermission() + { + Livewire::actingAs(User::factory()->create()) + ->test(Importer::class) + ->assertStatus(403); + } +} From c8dad528a8d5244cf01111523dfcadd58eb5ada1 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 15 Jul 2024 16:15:58 -0700 Subject: [PATCH 04/19] Migrate a couple items out of mount --- app/Livewire/Importer.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 71637f61e3..4731a3c53a 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -11,9 +11,9 @@ class Importer extends Component { public $files; - public $progress; //upload progress - '-1' means don't show + public $progress = -1; //upload progress - '-1' means don't show public $progress_message; - public $progress_bar_class; + public $progress_bar_class = 'progress-bar-warning'; public $message; //status/error message? public $message_type; //success/error? @@ -156,8 +156,6 @@ class Importer extends Component public function mount() { $this->authorize('import'); - $this->progress = -1; // '-1' means 'don't show the progressbar' - $this->progress_bar_class = 'progress-bar-warning'; $this->importTypes = [ 'asset' => trans('general.assets'), 'accessory' => trans('general.accessories'), From 017530ba4ba45f96d77cb27dd85e724b0d3783e7 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 16 Jul 2024 12:02:50 -0700 Subject: [PATCH 05/19] Make updating hook more specific --- app/Livewire/Importer.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 4731a3c53a..1cbe0825b2 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -107,9 +107,9 @@ class Importer extends Component return $results; } - public function updating($name, $new_import_type) + public function updatingActiveFile($value, $propertyKey) { - if ($name == "activeFile.import_type") { + if ($propertyKey == "import_type") { // go through each header, find a matching field to try and map it to. foreach ($this->activeFile->header_row as $i => $header) { @@ -117,7 +117,7 @@ class Importer extends Component if (array_key_exists($i, $this->field_map)) { // yes, we do. Is it valid for this type of import? // (e.g. the import type might have been changed...?) - if (array_key_exists($this->field_map[$i], $this->columnOptions[$new_import_type])) { + if (array_key_exists($this->field_map[$i], $this->columnOptions[$value])) { //yes, this key *is* valid. Continue on to the next field. continue; } else { @@ -127,9 +127,9 @@ class Importer extends Component } // TODO - strictly speaking, this isn't necessary here I don't think. } // first, check for exact matches - foreach ($this->columnOptions[$new_import_type] as $value => $text) { + foreach ($this->columnOptions[$value] as $v => $text) { if (strcasecmp($text, $header) === 0) { // case-INSENSITIVe on purpose! - $this->field_map[$i] = $value; + $this->field_map[$i] = $v; continue 2; //don't bother with the alias check, go to the next header } } @@ -140,7 +140,7 @@ class Importer extends Component // Make *absolutely* sure that this key actually _exists_ in this import type - // you can trigger this by importing accessories with a 'Warranty' column (which don't exist // in "Accessories"!) - if (array_key_exists($key, $this->columnOptions[$new_import_type])) { + if (array_key_exists($key, $this->columnOptions[$value])) { $this->field_map[$i] = $key; continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header } From 69263f0e5b2d5e600e4368a766104691a6e65e3f Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 16 Jul 2024 13:30:29 -0700 Subject: [PATCH 06/19] Migrate header row to component --- app/Livewire/Importer.php | 10 +++++++--- resources/views/livewire/importer.blade.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 1cbe0825b2..1f9a78ad1d 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -21,6 +21,7 @@ class Importer extends Component //originally from ImporterFile public $import_errors; // public ?Import $activeFile = null; + public $headerRow = []; public $importTypes; public $columnOptions; public $statusType; @@ -49,6 +50,7 @@ class Importer extends Component 'activeFile.import_type' => 'string', 'activeFile.field_map' => 'array', 'activeFile.header_row' => 'array', + 'headerRow' => 'array', 'field_map' => 'array' ]; @@ -62,7 +64,7 @@ class Importer extends Component { $tmp = array(); if ($this->activeFile) { - $tmp = array_combine($this->activeFile->header_row, $this->field_map); + $tmp = array_combine($this->headerRow, $this->field_map); $tmp = array_filter($tmp); } return json_encode($tmp); @@ -112,7 +114,7 @@ class Importer extends Component if ($propertyKey == "import_type") { // go through each header, find a matching field to try and map it to. - foreach ($this->activeFile->header_row as $i => $header) { + foreach ($this->headerRow as $i => $header) { // do we have something mapped already? if (array_key_exists($i, $this->field_map)) { // yes, we do. Is it valid for this type of import? @@ -510,8 +512,10 @@ class Importer extends Component return; } + $this->headerRow = $this->activeFile->header_row; + $this->field_map = null; - foreach($this->activeFile->header_row as $element) { + foreach ($this->headerRow as $element) { if(isset($this->activeFile->field_map[$element])) { $this->field_map[] = $this->activeFile->field_map[$element]; } else { diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index b1164990be..d3ab66bdc4 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -213,9 +213,9 @@ - @if($activeFile->header_row) + @if(! empty($headerRow)) - @foreach($activeFile->header_row as $index => $header) + @foreach($headerRow as $index => $header)
From b7744105a09e87a673f50eff32c1a7516d91c5ec Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 16 Jul 2024 14:20:41 -0700 Subject: [PATCH 07/19] Migrate import type to component --- app/Livewire/Importer.php | 74 ++++++++++----------- resources/views/livewire/importer.blade.php | 20 +++--- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 1f9a78ad1d..4c89e63dc2 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -22,6 +22,7 @@ class Importer extends Component public $import_errors; // public ?Import $activeFile = null; public $headerRow = []; + public $typeOfImport; public $importTypes; public $columnOptions; public $statusType; @@ -51,6 +52,7 @@ class Importer extends Component 'activeFile.field_map' => 'array', 'activeFile.header_row' => 'array', 'headerRow' => 'array', + 'typeOfImport' => 'string', 'field_map' => 'array' ]; @@ -109,49 +111,46 @@ class Importer extends Component return $results; } - public function updatingActiveFile($value, $propertyKey) + public function updatingTypeOfImport($type) { - if ($propertyKey == "import_type") { - - // go through each header, find a matching field to try and map it to. - foreach ($this->headerRow as $i => $header) { - // do we have something mapped already? - if (array_key_exists($i, $this->field_map)) { - // yes, we do. Is it valid for this type of import? - // (e.g. the import type might have been changed...?) - if (array_key_exists($this->field_map[$i], $this->columnOptions[$value])) { - //yes, this key *is* valid. Continue on to the next field. - continue; - } else { - //no, this key is *INVALID* for this import type. Better set it to null - // and we'll hope that the $aliases_fields or something else picks it up. - $this->field_map[$i] = null; // fingers crossed! But it's not likely, tbh. - } // TODO - strictly speaking, this isn't necessary here I don't think. + // go through each header, find a matching field to try and map it to. + foreach ($this->headerRow as $i => $header) { + // do we have something mapped already? + if (array_key_exists($i, $this->field_map)) { + // yes, we do. Is it valid for this type of import? + // (e.g. the import type might have been changed...?) + if (array_key_exists($this->field_map[$i], $this->columnOptions[$type])) { + //yes, this key *is* valid. Continue on to the next field. + continue; + } else { + //no, this key is *INVALID* for this import type. Better set it to null + // and we'll hope that the $aliases_fields or something else picks it up. + $this->field_map[$i] = null; // fingers crossed! But it's not likely, tbh. + } // TODO - strictly speaking, this isn't necessary here I don't think. + } + // first, check for exact matches + foreach ($this->columnOptions[$type] as $v => $text) { + if (strcasecmp($text, $header) === 0) { // case-INSENSITIVe on purpose! + $this->field_map[$i] = $v; + continue 2; //don't bother with the alias check, go to the next header } - // first, check for exact matches - foreach ($this->columnOptions[$value] as $v => $text) { - if (strcasecmp($text, $header) === 0) { // case-INSENSITIVe on purpose! - $this->field_map[$i] = $v; - continue 2; //don't bother with the alias check, go to the next header - } - } - // if you got here, we didn't find a match. Try the $aliases_fields - foreach ($this->aliases_fields as $key => $alias_values) { - foreach ($alias_values as $alias_value) { - if (strcasecmp($alias_value, $header) === 0) { // aLsO CaSe-INSENSitiVE! - // Make *absolutely* sure that this key actually _exists_ in this import type - - // you can trigger this by importing accessories with a 'Warranty' column (which don't exist - // in "Accessories"!) - if (array_key_exists($key, $this->columnOptions[$value])) { - $this->field_map[$i] = $key; - continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header - } + } + // if you got here, we didn't find a match. Try the $aliases_fields + foreach ($this->aliases_fields as $key => $alias_values) { + foreach ($alias_values as $alias_value) { + if (strcasecmp($alias_value, $header) === 0) { // aLsO CaSe-INSENSitiVE! + // Make *absolutely* sure that this key actually _exists_ in this import type - + // you can trigger this by importing accessories with a 'Warranty' column (which don't exist + // in "Accessories"!) + if (array_key_exists($key, $this->columnOptions[$type])) { + $this->field_map[$i] = $key; + continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header } } } - // and if you got here, we got nothing. Let's recommend 'null' - $this->field_map[$i] = null; // Booooo :( } + // and if you got here, we got nothing. Let's recommend 'null' + $this->field_map[$i] = null; // Booooo :( } } @@ -513,6 +512,7 @@ class Importer extends Component } $this->headerRow = $this->activeFile->header_row; + $this->typeOfImport = $this->activeFile->import_type; $this->field_map = null; foreach ($this->headerRow as $element) { diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index d3ab66bdc4..53bb59ffaf 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -142,12 +142,12 @@
-
- @if (($activeFile->first_row) && (array_key_exists($index, $activeFile->first_row))) + @if (($this->activeFile->first_row) && (array_key_exists($index, $this->activeFile->first_row)))
-

{{ str_limit($activeFile->first_row[$index], 50, '...') }}

+

{{ str_limit($this->activeFile->first_row[$index], 50, '...') }}

@else @php @@ -251,7 +251,7 @@
@@ -267,7 +267,7 @@ @else @endif {{-- end of if ... $typeOfImport --}} @@ -388,7 +388,7 @@ } } - $wire.$set('activeFile', null); //$wire.$set('hideDetails') + $wire.$set('activeFileId', null); //$wire.$set('hideDetails') }); }) return false; From f58e3114a23435331536000d04ee3090ad4fb9f4 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 16 Jul 2024 17:17:45 -0700 Subject: [PATCH 10/19] Simplify destroy method and update list --- app/Livewire/Importer.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 8d63f4b7d9..826d1ef7d9 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -523,23 +523,22 @@ class Importer extends Component public function destroy($id) { - // TODO: why don't we just do File::find($id)? This seems dumb. - foreach ($this->files as $file) { - if ($id == $file->id) { - if (Storage::delete('private_uploads/imports/' . $file->file_path)) { - $file->delete(); + $this->authorize('import'); - $this->message = trans('admin/hardware/message.import.file_delete_success'); - $this->message_type = 'success'; - return; - } else { - $this->message = trans('admin/hardware/message.import.file_delete_error'); - $this->message_type = 'danger'; - } - } + $import = Import::findOrFail($id); + + if (Storage::delete('private_uploads/imports/' . $import->file_path)) { + $import->delete(); + $this->message = trans('admin/hardware/message.import.file_delete_success'); + $this->message_type = 'success'; + + unset($this->files); + + return; } - unset($this->files); + $this->message = trans('admin/hardware/message.import.file_delete_error'); + $this->message_type = 'danger'; } public function clearMessage() From dd32341502c94f5dbcac64196a4e3acdc7e95462 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 16 Jul 2024 17:21:18 -0700 Subject: [PATCH 11/19] Display message if attempting to delete non-existent file --- app/Livewire/Importer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 826d1ef7d9..84041f4428 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -525,7 +525,16 @@ class Importer extends Component { $this->authorize('import'); - $import = Import::findOrFail($id); + $import = Import::find($id); + + // Check that the import wasn't deleted after while page was already loaded... + if (!$import) { + // @todo: improve error message + $this->message = trans('admin/hardware/message.import.file_delete_error'); + $this->message_type = 'danger'; + + return; + } if (Storage::delete('private_uploads/imports/' . $import->file_path)) { $import->delete(); From 04b6cb763f1cad48da45e4b2c2a491e95430728e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 10:58:48 -0700 Subject: [PATCH 12/19] Add todo --- app/Livewire/Importer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 84041f4428..1d2bd1fdb1 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -536,6 +536,8 @@ class Importer extends Component return; } + // @todo: next up...handle the file being missing for other interactions... + if (Storage::delete('private_uploads/imports/' . $import->file_path)) { $import->delete(); $this->message = trans('admin/hardware/message.import.file_delete_success'); From 3772a21a517c9805929f66e38122cbe7bf6f06f8 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 13:37:24 -0700 Subject: [PATCH 13/19] Move comment up --- app/Livewire/Importer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 1d2bd1fdb1..460460cd2d 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -528,6 +528,7 @@ class Importer extends Component $import = Import::find($id); // Check that the import wasn't deleted after while page was already loaded... + // @todo: next up...handle the file being missing for other interactions...for example switching the import type if (!$import) { // @todo: improve error message $this->message = trans('admin/hardware/message.import.file_delete_error'); @@ -536,8 +537,6 @@ class Importer extends Component return; } - // @todo: next up...handle the file being missing for other interactions... - if (Storage::delete('private_uploads/imports/' . $import->file_path)) { $import->delete(); $this->message = trans('admin/hardware/message.import.file_delete_success'); From b4ed01243bbac083ddd66d912207bd865098c30a Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 13:40:41 -0700 Subject: [PATCH 14/19] Add more details --- app/Livewire/Importer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 460460cd2d..49884dc6dd 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -528,7 +528,9 @@ class Importer extends Component $import = Import::find($id); // Check that the import wasn't deleted after while page was already loaded... - // @todo: next up...handle the file being missing for other interactions...for example switching the import type + // @todo: next up...handle the file being missing for other interactions... + // for example having an import open in two tabs, deleting it, and then changing + // the import type in the other tab. The error message below wouldn't display in that case. if (!$import) { // @todo: improve error message $this->message = trans('admin/hardware/message.import.file_delete_error'); From cfca1514c00e7ce1eab506b110f93f59a1b2eaf8 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 16:22:44 -0700 Subject: [PATCH 15/19] Swap file_id for activeFileId --- app/Livewire/Importer.php | 3 --- resources/views/livewire/importer.blade.php | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index 49884dc6dd..f3a461d313 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -30,8 +30,6 @@ class Importer extends Component public $send_welcome; public $run_backup; public $field_map; // we need a separate variable for the field-mapping, because the keys in the normal array are too complicated for Livewire to understand - // @todo: remove the need for this by using $activeFileId - public $file_id; // TODO: I can't figure out *why* we need this, but it really seems like we do. I can't seem to pull the id from the activeFile for some reason? // Make these variables public - we set the properties in the constructor so we can localize them (versus the old static arrays) public $accessories_fields; @@ -515,7 +513,6 @@ class Importer extends Component $this->field_map[] = null; // re-inject the 'nulls' if a file was imported with some 'Do Not Import' settings } } - $this->file_id = $id; $this->import_errors = null; $this->statusText = null; diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.php index ecc2c25836..081f7d3880 100644 --- a/resources/views/livewire/importer.blade.php +++ b/resources/views/livewire/importer.blade.php @@ -340,10 +340,10 @@ // console.warn("Here is the mappings:") // console.dir(mappings) // console.warn("Uh, active file id is, I guess: "+$wire.$get('activeFile.id')) - var this_file = $wire.$get('file_id'); // okay, I actually don't know what I'm doing here. + var file_id = $wire.$get('activeFileId'); $.post({ {{-- I want to do something like: route('api.imports.importFile', $activeFile->id) }} --}} - url: "api/v1/imports/process/"+this_file, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE + url: "api/v1/imports/process/"+file_id, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE contentType: 'application/json', data: JSON.stringify({ 'import-update': !!$wire.$get('update'), From 81bffccf0144dce331cabe57b7c5993fba13a6b2 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 16:28:26 -0700 Subject: [PATCH 16/19] Use better error message --- app/Livewire/Importer.php | 3 +-- resources/lang/en-US/admin/hardware/message.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index f3a461d313..fe084d547e 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -529,8 +529,7 @@ class Importer extends Component // for example having an import open in two tabs, deleting it, and then changing // the import type in the other tab. The error message below wouldn't display in that case. if (!$import) { - // @todo: improve error message - $this->message = trans('admin/hardware/message.import.file_delete_error'); + $this->message = trans('admin/hardware/message.import.file_already_deleted'); $this->message_type = 'danger'; return; diff --git a/resources/lang/en-US/admin/hardware/message.php b/resources/lang/en-US/admin/hardware/message.php index 32698b1c07..a062e5c487 100644 --- a/resources/lang/en-US/admin/hardware/message.php +++ b/resources/lang/en-US/admin/hardware/message.php @@ -58,6 +58,7 @@ return [ 'file_delete_success' => 'Your file has been been successfully deleted', 'file_delete_error' => 'The file was unable to be deleted', 'file_missing' => 'The file selected is missing', + 'file_already_deleted' => 'The file selected was already deleted', 'header_row_has_malformed_characters' => 'One or more attributes in the header row contain malformed UTF-8 characters', 'content_row_has_malformed_characters' => 'One or more attributes in the first row of content contain malformed UTF-8 characters', ], From 199e68ff2929e4f13d6fdd35ec71751b71cf82e5 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 17:10:12 -0700 Subject: [PATCH 17/19] Simplify computed propery --- app/Livewire/Importer.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.php index fe084d547e..99fb73b2a9 100644 --- a/app/Livewire/Importer.php +++ b/app/Livewire/Importer.php @@ -564,11 +564,7 @@ class Importer extends Component #[Computed] public function activeFile() { - if ($this->activeFileId) { - return Import::find($this->activeFileId); - } - - return null; + return Import::find($this->activeFileId); } public function render() From 7685de45f255979cbf1799dd8c6936a2c874419c Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jul 2024 17:12:14 -0700 Subject: [PATCH 18/19] Turn off legacy binding --- config/livewire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/livewire.php b/config/livewire.php index 8cc482183b..6c6d3ba8e1 100644 --- a/config/livewire.php +++ b/config/livewire.php @@ -101,7 +101,7 @@ return [ | */ - 'legacy_model_binding' => true, + 'legacy_model_binding' => false, /* |--------------------------------------------------------------------------- From 8d1cc22c5818baa8673e24cb402090acfbb73a10 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 18 Jul 2024 12:00:01 -0700 Subject: [PATCH 19/19] Turn on legacy binding since other components still use it --- config/livewire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/livewire.php b/config/livewire.php index 6c6d3ba8e1..8cc482183b 100644 --- a/config/livewire.php +++ b/config/livewire.php @@ -101,7 +101,7 @@ return [ | */ - 'legacy_model_binding' => false, + 'legacy_model_binding' => true, /* |---------------------------------------------------------------------------