Commit graph

233 commits

Author SHA1 Message Date
jenkins-bot 5689650a6a Merge "Replace $.extend with Object.assign" 2024-05-02 21:42:02 +00:00
Ed Sanders 1e0aa2171f Replace $.extend with Object.assign
Change-Id: Id559ab68451a1d767e92ed17b1ef0832a5f243af
2024-05-02 16:49:43 +01:00
Ed Sanders 2dd73f935c JSDoc: {Mixed} -> {any}
Change-Id: I78bdc1ec8767dca05e979d8c6ebfed72573acc6f
2024-05-02 10:36:24 +01:00
Ed Sanders a74c00ba8c Prefer arrow functions for callbacks
This allows us to remove our `this` bindings.

Change-Id: Ie8c8c38d36af8a033b5181870c39f8981a57b939
2024-04-19 12:34:23 +01:00
Ed Sanders b6ebb5db56 CommentController/ReplyWidget: Document events
Also rename CommentController#teardown to onReplyWidgetTeardown,
and NewTopicController#clear(Storage) to onReplyWidgetClear(Storage).

Change-Id: Ib1dd50ca69aac6f1836674d1a6aefa2402844c57
2024-01-05 16:20:30 +00:00
Ed Sanders a853e6f3d2 Remove { passive: true } from removeEventListener
This option doesn't exist when removing an event.

Change-Id: I2449fec2b2368f829d93eea9a13c13aea1ab75f8
2023-12-08 10:59:40 +00:00
Ed Sanders f2f0ec2f65 build: Update linters and fix
Change-Id: Iec16f3330f94d38bb50492b7dcc9207786b964a4
2023-11-28 16:10:47 +00:00
jenkins-bot ef28fbfc84 Merge "ReplyWidget: don't show the enter hint if the reply button is disabled" 2023-11-01 17:58:36 +00:00
jenkins-bot e729df2bfe Merge "ReplyWidget: don't show the enter hint if the target was in bodyWrapper" 2023-11-01 17:58:28 +00:00
David Lynch 0b64a1a52c Use VE shortcut-generation code for replywidget button labels
Now that the base ReplyWidget depends on VE.

Change-Id: I6bd2bf1b0867a0aeae8e94e35a2e765cad3e72f4
2023-10-26 16:29:08 +00:00
David Lynch e638c8a9ea ReplyWidget: don't show the enter hint if the reply button is disabled
Saying that ctrl-enter would submit the post at a moment when it
wouldn't may be confusing to users.

Bug: T326500
Change-Id: Ib513c8a6c36a0f607cc2034fc830dbfcdf10f554
2023-10-24 11:56:14 -05:00
David Lynch 2b69ceca51 ReplyWidget: don't show the enter hint if the target was in bodyWrapper
This stops VE UI inspectors from triggering the hint.

Bug: T326500
Change-Id: I3f62a3eb539d87cdee9d3587f9f10317ae0802bc
2023-10-24 11:55:16 -05:00
David Lynch 5b6018b244 Show a hint for ctrl-enter for comment submission if just enter is used
Bug: T326500
Change-Id: I7dc0e2ed7ccc101e896c18969b1f7d679150190b
2023-10-03 09:04:59 -05:00
Ed Sanders 2aafd08c4b Require CTRL+Enter to submit a comment, regardless of the input
Bug: T326500
Depends-On: I408adfe2b04f0d0a3e819e615e0db91c85997a9c
Change-Id: I5a4c482348b5e7dd9a4780bc4aedd8253a82ca72
2023-09-17 20:18:05 +00:00
Bartosz Dziewoński 5c612862a1 Acquire a temporary user username before previewing
When rendering a preview of the comment in order to check whether it's
signed, use the previously acquired temporary user username for the
signature.

Depends-On: Iec8a15dadd595bed0f7e54f907fbb8e192b45cf3
Bug: T331397
Change-Id: I7aeb1cc4c107ed752dc805405780a7609a6d4d3c
2023-08-22 23:42:32 +02:00
Ed Sanders 16924515df Use passive event listeners for window scroll events
TODO comments suggested using the VE helper util, but
that is no longer necessary since all our browsers
support passive events.

Change-Id: I7026d4c5013857f25f4474b3bec840af6fbf9fb6
2023-08-09 16:43:39 +01:00
Bartosz Dziewoński f7d98d7690 Redo wrapper for localStorage integration
I think the issues in T329299 are caused by partially autosaved
comments. We store data in multiple localStorage keys, and if some of
them are stored but others are not (due to exceeding storage quota),
our code can't handle the inconsistent state.

We already have a wrapper around localStorage that tries to cover up
these issues. Change it so that all values specific to an instance of
a reply tool are stored under one localStorage key. This ensures that
all updates consistently succeed or fail, with no partially stored
state.

One of the reasons we haven't done this is because this requires the
whole data to be serialized to JSON every time, but our experience
with VE change 4355d697aa shows that this is fast enough.

Extra changes:
* Remove storagePrefix, now redundant
* Remove use of createConflictableStorage, now redundant
* Prefix the key with 'mw' as advised by mw.storage documentation
* Use ES6 syntax for the new code (just for fun)
* Use consistent expiry (T339042)

Bug: T329299
Change-Id: I347115f7187fd7d6afd9c6f368441e262154233b
2023-06-19 16:45:08 +02:00
Bartosz Dziewoński 8b2e0d7be9 Update warning about logged-out editing for temp user creation
Depends-On: I2ea656a8a1704a495f1a94fede1a8829ba7325a1
Depends-On: I84ce108b4d46b4e19fad032382f8b69a1b0065d5
Bug: T332432
Change-Id: I8487d7d249c66bf3c3c60120f490a6ba72745aac
2023-05-16 18:57:46 +02:00
Bartosz Dziewoński 060c38b7e0 Don't show a link to change their preferences to temp users
Temporary users will not have access to user preferences (T330815).

Bug: T332432
Change-Id: I5d0718613494db84de800cef0544fccb9e3d8b8c
2023-05-04 20:46:54 +02:00
David Lynch 98bab18d91 Log an EditAttemptStep session-abort when refreshing the page contents
Depends-On: I0092789a425ed92e90c71b2125b195b61dcb49c3
Bug: T301582
Change-Id: I2ba94bf9ca28718dac69bb4b2b431471eff63abc
2023-03-28 22:55:45 -05:00
Bartosz Dziewoński dcecf76ff1 Centralize EditAttemptStep logging code in WikimediaEvents
PHP logging code is not moved.

* Use the new mw.track() handlers from WikimediaEvents
* Ensure that 'integration' and 'editor_interface' are set on init
  events, since they're not hard-coded in the handler any more
* Remove the setting of 'editingStatsId' tracking parameter,
  now happens in WikimediaEvents (by way of VE ArticleTargetSaver)
* Remove code connecting ve.track to mw.track, now happens in VE

This must be merged together with WikimediaEvents change
Iace4d53a972396ca5b8713000570cc47c9986034 (but we can't use
Depends-On, because CI requires code here to be removed first).

Bug: T332438
Change-Id: I0ef0a96aafdf89a4ebe32131a85b18c25744bb2c
2023-03-18 13:26:10 +00:00
Bartosz Dziewoński 1fb67ef63d Fix summary when topic title is changed after restoring from autosave
Previously, we would restore the title and the summary generated from
it, but we wouldn't restore `prevTitleText`, so we would lose track of
the fact that it was automatically generated, and stop updating it
because of that.

Instead of adding it to the stored data, let's instead stop storing
automatically generated summaries, and tweak the code to support
generating them when restoring.

Bug: T315730
Change-Id: I96420bc0a3e34373190d2c2c0db2e2175ad3156d
2023-01-24 14:28:17 +01:00
David Lynch 84620569dd Track events for the new comment notice
Bug: T301582
Change-Id: I40355502a59a7f31e465e52859b303680c1e109f
2022-11-16 11:49:50 -06:00
Ed Sanders e0855e4f41 Make virtual keyboard detection into a body class
This allows it to be re-used for other features, such as the
upcoming floating "Add topic" button.

Add some support for Android, although not used in this patch.

Change-Id: Ibd1e1ee087ac607c88a7402d0422c633700d1992
2022-11-10 23:30:53 +01:00
Ed Sanders b4eb7fc9ad Disable "Share feedback..." links by default
Will still be enabled on WMF wikis for now.

Bug: T322494
Change-Id: Ic0b79fdf459d4949d7604f5a213cb1851ca30901
2022-11-08 21:58:39 +00:00
Bartosz Dziewoński 5ed1c4a482 Add accesskey "s" to the "Reply" / "Add topic" button
Add brackets around the existing shortcut key labels, so that they
don't look quite so out-of-place next to the automatically added
accesskey label.

Bug: T278249
Change-Id: Icc0df5ba036080807ea0eb215f5526c93da78ef1
2022-10-20 22:58:25 +02:00
Ed Sanders 481b687c35 Follow-up I394f02912: Use existing class API to move button away from sticky header
Bug: T318474
Change-Id: Iab3a817e305d48e922499aad3620d93cf8aa165e
2022-10-17 14:49:36 +01:00
Bartosz Dziewoński 9b317c6f22 ReplyWidget: Ignore pending updates after tearing down
When using ReplyWidgetVisual, this would just crashes in #getValue.

When using ReplyWidgetPlain, if the timing is right, this might update
our auto-save after the value was cleared in the teardown code,
breaking the way we restore the reply after showing new comments.

Bug: T316074
Change-Id: I23c5f17a6ff9a6ec9c73a176e4cc60e3ad96e7f1
2022-09-03 06:55:42 +02:00
Bartosz Dziewoński 549fcc062b Fix focussing the reply button/link after closing the reply widget
Change-Id: I0db0fc8a93512751f8a9bcc96b048c1ab1f24f95
2022-08-02 00:32:24 +02:00
Bartosz Dziewoński e7bbc9864c ReplyWidget: Scroll save error into view after showing it
Bug: T298263
Change-Id: Ibe488bf9184dc9d9c3c8b2c3491c0baf6676ba16
2022-07-25 18:16:13 +02:00
Ed Sanders 2c2e57fd47 Show a "Return to reply/new topic" button when widget is scrolled off the screen
Bug: T310967
Change-Id: I3d1626162eb5c66ac35560792a81ce09455e86a8
2022-07-18 13:20:12 +01:00
Bartosz Dziewoński 5c3277a196 Format number of comments in reply tool new comment warning
Bug: T312033
Change-Id: If8e95b9554eddec2f00c492885575266b02cc1af
2022-07-04 17:57:41 +02:00
Ed Sanders 639fabf647 Pass useskin/mobileformat when previewing/refreshing page contents
These are required to render content correctly on mobile.

Change-Id: I421e1f172e208c4bf9d50eee68f1b0220a78dfbe
2022-06-27 17:15:28 +01:00
jenkins-bot 521760ecdc Merge "Redesign "new comments" warning" 2022-05-12 17:21:23 +00:00
Ed Sanders cf3e7c49d8 Redesign "new comments" warning
Bug: T300560
Change-Id: I5abf22b5a11c2639392a3d571c987ed5afaac2d6
2022-05-12 18:02:32 +01:00
Bartosz Dziewoński d7c390a6ca ReplyWidget: Fix 'returntoquery' handling for anon links
mw.util.getUrl() already encodes the values, encodeURIComponent()
isn't needed.

Also, slice off the leading '?' – while MediaWiki seems to accept it,
it looks like it is never present in any other place using this
parameter (this is fine even if there are no query parameters).

Bug: T308198
Change-Id: Iee3747ab53e3b0a5a0b43a7701205ac0c7f07e7f
2022-05-12 03:23:29 +02:00
Bartosz Dziewoński 584f6a020c Use tagName rather than nodeName when we know the node is an element
`tagName` is only defined on Element, and it returns its tag name.

`nodeName` is defined on Node, and it returns the tag name for Elements,
and a string like '#text' or '#document-fragment' for other types.

We were using both, which made it harder to reason about what types
we're dealing with.

Change-Id: I8e621e5872bdf78c84ec553cfbfcdbf0192f0589
2022-03-08 23:29:05 +00:00
Ed Sanders 487be9e202 Show error message as soon as we detect the parent comment has been deleted
Bug: T300504
Change-Id: I654422f7931f50503e51500508aea728adf327a1
2022-03-04 00:40:29 +00:00
Ed Sanders da49448f43 Poll for new comments in the section you are replying in
Bug: T300504
Change-Id: I3a887ab2f5260bb4893a3d680103c9d8ec767f45
2022-03-04 00:40:29 +00:00
Bartosz Dziewoński 1d43a024f9 Handle reply/topic preview entirely server-side
We were rendering the preview in a completely different way from how
we would add the real reply, and the results would be different
sometimes, particularly for multi-line comments with messed-up markup.

Render it server-side instead, in a very similar way to real replies
(generating a DOM list node and transforming it through Parsoid),
although without the whole context of the page to improve performance.

We can remove a lot of client-side code that was used solely for this.

This will allow the preview to accurately display the signatures when
we change how they are added (T278442), without us having to implement
those changes again from scratch for the preview.

Change-Id: I53341f4d4075c25b67ec3b3032bff9b8a880dcd3
2022-02-21 17:42:28 +01:00
Ed Sanders 3d0849112a ReplyWidget: Factor out #createErrorMessage
Change-Id: Ie7e34154d74c24ce8379552fdf13feba31fd401f
2022-02-07 22:44:09 +00:00
Ed Sanders e2f3c2f264 ReplyWidget: Introduce a 'refresh' teardown mode that preserves auto-save
Change-Id: Ibb04f7c2813b9d3cf2bb2434a414c86eb0a7f644
2022-02-02 18:38:22 +00:00
Ed Sanders dd9d37b555 Create MemoryStorage wrapper around mw.SafeStorage
This means we can guarantee we will be able to recover
auto-saves if we don't reload the page.

Change-Id: Ic867ae6df0c949f35cb32ec4b835688778db29ef
2022-02-02 14:59:47 +00:00
Ed Sanders 7381d9d963 Cleanup CommentController and document
* Document all methods
* Rename comment to threadItem
* Use this.threadItem instead of passing in identical
  threadItem in various methods.
* Don't pass threadItem to ReplyWidget as we already
  pass the whole CommentController.

Change-Id: If9aad0bcf9f0e4ebf3342b75631ddac8b57f7d87
2022-02-02 00:05:19 +01:00
jenkins-bot 7f329ca9a2 Merge "Enable wikis to customize the syntax used for replies" 2022-01-12 21:32:49 +00:00
Bartosz Dziewoński 7b1053300a Enable wikis to customize the syntax used for replies
The following values for configuration variables are supported:
$wgDiscussionToolsReplyIndentation = 'invisible'; (default)
$wgDiscussionToolsReplyIndentation = 'bullet';

Bug: T259864
Change-Id: Icefad79630adc6ed35687498614e6a03ede1451b
2022-01-12 20:54:04 +00:00
Bartosz Dziewoński 08d33f4ced Ignore the watch star when replying to a transcluded comment
Bug: T298917
Change-Id: I2523f5cf53151c4c32699ce0b0cadbcb7f9bd02d
2022-01-10 23:30:09 +01:00
jenkins-bot a627011ddf Merge "Use new wikipage.watchlistChange hook" 2022-01-10 22:21:17 +00:00
jenkins-bot ef13ceb9aa Merge "Fix some typos in doc comments" 2022-01-10 16:50:14 +00:00
Ed Sanders 238a6b49b4 Use new wikipage.watchlistChange hook
Bug: T294254
Depends-On: I88af8585e8fc75f77ebef867d267199aeb2c6592
Change-Id: Ic7201de567329b5752dcf52602602030d7c347f0
2021-12-21 13:00:48 +00:00