-
-
Notifications
You must be signed in to change notification settings - Fork 545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x] Fix error when deleting collections #10908
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure how we got ourselves into a situation where we sometimes have this.items
and sometimes have this.rows
. I think maybe it's whenever we have ajax based listings it uses items
and when we pass in data from controllers it's rows
.
Regardless, this now does break the collection actions. The listing no longer refreshes after you run an action.
e.g. If you ran this action on a collection, it would look like nothing happened. Only when you manually refreshed the page would you see the changed title.
<?php
namespace App\Actions;
use Statamic\Actions\Action;
class Plop extends Action
{
public function run($items, $values)
{
$items->each(function ($c) {
$c->title('Plopped '.$c->title())->save();
});
}
}
The simplest solution here I think would be to remove the "resource deleter" from the collection listing and make the Delete action available to collections.
cms/resources/js/components/collections/Listing.vue
Lines 21 to 33 in 23a5b78
<dropdown-item | |
v-if="collection.deleteable" | |
:text="__('Delete Collection')" | |
class="warning" | |
@click="$refs[`deleter_${collection.id}`].confirm()" | |
> | |
<resource-deleter | |
:ref="`deleter_${collection.id}`" | |
:resource="collection" | |
@deleted="removeRow(collection)"> | |
</resource-deleter> | |
</dropdown-item> | |
</dropdown-list> |
Lines 22 to 28 in 6db65ff
case $item instanceof Contracts\Taxonomies\Term: | |
case $item instanceof Contracts\Assets\Asset: | |
case $item instanceof Contracts\Assets\AssetFolder: | |
case $item instanceof Contracts\Forms\Form: | |
case $item instanceof Contracts\Forms\Submission: | |
case $item instanceof Contracts\Auth\User: | |
return true; |
Dealing with the rows/items inconsistency is probably a bigger job and a breaking change.
Rather than the `<resource-deleter>` component.
@jasonvarga Okay! I've refactored this PR to use the delete action instead. 👍 |
This pull request fixes an issue where you'd see a console error when attempting to delete collections.
This issue was caused by the rename of
rows
toitems
in #10471. This PR fixes it by doing away with the<resource-deleter>
component, in favour of theDelete
action we use elsewhere.This PR also fixes a bug with the context passed to collection actions on the "collection show", where
view
was wronglylist
instead ofform
.