Extending Review Board¶
Review Board is a highly-extensible code review product. Like a browser, anyone can write extensions that improve the product, adding new features, enhancing existing ones, changing the look and feel, and integrating with other services. Here are just a few examples of what you can accomplish by writing an extension:
Modify the user interface to provide new review request actions, fields, or update the content of e-mails
Collect statistics and generate reports
Connect Review Board with other systems (Slack, IRC, Asana, etc.)
Add new API for collecting or computing custom data
Implement review UIs for previously unsupported types of files
This guide will cover some of the basics of extension writing, and provide a reference to the Review Board codebase.
Extension Basics¶
To begin, you’ll want to become familiar with a few of the basics of extension writing.
Tip
To get started quickly, you can use rbext create to create your initial page and extension source code. This won’t write your whole extension for you, of course, but it’s a good way of getting the basics in place.
New in version 3.0.4.
Python Extension Hooks¶
Review Board provides what we call “extension hooks,” which are areas that an extension can hook into in order to modify behavior or UI. There are many extension hooks available to you.
- General Utility Hooks:
- SignalHook:
Connects to signals defined by Review Board, Django, or other projects.
- General Page Content Hooks:
- NavigationBarHook:
Adds new navigation options to the page alongside “Dashboard,” “All Review Requests,” etc.
- TemplateHook:
Adds new content to existing templates.
- URLHook:
Defines new URLs in Review Board, which can point to your own custom views.
- AvatarServiceHook:
Adds a new avatar service, which can be used to provide pictures for user accounts.
- Action Hooks:
A series of hooks used to add new actions for review requests, the diff viewer, and the account/support header at the top of the page.
The following action hooks are available:
ActionHook
:Generic hook for adding new-style actions.
HideActionHook
:Hook for hiding built-in actions.
DiffViewerActionHook
:Deprecated hook for adding actions to the diff viewer’s review request actions bar.
HeaderActionHook
:Deprecated hook for adding actions to the top-right of the page.
HeaderDropdownActionHook
:Deprecated hook for adding drop-down actions to the top-right of the page.
ReviewRequestActionHook
:Deprecated hook for adding actions to the review request actions bar.
ReviewRequestDropdownActionHook
:Deprecated hook for adding drop-down actions to the review request actions bar.
- API Hooks:
- WebAPICapabilitiesHook:
Adds new capability flags to the root API resource that clients of the API can use to determine whether particular features or capabilities are active.
- APIExtraDataAccessHook:
Allows for customizing visibility and mutation for keys in
extra_data
fields, allowing fields to be private or read-only.
- Datagrid Hooks:
- DashboardColumnsHook:
Adds new columns to the dashboard, for additional information display.
- DashboardSidebarItemsHook:
Add sections and items to the Dashboard sidebar, where the lists of groups are displayed.
- DataGridColumnsHook:
Adds new columns to other datagrids (like the users, groups, and All Review Requests pages).
- UserPageSidebarItemsHook:
Add sections and items to the user page’s sidebar, where information on the user is normally shown.
- Review-related Hooks:
- CommentDetailDisplayHook:
Adds additional information to the displayed comments on reviews in the review request page and in e-mails.
- FileAttachmentThumbnailHook:
Adds thumbnail renderers for file attachments matching certain mimetypes.
- FileDiffACLHook:
Allows implementing ACLs for diffs. This can be used to mirror your repository ACLs into access control for associated review requests.
- ReviewRequestApprovalHook:
Adds new logic indicating whether a review request can been approved for landing in the codebase.
- ReviewRequestFieldsHook:
Adds new fields to the review request.
- ReviewRequestFieldSetsHook:
Adds new fieldsets to the review request.
- ReviewUIHook:
Adds new review UIs for reviewing file attachments matching certain mimetypes.
- E-mail hooks:
A series of hooks that allow for updating recipients lists for outgoing e-mails.
The following e-mail hooks are available:
- ReviewRequestPublishedEmailHook:
Updates information for e-mails about publishing review requests.
- ReviewRequestClosedEmailHook:
Updates information for e-mails about closing review requests.
- ReviewPublishedEmailHook:
Updates information for e-mails about new reviews.
- ReviewReplyPublishedEmailHook:
Updates information for e-mails about new replies.
- My Account Page Hooks:
- AccountPageFormsHook:
Adds new forms in the My Account page.
- AccountPagesHook:
Adds new sub-pages in the My Account page.
- Administrative Hooks:
- AdminWidgetHook:
Adds new widgets for the administration UI.
- AuthBackendHook:
Adds a new authentication backend for logging into Review Board.
- HostingServiceHook:
Adds support for new source code or bug tracker hosting services.
- SCMToolHook:
Adds support for new SCM implementations.
- IntegrationHook:
Adds new integration options for services and tools.
JavaScript Extension Hooks¶
When writing a JavaScript extension, you can make use of some special hooks to augment behavior in Review Board’s UI. These work just like Python hooks.
- Review-related Hooks:
- CommentDialogHook:
Adds new fields or content to the comment dialog.
- FileAttachmentThumbnailContainerHook:
Adds new content or file actions to file attachment thumbnails.
- ReviewDialogCommentHook:
Adds new fields or content to comments shown in the review dialog.
- ReviewDialogHook:
Adds new fields or content to the top of the review dialog.
Guides to Extending Review Board¶
We have guides on some of the more common types of extensions you might be interested in. Note that some of these are still a work-in-progress.
Code Base Documentation¶
When writing extensions, you will be working directly with the same Review Board classes and methods that we use in the product ourselves.
Please note that not all of these are guaranteed to be API-stable or fully documented.