-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add intestactions to loadQuery, auto-add XfD edit request #1091
Add intestactions to loadQuery, auto-add XfD edit request #1091
Conversation
morebits.js
Outdated
@@ -2056,6 +2056,7 @@ Morebits.wiki.page = function(pageName, currentAction) { | |||
watchlistOption: 'nochange', | |||
creator: null, | |||
timestamp: null, | |||
canEdit: null, // true or false after load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better for this to be a testactions
array or something, then just assign all found actions to that array. Then, separate getters can be used (return ctx.testactions.indexOf('edit') !== -1
) or a bulk test (function(action) { return ctx.testactions.indexOf(action) !== -1 }
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also concerns about initial value here. Distinguishing null
from false
or true
could be useful if there's a chance a page object hasn't been load
ed yet...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone and done this, still just with edit
for now, using the former style.
6bd2ae7
to
a7892f7
Compare
a7892f7
to
b79fd07
Compare
b79fd07
to
b98d6ad
Compare
b98d6ad
to
f21db8d
Compare
Simple proof of concept with just `edit` being tested, but this could (should?) easily be expanded to include any relevant actions, allowing us to verify a number of actions ahead of time and catch likely errors early. For now, return editability with `canEdit`.
Currently written with repetitive `if (pageobj.canEdit())` loop. That's just because everyone but AfD has a distinct function on page load, but AfD is muddled within a bunch of other checks. Those checks are good (and should maybe be added to the others...), so we would have to break out the actual tagging into a separate function that doesn't need more loading to cut down on the ifs while still handling the loading for everyone else. PITA. Would close wikimedia-gadgets#176
f21db8d
to
9b61d50
Compare
There are two separate issues here, but the main question is whether adding
intestactions
to the page load query inMorebits.wiki.page
is a good idea. I think it adds value being able to confirm early whether an action can take place, and should avoid running into a hard error if handled elegantly. While this is a simple proof of concept, there's a lot we can think about making use of it. Right now, I've just addededit
, but an expansive view could imagine checks formove
ordelete
, whether in morebits itself or available for modules to use. Even without additional checks, it'd be a helpful pre-edit early failure check. I've not tested or thought through the implications for non-load things likeappend
.I've used it here to enable twinklexfd to auto-add edit protected requests when a user can't edit the page in question. With the exception of TfM other template tagging,
wgIsProbablyEditable
would have sufficed for this implementation. (technically both are making assumptions about "protection" but in practice, that's it). I'm not certain that it's easier than using promises (cc @siddharthvp) but it's probably more efficient.At any rate, I'd welcome thoughts on either side of things.