Add base classes and registry for new actions framework.
Review Request #12752 — Created Dec. 7, 2022 and submitted
The actions framework is in the process of being rewritten to give us
better consistency across all the different types of actions, a real
registry, and new features and capabilities.This change introduces the actions app with the action base classes and
registry, along with a JavaScript-side stub model/view, template tags
for rendering the actions on pages, and the beginnings of some unit
tests.
- Ran unit tests.
- Used this with other changes that start porting existing actions over
to the new framework.
Summary | ID |
---|---|
01b769a7cc9607bfc94beb3a36869df6ea02e434 |
Description | From | Last Updated |
---|---|---|
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (8% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (8% scanned). Column: 9 Error code: E041 |
reviewbot | |
If an extension wants to provide its own action points, building on top of our action system, I think the … |
chipx86 | |
Rather than hidden, can we inverse this and use visible? That would pair better with things like fields/fieldsets. |
chipx86 | |
Can we add an "Instance variables" section above and document the types + doc comments for these in that? |
chipx86 | |
This is missing a Type: |
chipx86 | |
Second return will never be invoked. |
chipx86 | |
Can we alphabetize these? |
chipx86 | |
This feels very implementation-specific. Is there a more general name we could use to convey what this ultimately does? |
chipx86 | |
Missing a docstring. We should also document the attributes in the class body in an "Instance variables" section. |
chipx86 | |
Plain imports go before froms. |
chipx86 | |
Missing trailing comma. |
chipx86 | |
Can we separate this with a blank line, so it doesn't blend together? |
chipx86 | |
This needs to be the full class path. Same below. |
chipx86 | |
Let's sort these in alphabetical order. |
chipx86 | |
Can we break once found? |
chipx86 | |
Let's make this keyword-only. |
chipx86 | |
Can we include the exception error message in this string? I know there's a traceback but it helps when grepping … |
chipx86 | |
Can we add Model Attributes:? Same for other JavaScript models. |
chipx86 | |
Blank line here. |
chipx86 | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (8% scanned). Column: 9 Error code: E041 |
reviewbot | |
The first parameter can probably just use |json_dumps without the other {}, since it's not merging it in with anything. |
chipx86 | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Missing a period. |
maubin | |
I think it'd be good to add some docstrings to these explaining what each attachment point is, like what it … |
maubin | |
Should we include the exception details in the log? |
maubin | |
Should we include the exception details in the log? |
maubin | |
Could add -> None to the rest of these test methods. |
maubin | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Since these are documented as instance variables, we no longer need to have these here. |
chipx86 | |
Pure nit, but maybe alphabetize these, so it's clear where new entries should go? |
chipx86 | |
For most of these functions, we can err on the side of making things like context and maybe request keyword-only … |
chipx86 | |
Can we order these alphabetically? |
chipx86 | |
Can we make at least depth_limit a keyword-only argument? |
chipx86 | |
Do we want to localize this string? |
chipx86 | |
Descriptions are a little inconsistent. We can probably omit the "Raised" parts. |
chipx86 | |
Can we add an explicit typing for parent at the top of the function? I've seen either mypy or pyright … |
chipx86 | |
Mind adding a comment with what you were telling me during my previous review, so it's clear that there may … |
chipx86 | |
This can use yield from. |
chipx86 | |
We may need to type this. |
chipx86 | |
We may need to type this. |
chipx86 | |
We may need to type this. |
chipx86 | |
We should probably document our interfaces and their types. I don't know what the right thing is for then documenting … |
chipx86 | |
Can we have a doc comment for the interface? |
chipx86 | |
"ID" |
chipx86 | |
I almost left an entirely different comment, but now I realize Action is meant to be a generic. Might be … |
chipx86 | |
I've kind of been adopting Python's import groups rules. I think that's a nice way of keeping things a bit … |
chipx86 | |
Can we have a doc comment for the interface? |
chipx86 | |
What's this for? |
chipx86 | |
Every time .render() is called, we'll get a new menu appended. I'm assuming we don't want that? Should this be … |
chipx86 | |
When RB.MenuView is converted, we'll be able to do: this.menu.renderInto(this.el); |
chipx86 | |
Do we want these to be private? |
chipx86 | |
A switch might be a better choice here for all these. I think JavaScript can optimize that better too. |
chipx86 | |
Alphabetical order? Just to keep it manageable. |
chipx86 | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Can we add a Version Added here, and a Version Changed on the function description to document it? |
chipx86 | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Let's go with import groups and do a blank line between these. |
chipx86 | |
Expected '}' and instead saw 'djblets_js'. Column: 9 Error code: E021 |
reviewbot | |
Unrecoverable syntax error. (10% scanned). Column: 9 Error code: E041 |
reviewbot | |
Expected a JSON value. Column: 9 Error code: E003 |
reviewbot | |
Expected ':' and instead saw 'load'. Column: 4 Error code: E021 |
reviewbot | |
Expected a string and instead saw %. Column: 2 Error code: W095 |
reviewbot |
- Change Summary:
-
Add some more pieces that got missed in the initial commit.
- Commits:
-
Summary ID 476a1da882bdb8e1bfe23ad648c7b462db36cafd 03c5cdb56368f10b582d48e0cfba12d0900006f7 - Diff:
-
Revision 2 (+1688)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
- Implement
apply_to
- Add maximum depth checking for nested items.
- Change it so registering nested items out of order (child first, then parent) will be properly handled with a warning rather than causing an assertion error.
- Add missing menu action JS view.
- Implement
- Commits:
-
Summary ID 03c5cdb56368f10b582d48e0cfba12d0900006f7 c3153d2e96ca4fb91c7629c84ceefd7837f11867 - Diff:
-
Revision 3 (+2238)
Checks run (1 failed, 1 succeeded)
JSHint
-
-
If an extension wants to provide its own action points, building on top of our action system, I think the enum would prevent that (from a typing perspective), right?
Maybe just take arbitrary strings as attachment points and have an object of constants for our built-in ones?
-
Rather than
hidden
, can we inverse this and usevisible
? That would pair better with things like fields/fieldsets. -
Can we add an "Instance variables" section above and document the types + doc comments for these in that?
-
-
-
So I've noticed that our general defaults of
None
for class attributes has been a bit annoying when working with those values, because we always need to do these checks.That might still be the right approach. Another, though, would be to default those to empty strings instead of
None
, and then simply return or assert for truthiness, depending on where we're using it.In simple cases like this, not a big deal, but it's definitely made porting some older code a bit more of a hassle.
I'd love to figure out what the right pattern is going forward.
-
-
This feels very implementation-specific. Is there a more general name we could use to convey what this ultimately does?
-
-
Missing a docstring.
We should also document the attributes in the class body in an "Instance variables" section.
-
-
-
-
-
-
-
-
Can we include the exception error message in this string? I know there's a traceback but it helps when grepping for errors.
Same below.
-
-
-
The first parameter can probably just use
|json_dumps
without the other{}
, since it's not merging it in with anything.
- Commits:
-
Summary ID c3153d2e96ca4fb91c7629c84ceefd7837f11867 a2c9e42dfb760da85b727e3fc7f73a0001da7769 - Diff:
-
Revision 4 (+2314)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
Check parent
should_render
so menus can entirely control their children. - Commits:
-
Summary ID a2c9e42dfb760da85b727e3fc7f73a0001da7769 6c832a24cc1beee8f1f86fae31e7756995142df1 - Diff:
-
Revision 5 (+2328)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
- Change element classes to be generic names (no "review-request")
- Add icon_class attribute.
- Commits:
-
Summary ID 6c832a24cc1beee8f1f86fae31e7756995142df1 7ab475ad456a93ba67dff2dfad8881ab5bdb5c64 - Diff:
-
Revision 6 (+2358)
Checks run (1 failed, 1 succeeded)
JSHint
- Commits:
-
Summary ID 7ab475ad456a93ba67dff2dfad8881ab5bdb5c64 7462dac7c8b554b874ef1164d6684d47228e6551 - Diff:
-
Revision 7 (+2394)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
- Port JS to spina
- Move registry initialization with built-in actions into the change that adds those actions.
- Commits:
-
Summary ID 7462dac7c8b554b874ef1164d6684d47228e6551 8f3bca1bafba20c0799bef650b78a34460a1d6ef - Diff:
-
Revision 8 (+2340)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
Make menu action's menu public so subclasses can use it directly.
- Commits:
-
Summary ID 8f3bca1bafba20c0799bef650b78a34460a1d6ef afae20640cc8d0f7d62e3f01fd7683ff5e28c9ec - Diff:
-
Revision 9 (+2340)
Checks run (1 failed, 1 succeeded)
JSHint
-
This looks great!
Pretty much everything here is tiny, with some being "what standards do we want to set for TypeScript code?" comments.
-
-
-
For most of these functions, we can err on the side of making things like
context
and mayberequest
keyword-only arguments? I think that's a good habit we should get into for things meant to be overridden by subclasses, so we're not stuck maintaining argument orders indefinitely. -
-
-
-
-
Can we add an explicit typing for
parent
at the top of the function? I've seen either mypy or pyright sometimes get things wrong without it (or convert toAny
, depending) when there's some assignments to values, some toNone
. -
Mind adding a comment with what you were telling me during my previous review, so it's clear that there may be multiple things being unregistered here?
-
-
-
-
-
We should probably document our interfaces and their types.
I don't know what the right thing is for then documenting the model's attributes. Maybe we just rely on the interface's going forward.
-
I almost left an entirely different comment, but now I realize
Action
is meant to be a generic. Might be worth documenting this and that subclasses may want to provide a subclass for their attributes? -
I've kind of been adopting Python's import groups rules. I think that's a nice way of keeping things a bit separate and clear. Can we do that for these changes?
-
-
Every time
.render()
is called, we'll get a new menu appended. I'm assuming we don't want that? Should this beonInitialRender()
, or should we clear elements and clean up state? -
-
-
-
A
switch
might be a better choice here for all these. I think JavaScript can optimize that better too.
- Commits:
-
Summary ID afae20640cc8d0f7d62e3f01fd7683ff5e28c9ec b77f112e77e458c25ff62b81e014cfc7a8e46da0 - Diff:
-
Revision 10 (+2388)
Checks run (1 failed, 1 succeeded)
JSHint
- Commits:
-
Summary ID b77f112e77e458c25ff62b81e014cfc7a8e46da0 b6a494c721ba4bdde23fa30ad321d4bbe5c29247 - Diff:
-
Revision 11 (+2426)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
Fix arguments passed to MenuView.open
- Commits:
-
Summary ID b6a494c721ba4bdde23fa30ad321d4bbe5c29247 57c9a86a03e008b00b1a51c7ffb3149eb72a6b01 - Diff:
-
Revision 12 (+2426)
Checks run (1 failed, 1 succeeded)
JSHint
- Change Summary:
-
Pull a couple things from later changes into this one.
- Commits:
-
Summary ID 57c9a86a03e008b00b1a51c7ffb3149eb72a6b01 d1b7f6159228290519131dc213e057bd60e5ce26 - Diff:
-
Revision 13 (+2532 -4)
Checks run (1 failed, 1 succeeded)
JSHint
- Commits:
-
Summary ID d1b7f6159228290519131dc213e057bd60e5ce26 01b769a7cc9607bfc94beb3a36869df6ea02e434 - Diff:
-
Revision 14 (+2546 -4)