Commit graph

98 commits

Author SHA1 Message Date
Ed Sanders 900a01772f Support reply tool on mobile
Bug: T270536
Change-Id: I94d04e9cd442f9a4e0c5924da67c43a768417a8b
2021-11-03 17:49:06 +00:00
jenkins-bot 10111ea872 Merge "Generate form tokens in the client to prevent double posting" 2021-10-29 22:32:47 +00:00
Ed Sanders 6022982eb9 Generate form tokens in the client to prevent double posting
Store used tokens in session storage.

Bug: T286409
Change-Id: I88c81689d9cf3447f6cc77c849a84d52c8b2c0db
2021-10-29 00:17:14 +01:00
jenkins-bot 37397e1769 Merge "Logging for new comments" 2021-10-28 21:54:38 +00:00
David Lynch df47f9fda3 Logging for new comments
Bug: T286076
Change-Id: Ic78a49aedcb03d160d74ba3fa9660f3583f0e568
2021-10-28 21:50:23 +00:00
Ed Sanders f4c12e120a Define documentable types in eslintrc instead of inline
These types can be passed a parameters to any file without
creating a dependency, so it makes more sense to allow
the globally.

Change-Id: I5504465fd997b46547642e7046993b370b85586e
2021-10-17 14:38:39 +01:00
Bartosz Dziewoński 59cba79c85 Compatibility with Microsoft Edge's translation feature
Bug: T292675
Change-Id: I7bc4dded7fdd522167d473dce4843d666c6e88fd
2021-10-06 21:01:10 +00:00
Bartosz Dziewoński 085ea2e8d1 Remove client-side timeout when saving pages (again)
Previously: e3e36e11ac (April 2020),
regressed: 3b31aa669d (October 2020).

Bug: T290514
Change-Id: Ifb09d62145e0b62c5b59708552a3a63b920e5b2f
2021-09-09 23:46:44 +02:00
Bartosz Dziewoński a2c662d3b2 Move reply link handling out of CommentController
Problems with the current setup:

* Each CommentController must have exactly one link.
  For T277371 we want multiple, and for T282205 we might want zero.

* CommentController objects must be constructed immediately.
  They are implemented to make this pretty fast, but it's still
  unnecessary work to do on page load.

* Only one link may be activated at a time, and activating one affects
  the styling of others, so CommentController has to use global state
  to check if it can set up and to update them.

Instead introduce ReplyLinksController, which knows about all reply
links and which one is active, and emits events that allow
CommentControllers to be constructed on demand.

Change-Id: Iabdeded2e71e598ae78703a6ff9410d0cfba397c
2021-06-30 17:05:55 +02:00
Bartosz Dziewoński ea68e1a8f0 Introduce CommentDetails to group up and document stuff we pass around
Change-Id: I809524ea8d89130548964ba9e5a73f00f6089ff4
2021-06-21 22:12:18 +02:00
Ed Sanders e995332d77 Fix eslint doc type warnings
Change-Id: Iaadc500609db3b462ef8de663f7ec34f46dc0434
2021-04-27 22:52:11 +01:00
jenkins-bot 60e1fa334f Merge "Remove deprecated dt- classes" 2021-04-23 17:35:51 +00:00
Ed Sanders eae0c1e6e1 Implement hidden tag for source mode with toolbar
Bug: T279157
Change-Id: I0244530580c7243e4db33848d36c336d8e5e8a08
2021-04-22 17:44:00 +00:00
Ed Sanders 1893405635 Code style: Move var declarations inline
Change-Id: I1686603388b050ba4ec22eff23e4806cdf262b87
2021-04-22 17:43:46 +00:00
Bartosz Dziewoński bfe6a36514 Include comment names in 'transcludedfrom' API response
As of 7ad6328223, we also use this data
to check whether comments exist on the page, not only whether they're
transcluded.

Follow-up to 42ce942c86.

Bug: T275821
Bug: T273413
Change-Id: I95eb85354e7b84cc10ab703d28315d0667696f4c
2021-04-07 22:46:36 +02:00
Ed Sanders 4c27187500 Make the source mode toolbar a user preference feature
Bug: T275950
Change-Id: I099af342f378215c68092d165dd88de1807d29d2
2021-03-31 22:40:53 +02:00
jenkins-bot c2ebb93d8a Merge "ReplyWidget: Defer scrollElementIntoView" 2021-03-24 20:00:58 +00:00
Ed Sanders d5450abe39 ReplyWidget: Defer scrollElementIntoView
Prevents VE from cancelling this scroll, and so not full scrolling the
widget into view.

Change-Id: I5b242fa2c60b87a52935f86f95d6c0efde2b74bc
2021-03-24 12:59:25 +00:00
Bartosz Dziewoński 42ce942c86 Introduce comment "names" to identify comments across revisions/pages
The existing comment IDs can't be used to find the same comment on
a different revision or page (when it's transcluded), because they
depend on the comment's parent and its position on the page.

Comment names depend only on the author and timestamp. The trade-off
is that they can't distinguish comments posted within the same minute,
or in the same edit, so we will still need the IDs sometimes.

Prefer using comment names when replying, if they're not ambiguous.
This fixes T273413 and T275821.

Heading names depend on the author and timestamp of the oldest comment.
This way we don't have to detect changes to the heading text, but we
can't distinguish headings without any comments.

Bug: T274685
Bug: T273413
Bug: T275821
Change-Id: Id85c50ba38d1e532cec106708c077b908a3fcd49
2021-03-23 16:08:42 +00:00
Ed Sanders b0a94405dc Remove deprecated dt- classes
Change-Id: I4fb59f187bf3e31fd9c31841576b3f69aec23634
2021-03-23 12:39:34 +00:00
Bartosz Dziewoński 1dbe907011 Ensure ReplyWidgetVisual#getMode always returns a mode
In some situations we didn't pass the mode in the config.

Simplify some redundant code that got messed up when we
introduced the NWE source mode.

Change-Id: Ia838fc6752d411f70c8cc6a36d84d2a851fd68bd
2021-03-18 15:15:40 +01:00
Ed Sanders ece8ff69ff Change dt- class prefix to ext-discussiontools-
Longer, but follows the style guide and less likely to conflict.

We need to account for init classes in the cache being around for
a while.

Change-Id: I738bc93393850db320fdbda2b003ca8ac40556da
2021-03-13 14:42:39 +00:00
Ed Sanders 01ac28540a Support the enable2017Wikitext option
Bug: T257391
Change-Id: If2511609035c26063203512f4b860bd0060e08af
2021-02-26 19:13:54 +00:00
Bartosz Dziewoński 444e5deb62 Make sure the Visual/Source mode selector loses focus after switching
Bug: T274423
Change-Id: Icfa4d435e4cb0ecab123c5fbdb68f23ecde99b5f
2021-02-24 12:32:14 +00:00
Ed Sanders 33c6181e79 Rename indent replacement methods
Change-Id: I8cb1b58dad068be7cfa62cab9e932463a23c6b12
2021-02-17 23:42:57 +00:00
jenkins-bot 373282dfb4 Merge "Don't show error message popups when failing to restore auto-save" 2021-01-26 17:21:32 +00:00
Bartosz Dziewoński 344038ae41 Don't show error message popups when failing to restore auto-save
Several of the messages talk about clicking the reply links, which
seems unhelpful. Also, showing a fullscreen popup on page load seems
very unhelpful too. (Itoldyouso that we shouldn't use popups.)

Bug: T268069
Change-Id: Id1312cf06200fb45a28b39481a99cc2c96603fa4
2021-01-26 03:03:19 +00:00
Bartosz Dziewoński 718457130e Move some setup code from CommentController to controller.js
We'd like the [reply] links to behave differently if other
CommentControllers are already active, but each CommentController
doesn't know anything about others; only the main controller.js does.

Change-Id: Ic21b2d40d213a325509822f703709f52aa8dc8d7
2021-01-25 23:33:58 +01:00
Bartosz Dziewoński 2798ee73f4 CommentController: Better handle clicking links while already commenting
Bug: T272389
Change-Id: If28a6cce250dca4810de3f51c0a2a4587d00649e
2021-01-19 21:21:47 +01:00
David Lynch 5696495754 Give new-section a specific init_type to distinguish it
Bug: T265099
Change-Id: I0117a41ec44263162621a34cf045b13650c6918c
2021-01-12 20:15:41 +00:00
Bartosz Dziewoński d76143bc08 Ability to add new discussion sections
1. Extend the JS modifier to allow adding top-level comments
   (that is, replies to headings). PHP modifier doesn't do this
   because we'll save the changes using paction=addtopic instead.

2. Subclass CommentController to allow adding a new heading and a
   top-level comment underneath it at the same time.

3. A lot of ugly code in ReplyWidget to customize the interface
   for this case. Much of it should probably be moved to
   CommentController/NewTopicController.

Bug: T267595
Change-Id: I9c707bb7f7aae1b92c72fb4dee436490f8c8409b
2021-01-12 20:15:28 +00:00
Bartosz Dziewoński c17a076382 Fix displaying reply links after posting a reply with dtenable=1
Bug: T267847
Change-Id: Ifb59cb942b673d9abcab563e6bc27fa1f6d5e9d7
2020-11-18 19:29:04 +01:00
Ed Sanders 3b31aa669d Create controller.getApi method with defaults
Only share API objects when it is safe to do so.

Change-Id: I4810f59ce41c43f78e0b42db6b36620b2aca1cec
2020-10-23 12:30:37 +01:00
Ed Sanders 64392af485 Add reply links on the server
Bug: T252555
Change-Id: I4e60fdbc098c1a74757d6e60fec6bcf8e5db37c1
2020-10-08 13:27:08 +01:00
Bartosz Dziewoński 48d5a67d41 ReplyWidget: Pass initial config values to #setup, not to constructor
The same ReplyWidget instance can be re-used when the user cancels
replying and then starts replying again to the same comment.

Previously, the initial values passed to the constructor (when switching
modes) would still persist in this case, even if they were incorrect.

Bug: T263061
Change-Id: I3dff007456bfd4f3149c718ae72fbf373a2e2913
2020-09-25 20:00:00 +02:00
David Lynch b988eca191 When preventing switching modes, don't log a type-specific action
Just log dialog-prevent-show.

Bug: T259673
Change-Id: I336ad745a3bd92b9a5d40fc0962be2084a6cc589
2020-09-17 16:52:32 -05:00
Ed Sanders ebaa132ebf Edit summary in advanced mode
Bug: T249391
Change-Id: Ibfd1cf77293d30b8e0d9869bbdc9aae2aa830a06
2020-09-14 22:29:54 +01:00
Bartosz Dziewoński ff05e0c0b5 Improve error message for edit conflict
Bug: T261788
Change-Id: I079517ad6e258dd23b9048f4133f18cbb087acd9
2020-09-01 22:33:25 +02:00
Ed Sanders d664e0dae4 Update watchlist status from API result
Mirrors the change made in VE in I2c844223.

Bug: T260434
Change-Id: I013e6e7b3a267de09a4e8100b98c77c22cb5b1fd
2020-08-29 20:31:58 +00:00
Ed Sanders c240f281a4 Pass through watchlist state to response data
This got lost when the watchlist updating code was refactored
out into controller.js, as it assumes that 'data' (the post data)
is still available.

Bug: T261362
Change-Id: Id274e7b8518b62dddbc3d4095d9f6cab17aa17cd
2020-08-26 23:50:06 +01:00
Ed Sanders d36ffeaa3d build: Update eslint-config-wikimedia to 0.17.0
Remove variable shadowing, and fix some documentation.

Change-Id: I08a7cbbdc0a1a409f9c4415b36c62c89535e12eb
2020-08-26 23:46:34 +01:00
Bartosz Dziewoński b706eac8bc Re-apply new reply API patches (again)
This reverts commit 4d7c98b97c.

Change-Id: I4100521efb687ec324d25e273a9c986fd5dac0d0
2020-08-19 20:05:42 +00:00
Bartosz Dziewoński 4d7c98b97c Revert new reply API (again)
Causes page corruption, in a new way we haven't seen before.

* Revert "Move page updating logic to controller.js"
  This reverts commit 54fdc6de06.
* Revert "ReplyWidget: Move clear methods from #teardown to #clear"
  This reverts commit 9b811a94e0.
* Revert "ApiDiscussionToolsEdit: Do not pass 'basetimestamp'"
  This reverts commit 7de5938a6f.
* Revert "Use DOMCompat::getOuterHTML instead of doc->saveHTML()"
  This reverts commit 7b2448d2f0.
* Revert "CommentController: Remove remains of client-side edit conflict handling"
  This reverts commit 2d038af705.
* Revert "Restore error message for when comment is deleted while replying"
  This reverts commit 655c0526d6.
* Revert "Use transcluded from API to avoid ever fetching Parsoid DOM in client"
  This reverts commit 9d0fc184fe.
* Revert "Create a 'transcludedfrom' API endpoint"
  This reverts commit 5d8f3b9051.
* Revert "Edit API for replies"
  This reverts commit 8829a1a412.

Bug: T259855
Change-Id: I6419408c6194ec0afa6b8ee604b12c1a24c6ac7b
2020-08-13 20:19:29 +02:00
Ed Sanders 54fdc6de06 Move page updating logic to controller.js
Change-Id: I9cd11f49a9dd7bf9c6aa034359244c3a21f459e8
2020-08-13 11:59:41 +01:00
Bartosz Dziewoński 2d038af705 CommentController: Remove remains of client-side edit conflict handling
In commit 8829a1a412 we kept this code
when adding the reply API, but on second thought it doesn't actually
make sense.

The reply API should never fail with an edit conflict normally, since
it makes the edit on the latest version of the page. If it does fail,
I think it's better to just show the error message. Current behavior
is to retry, and if that doesn't actually solve the problem, this ends
up in an infinite loop.

Bug: T252558
Change-Id: I5e0dcb2c42e5de4f18e99b8a761ca048a430b31e
2020-08-10 20:27:57 +02:00
Esanders c26ca107db Re-apply new reply API patches
This reverts commit 96953647c3.

* Re-apply "Edit API for replies"
  This applies commit 8829a1a412.
* Re-apply "Create a 'transcludedfrom' API endpoint"
  This applies commit 5d8f3b9051.
* Re-apply "Use transcluded from API to avoid ever fetching Parsoid DOM in client"
  This applies commit 9d0fc184fe.
* Re-apply "Restore error message for when comment is deleted while replying"
  This applies commit 655c0526d6.

Change-Id: Id20d21899f87464636022aa0683f8c03e0060117
2020-08-07 21:31:38 +02:00
Bartosz Dziewoński 96953647c3 Revert new reply API
Causes page corruption.

* Revert "Restore error message for when comment is deleted while replying"
  This reverts commit 655c0526d6.
* Revert "Use transcluded from API to avoid ever fetching Parsoid DOM in client"
  This reverts commit 9d0fc184fe.
* Revert "Create a 'transcludedfrom' API endpoint"
  This reverts commit 5d8f3b9051.
* Revert "Edit API for replies"
  This reverts commit 8829a1a412.

Bug: T259855
Change-Id: I98036f14dd900b51f20e98696e31b9b618eceee1
2020-08-07 18:18:21 +02:00
jenkins-bot 3e813316b0 Merge "Restore error message for when comment is deleted while replying" 2020-07-31 15:02:55 +00:00
Bartosz Dziewoński 655c0526d6 Restore error message for when comment is deleted while replying
Follow-up to 9d0fc184fe.

Change-Id: I4aea79259a25dbe85dc359edebedf9174ca9e0fc
2020-07-28 21:59:10 +02:00
David Lynch 6cf2f9ac56 Log when editor switching is prevented
feature: editor-switch
action: dialog-prevent-table-show / dialog-prevent-template-show /
dialog-prevent-extension-show

Bug: T257501
Change-Id: Id0704c082d98504b84795c38a2f4ff372f8c51da
2020-07-28 12:19:36 -05:00