reviewboard.actions.renderers¶
Base support for action renderers.
New in version 7.1.
- ActionSubgroupRendererType¶
The type of an action group renderer for subgroups of groups.
This can be a
BaseActionGroupRenderersubclass, the string “self” to reuse the parent action renderer, orNoneto prevent rendering.New in version 7.1.
alias of
Optional[Union[Type[BaseActionGroupRenderer],Literal[‘self’]]]
- class BaseActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
objectBase class for an action renderer.
Action renderers are responsible for rendering an action and providing any setup necessary for a client-side JavaScript view.
Renderer classes can be passed to an action during rendering or set as the default for an action. Renderers don’t need to be centrally registered, and any action implementation is free to construct custom renderers for their needs.
New in version 7.1.
- js_template_name: ClassVar[str] = 'actions/action_view.js'¶
The name of the template to use for rendering action JavaScript.
- js_view_class: ClassVar[str] = 'RB.Actions.ActionView'¶
The class to instantiate for the JavaScript view.
- __init__(*, action: BaseAction, placement: ActionPlacement) None[source]¶
Initialize the renderer.
- Parameters:
action (
reviewboard.actions.base.BaseAction) – The action being rendered.placement (
reviewboard.actions.base.ActionPlacement) – The placement for the action.
- action: BaseAction¶
The action being rendered.
- placement: ActionPlacement¶
The placement for the action.
- get_js_view_data(*, context: Context) SerializableDjangoJSONDict[source]¶
Return data to be passed to the rendered JavaScript view.
Subclasses can override this to provide custom data for a view.
- Parameters:
context (
django.template.Context) – The current rendering context.- Returns:
A dictionary of options to pass to the view instance.
- Return type:
- get_extra_context(*, request: HttpRequest, context: Context) dict[str, Any][source]¶
Return extra template context for the action.
Subclasses can override this to provide additional context needed by the template for the action.
By default, this returns the action’s context for the template.
- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.context (
django.template.Context) – The current rendering context.
- Returns:
Extra context to use when rendering the action’s template.
- Return type:
- render(*, request: HttpRequest, context: Context) SafeString[source]¶
Render the action.
- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.context (
django.template.Context) – The current rendering context.
- Returns:
The rendered action HTML.
- Return type:
- render_js(*, request: HttpRequest, context: Context, extra_js_view_data: SerializableDjangoJSONDict | None = None) SafeString[source]¶
Render the action’s JavaScript.
- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.context (
django.template.Context) – The current rendering context.extra_js_view_data (
dict, optional) – Optional extra data to pass to the JavaScript action view’s constructor.
- Returns:
The rendered action JavaScript.
- Return type:
- class DefaultActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionRendererDefault renderer for actions.
This is the default renderer used for actions that don’t otherwise specify their own default. It will render as a menu item.
- template_name: ClassVar[str | None] = 'actions/action.html'[source]¶
The name of the template to use when rendering.
- js_view_class: ClassVar[str] = 'RB.Actions.ActionView'[source]¶
The class to instantiate for the JavaScript view.
- get_js_view_data(*, context: Context) SerializableDjangoJSONDict[source]¶
Return data to be passed to the JavaScript view.
By default, for backwards-compatibility, this will call
BaseAction.get_js_view_data(). This method is deprecated, and will be removed in Review Board 9.- Parameters:
context (
django.template.Context) – The current rendering context.- Returns:
A dictionary of options to pass to the view instance.
- Return type:
- class BaseActionGroupRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionRendererBase class for an action group renderer.
Group action renderers are responsible for rendering the group and any items within it.
This must be subclassed to specify rendering behavior for the group and a default renderer class for items within the group.
New in version 7.1.
- default_item_renderer_cls¶
The default class for rendering any non-group items within the group.
alias of
DefaultActionRenderer
- default_subgroup_renderer_cls: ClassVar[ActionSubgroupRendererType] = None¶
The default class for rendering any sub-group items within the group.
If unset (the default), then something else must supply a default renderer for subgroups of this group.
This can be the string “self” to use this class as the renderer for subgroups.
- get_extra_context(*, request: HttpRequest, context: Context) dict[str, Any][source]¶
Return extra template context for the action.
This includes a
childrenkey containing the children for this action in the parent attachment point.- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.context (
django.template.Context) – The current rendering context.
- Returns:
Extra context to use when rendering the action’s template.
- Return type:
- render_children(*, children: Iterable[BaseAction], context: Context, request: HttpRequest) SafeString[source]¶
Render the children in the group.
This will iterate through all children in the group, rendering them using their provided renderer or the group’s default renderer. The renderer chosen will depend on whether a child is a group action or a standard action.
If this group should not be rendered, then no children will be rendered.
- Parameters:
children (
listofreviewboard.actions.base.BaseAction) – The children to render.context (
django.template.Context) – The current rendering context.request (
django.http.HttpRequest) – The HTTP request from the client.
- Returns:
The rendered children.
- Return type:
- class DefaultActionGroupRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionGroupRendererDefault class for an action group renderer.
This is a simple renderer that just displays the children of a group. In most cases, an action group will want to provide a more suitable renderer than this.
New in version 7.1.
- class ButtonActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionRendererAction renderer that renders as a button.
This will render a button that reflects and activates the action.
New in version 7.1.
- class MenuItemActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionRendererAction renderer that renders as a menu item.
This will render the action as an Ink menu item, intended for use within a
ActionGroupMenuRenderer.New in version 7.1.
- class MenuActionGroupRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionGroupRendererGroup action renderer that renders as a menu of items.
This will render the group as an Ink menu, with each item in the group as a registered Ink menu item available to the menu.
New in version 7.1.
- default_item_renderer_cls¶
alias of
MenuItemActionRenderer
- class DetailedMenuItemActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
MenuItemActionRendererAction renderer that renders as a detailed menu item.
Detailed menu items have an icon, verbose label, and a description, helping provide more guidance beyond a standard menu item.
New in version 7.1.
- class DetailedMenuActionGroupRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
MenuActionGroupRendererGroup action renderer that renders as detailed menu items.
Detailed menu items have an icon, verbose label, and a description, helping provide more guidance beyond a standard menu item.
New in version 7.1.
- default_item_renderer_cls¶
alias of
DetailedMenuItemActionRenderer
- class SidebarItemActionRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionRendererRenderer for items in a sidebar.
An item in a sidebar contains a label, an optional icon, and an optional URL.
If a URL is supplied and it matches the current page, the item’s presentation will show as active.
New in version 7.1.
- template_name: ClassVar[str | None] = 'actions/sidebar_item_action.html'[source]¶
The name of the template to use when rendering.
- get_extra_context(*, request: HttpRequest, context: Context) dict[str, Any][source]¶
Return extra template context for the action.
- Parameters:
request (
django.http.HttpRequest) – The HTTP request from the client.context (
django.template.Context) – The current rendering context.
- Returns:
Extra context to use when rendering the action’s template.
- Return type:
- class SidebarActionGroupRenderer(*, action: BaseAction, placement: ActionPlacement)[source]¶
Bases:
BaseActionGroupRendererRenderer for a group in a sidebar.
A rendered sidebar group may contain any number of items or nested groups (though presentation may not be optimal if a subgroup contains anther subgroup, due to space limitations in the sidebar).
New in version 7.1.
- default_item_renderer_cls¶
alias of
SidebarItemActionRenderer
- default_subgroup_renderer_cls: ClassVar[ActionSubgroupRendererType] = 'self'¶
The default class for rendering any sub-group items within the group.
If unset (the default), then something else must supply a default renderer for subgroups of this group.
This can be the string “self” to use this class as the renderer for subgroups.