kopia lustrzana https://github.com/wagtail/wagtail
				
				
				
			Add docs for context argument removal from construct_snippet_listing_buttons
							rodzic
							
								
									39ae5b2797
								
							
						
					
					
						commit
						97052d2e46
					
				| 
						 | 
				
			
			@ -1317,14 +1317,18 @@ The `priority` argument controls the order the buttons are displayed in. Buttons
 | 
			
		|||
 | 
			
		||||
### `construct_snippet_listing_buttons`
 | 
			
		||||
 | 
			
		||||
Modify the final list of snippet listing buttons. The callable passed to this hook receives a list of `SnippetListingButton` objects, a user, and a context dictionary as per `register_snippet_listing_buttons`, and should modify the list of menu items in-place.
 | 
			
		||||
Modify the final list of snippet listing buttons. The callable passed to this hook receives a list of `SnippetListingButton` objects, the snippet object and a user, and should modify the list of menu items in-place.
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
@hooks.register('construct_snippet_listing_buttons')
 | 
			
		||||
def remove_snippet_listing_button_item(buttons, snippet, user, context=None):
 | 
			
		||||
def remove_snippet_listing_button_item(buttons, snippet, user):
 | 
			
		||||
    buttons.pop()  # Removes the 'delete' button
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```{versionchanged} 5.2
 | 
			
		||||
The `context` argument has been removed from this hook.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Bulk actions
 | 
			
		||||
 | 
			
		||||
Hooks for registering and customising bulk actions. See [](custom_bulk_actions) on how to write custom bulk actions.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -364,3 +364,9 @@ def my_view(request):
 | 
			
		|||
        {"page": page, "side_panels": side_panels, "media": side_panels.media},
 | 
			
		||||
    )
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### `construct_snippet_listing_buttons` hook no longer accepts a `context` argument
 | 
			
		||||
 | 
			
		||||
The [`construct_snippet_listing_buttons`](construct_snippet_listing_buttons) hook no longer accepts a `context` argument. If you have implemented this hook, you will need to remove the `context` argument from your implementation. If you need to access values computed by the view, you'll need to override the {attr}`~wagtail.snippets.views.snippets.SnippetViewSet.index_view_class` with a custom `IndexView` subclass. The `get_list_buttons` and `get_list_dropdown_buttons` methods in particular may be overridden to customise the buttons on the listing.
 | 
			
		||||
 | 
			
		||||
Defining a function for this hook that accepts the `context` argument will raise a warning, and the function will receive an empty dictionary (`{}`) as the `context`. Support for defining the `context` argument will be completely removed in a future Wagtail release.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue