Add a central registry and hooks for custom condition choices.

Review Request #14280 — Created Jan. 1, 2025 and submitted — Latest diff uploaded

Information

Review Board
release-7.1.x

Reviewers

When we first wrote the support for condition choices for integrations,
we intended for the framework to be extensible, allowing extensions to
produce new condition choices that users could select from. However,
this didn't work in practice, since we lacked any kind of central
registry for condition choices that extensions could hook into.

This change introduces a new central review_request_condition_choices
registry, along with a new ReviewRequestConditionChoicesHook that
wraps it.

A central ReviewRequestConditionsField can be used whenever a
ConditionsField is meant to be used with review_request_condition_choices,
enabling custom condition choices from any extension. rbintegrations 4.1
will be updated to use this.

Documentation has been written to help extension authors make use of the
new hook. It only touches upon the basics of creating new choices, and
doesn't touch upon custom operators, but it should be enough to get
people going.

Unit tests passed.

Tested the new central registry with in-progress code in rbintegrations
and Power Pack.

Built the docs. Checked the example code against the unit tests, and
checked for bad links and other errors.

Changes between revision 1 and 2

orig
1
2
3
4
5

Commits

Summary ID Author
Add a central registry and hooks for custom condition choices.
When we first wrote the support for condition choices for integrations, we intended for the framework to be extensible, allowing extensions to produce new condition choices that users could select from. However, this didn't work in practice, since we lacked any kind of central registry for condition choices that extensions could hook into. This change introduces a new central `review_request_condition_choices` registry, along with a new `ReviewRequestConditionChoicesHook` that wraps it. With this, any extension can easily introduce one or more new condition choices, which will be picked up automatically when presenting a `ConditionsField` (when used along with the upcoming rbintegrations 4.1 release). Documentation has been written to help extension authors make use of the new hook. It only touches upon the basics of creating new choices, and doesn't touch upon custom operators, but it should be enough to get people going.
edcffe03efc09593aafe2ecd22c157d25fbd40d7 Christian Hammond
Add a central registry and hooks for custom condition choices.
When we first wrote the support for condition choices for integrations, we intended for the framework to be extensible, allowing extensions to produce new condition choices that users could select from. However, this didn't work in practice, since we lacked any kind of central registry for condition choices that extensions could hook into. This change introduces a new central `review_request_condition_choices` registry, along with a new `ReviewRequestConditionChoicesHook` that wraps it. With this, any extension can easily introduce one or more new condition choices, which will be picked up automatically when presenting a `ConditionsField` (when used along with the upcoming rbintegrations 4.1 release). Documentation has been written to help extension authors make use of the new hook. It only touches upon the basics of creating new choices, and doesn't touch upon custom operators, but it should be enough to get people going.
9451fe1c2a3b17921c97ee4cb3d2d58754680aa3 Christian Hammond
reviewboard/extensions/tests/test_review_request_condition_choices_hook.py
Loading...