reviewboard.actions.base¶
Base classes for actions.
New in version 6.0.
- class AttachmentPoint[source]¶
Bases:
object
Attachment points for actions.
New in version 6.0.
- NON_UI = 'non-ui'[source]¶
Attachment for actions which do not want to render in the UI.
This can be used for actions which want to be JavaScript-only, and may be used in the future for things like keyboard shortcuts or a command-K bar.
- REVIEW_REQUEST_LEFT = 'review-request-left'[source]¶
Attachment for actions on the left side of the review request header.
- class BaseAction[source]¶
Bases:
object
Base class for actions.
New in version 6.0.
- apply_to: Optional[List[str]] = None¶
A list of URLs to apply to.
If this is
None
, the action will be loaded on all pages. Otherwise, it will be limited to the URLs listed here.
- icon_class: Optional[str] = None¶
A class name to use for an icon.
If specified, this should be the entire class to apply to a <span> element to display an icon. For example, ‘fa fa-rss’.
- Type:
- js_template_name: str = 'actions/action.js'¶
The name of the template to use for rendering action JavaScript.
- Type
str
- js_view_class: str = 'RB.Actions.ActionView'¶
The class to instantiate for the JavaScript view.
- Type:
- url_name: Optional[str] = None¶
A URL name to resolve.
If this is not None, it will take precedence over
url
.- Type:
- parent_action: Optional[BaseMenuAction]¶
The parent of this action, if this is a menu item.
- Type:
- child_actions: List[BaseAction]¶
The list of child actions, if this is a menu.
- Type:
list
ofBaseAction
- should_render(*, context: Context) bool [source]¶
Return whether this action should render.
This differs from
visible
in that non-visible actions still render but are hidden by CSS, whereas if this returnsFalse
the action will not be included in the DOM at all.- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
True
if the action should render.- Return type:
- get_dom_element_id() str [source]¶
Return the ID used for the DOM element for this action.
- Returns:
The ID used for the element.
- Return type:
- get_js_model_data(*, context: Context) dict [source]¶
Return data to be passed to the JavaScript model.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
A dictionary of attributes to pass to the model instance.
- Return type:
- get_js_view_data(*, context: Context) dict [source]¶
Return data to be passed to the JavaScript view.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
A dictionary of options to pass to the view instance.
- Return type:
- get_label(*, context: Context) _StrOrPromise [source]¶
Return the label for the action.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
The label to use for the action.
- Return type:
- get_url(*, context: Context) str [source]¶
Return the URL for the action.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
The URL to use for the action.
- Return type:
- get_visible(*, context: Context) bool [source]¶
Return whether the action should start visible.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
True
if the action should start visible.False
, otherwise.- Return type:
- get_extra_context(*, request: HttpRequest, context: Context) dict [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 an empty dictionary.
- 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:
django.utils.safestring.SafeText
- render_js(*, request: HttpRequest, context: Context) 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.
- Returns:
The rendered action JavaScript.
- Return type:
django.utils.safestring.SafeText
- __annotations__ = {'_hidden_by_extension': 'Optional[bool]', 'action_id': 'Optional[str]', 'apply_to': 'Optional[List[str]]', 'attachment': 'str', 'child_actions': 'List[BaseAction]', 'icon_class': 'Optional[str]', 'js_model_class': 'str', 'js_template_name': 'str', 'js_view_class': 'str', 'label': 'Optional[_StrOrPromise]', 'parent_action': 'Optional[BaseMenuAction]', 'parent_id': 'Optional[str]', 'template_name': 'str', 'url': 'str', 'url_name': 'Optional[str]', 'visible': 'bool'}¶
- class BaseMenuAction[source]¶
Bases:
BaseAction
Base class for menu actions.
New in version 6.0.
- template_name: str = 'actions/menu_action.html'[source]¶
The name of the template to use when rendering.
- Type:
- js_model_class: str = 'RB.Actions.MenuAction'[source]¶
The class to instantiate for the JavaScript model.
- Type:
- js_view_class: str = 'RB.Actions.MenuActionView'[source]¶
The class to instantiate for the JavaScript view.
- Type:
- children: List[str] = []¶
An ordered list of child menu IDs.
This can be used to specify a specific order for children to appear in. The special string ‘–’ can be used to add separators. Any children that are registered with this menu as their parent but do not appear in this list will be added at the end of the menu.
- __annotations__ = {'_hidden_by_extension': 'Optional[bool]', 'action_id': 'Optional[str]', 'apply_to': 'Optional[List[str]]', 'attachment': 'str', 'child_actions': 'List[BaseAction]', 'children': 'List[str]', 'icon_class': 'Optional[str]', 'js_model_class': 'str', 'js_template_name': 'str', 'js_view_class': 'str', 'label': 'Optional[_StrOrPromise]', 'parent_action': 'Optional[BaseMenuAction]', 'parent_id': 'Optional[str]', 'template_name': 'str', 'url': 'str', 'url_name': 'Optional[str]', 'visible': 'bool'}¶
- get_extra_context(*, request: HttpRequest, context: Context) dict [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 an empty dictionary.
- 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:
- get_js_model_data(*, context: Context) dict [source]¶
Return data to be passed to the JavaScript model.
- Parameters:
context (
django.template.Context
) – The current rendering context.- Returns:
A dictionary of attributes to pass to the model instance.
- Return type: