Implement review request action registration.
Review Request #7661 — Created Sept. 26, 2015 and submitted — Latest diff uploaded
This is an architectural change for Review Board 2.6 that affects
extensions. Currently, there are some default review request actions
(like "Close -> Submitted" or "Download Diff" or "Ship It!") that have
been hardcoded into the template. Extensions can provide custom actions
by passing dictionaries into a variety of ActionHooks.This change encapsulates this logic into a BaseReviewRequestAction
class. Instead of passing ActionHook-style dictionaries into the hooks,
extensions can now pass in BaseReviewRequestAction instances. Hardcoded
actions have been ripped out from the template and retrofitted into a
cleaner action registration system. Other new features include:- Up to two levels of action nesting via BaseReviewRequestMenuActions.
- A should_render() method that subclasses of BaseReviewRequestAction
can override in order to implement complex action rendering behaviour.
- A register_actions() method that can be used to add a custom action to
any of the default menu actions.
- An unregister_actions() method that can be used to remove any of the
default actions.
- A ReviewRequestActionHookModel for providing action callbacks in JS.
- Ran and passed the relevant reviewboard unit tests. - Manually verified that all default actions display correctly in different scenarios. 1. Test in all three types of pages ("Reviews", "File", "Diff"). 2. Test in normal as well as local sites. 3. Test DownloadDiffAction with the slider (for interdiffs). 4. Test as an authenticated user and as a guest. 5. Test when the review request is pending review and is submitted. - Added my own extension that provides its own actions in different ways and manually verified that each action displayed correctly in different scenarios. 1. Test adding actions and menu actions via action-style dicts. 2. Test adding actions and menu actions via action instances. 3. Test adding menu actions that contain their own menu actions. 4. Test that a menu action can override its children from rendering. 5. Test unregistering a default action. 6. Test unregistering a child action of a default menu action. 7. Test registering a new child action on a default menu action. - Added unit tests that cover the above functionality, which all pass. - Added my own JS extension that provides its own callback and manually verified that the callback is correctly triggered when its corresponding action is clicked. - Built the Sphinx docs and manually verified that my updates rendered correctly.