Commit graph

49 commits

Author SHA1 Message Date
Ed Sanders 66ddcf5b64 Remove A/B test code
It's unlikely we'll do another feature A/B test any time soon.

Bug: T322492
Bug: T341491
Depends-On: Ia3712e2930fcd971bce44f568430602ce3949f23
Change-Id: I1ef4191f9466b7420a2fead571615ed6d49f873e
2024-06-21 21:08:15 +00:00
Ed Sanders dda9227947 ESLint: Manually fix remaining no-var violations
Change-Id: I4474bd0205e7a1ed8e60147e52675e3e0b93ccd9
2024-05-24 16:50:11 +01:00
Ed Sanders ca5157156a ESLint: Autofix no-var rule
Leave rule off for now as manual fixes are required.

Also temporarily disable prefer-const rule as that
will also require some manual fixes.

Change-Id: I8c3478f26f51287acb943bd38c9c1020c06b9f39
2024-05-24 16:49:36 +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
thiemowmde b2dd787039 Remove obsolete check for window.history.replaceState
I think we can remove this by now with the current browser support
matrix.

Change-Id: I6fc7b9c3d9b13ab920da75dd35ca8fdf01a318ee
2023-10-30 09:43:46 +01:00
jenkins-bot 82bab7a4e6 Merge "Show new topics subscription button on history pages" 2023-09-26 17:40:55 +00:00
Ed Sanders 7dff37e354 Show new topics subscription button on history pages
Bug: T345096
Change-Id: I5da6ac0bca900f9fe3482d247d20aaf24feb61f2
2023-08-28 19:54:56 +01:00
Bartosz Dziewoński c0f5a95504 Fix showing temp user popup after page reload
Bug: T344879
Change-Id: I1bb86468c27d4fbbd55ebcdc81ec841fbfeeb952
2023-08-24 16:09:25 +00:00
Bartosz Dziewoński 9ba9081efb Clean up old localStorage entries
Bug: T339042
Change-Id: Ia07c0234d23f16b04dd6c729fefd33c99f8cf9c6
2023-06-19 15:55:37 +00:00
Bartosz Dziewoński 316e741868 Support topic subscriptions when JavaScript is disabled
Unsubscribing was already available from Special:TopicSubscriptions
when JavaScript is disabled.

* Add links to subscribe/unsubscribe in CommentFormatter
* Update links in skin navigation
* Add support for subscribing in the actions

Bug: T321431
Change-Id: If3c4bf7df309d0d98237c3b7b9c129cc2f72cda3
2023-04-10 21:30:19 +02: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
Ed Sanders 15a8074002 Special:TopicSubscriptions: Perform unsubscribe asynchronously
Bug: T327662
Change-Id: Ib7f5cf8b075f44ac06c0a014aa1e200ccda8fe26
2023-02-04 14:30:14 +00:00
David Lynch fcb6468805 a/b test anonymous ID was being reset because of cookie prefixes
Bug: T321961
Change-Id: Ie37d0dbefaf10bf48c32461cd7d5d1b4c7882725
2022-12-16 14:45:07 -06:00
jenkins-bot af6f6e6149 Merge "Disable "Share feedback..." links by default" 2022-11-08 22:04:08 +00: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
David Lynch 9021a45966 ABtest for mobile, logged out users
Bug: T320993
Change-Id: I3530c540ec20f8806abcd7010b4d4933d1b53cfc
2022-10-31 16:23:59 -05:00
Bartosz Dziewoński 2ad3e4ad26 Fix new topic tool appearing from autosave in its own preview
Follow-up to 9425f75f47

Bug: T317005
Change-Id: I247f33e3658fbb8307a725b7c4fdc5871932b5d3
2022-10-10 23:12:18 +02:00
Bartosz Dziewoński 9425f75f47 Initialize on live preview and real-time preview too
Bug: T309423
Change-Id: I661dfb2b9159fe56edffabd9fba00cd2c56343cd
2022-07-28 19:06:32 +02:00
David Lynch b6f554a945 Ready A/B test code for topic subscriptions
Topic subscription test is going to be all logged in users only, no
transitory enrollment conditions, so we can remove the anonymous user
handling and DB writes.

Bug: T302515
Bug: T304030
Change-Id: I5e57bb9b7958576f3a04373748331a86f4626fb5
2022-05-19 01:09:40 -05:00
Bartosz Dziewoński cf255f28bf Replace mediawiki.Uri with native URL (or polyfill)
Depends-On: I7c4f9b6449a4317d68f4923fb4f198181bbfe800
Depends-On: I04464c17369ffb0dd4e7c33d2bd4db7b2d050bf4
Bug: T305010
Change-Id: I02da91010304af35f0b1f2bd4d65a84d51f29930
2022-04-08 00:35:37 +02:00
Ed Sanders d619308098 Don't show auto-save notifications when dynamically updating the page
Bug: T302327
Depends-On: If94e603458a385ba6eb15c4e29144f72e3ad12ca
Change-Id: I28f965137b986d00ac7a020ca93d8dc5195f5d4f
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
Bartosz Dziewoński 4613ae78e7 Change CommentParser into a service
Goal:
-----
To have a method like CommentParser::parse(), which just takes a node
to parse and a title and returns plain data, so that we don't need to
keep track of the config to construct a CommentParser object (the
required config like content language is provided by services) and
we don't need to keep that object around after parsing.

Changes:
--------
CommentParser.php:
* …is now a service. Constructor only takes services as arguments.
  The node and title are passed to a new parse() method.
* parse() should return plain data, but I split this part to a separate
  patch for ease of review: I49bfe019aa460651447fd383f73eafa9d7180a92.
* CommentParser still cheats and accesses global state in a few places,
  e.g. calling Title::makeTitleSafe or CommentUtils::getTitleFromUrl,
  so we can't turn its tests into true unit tests. This work is left
  for future commits.

LanguageData.php:
* …is now a service, instead of a static class.

Parser.js:
* …is not a real service, but it's changed to behave in a similar way.
  Constructor takes only the required config as argument,
  and node and title are instead passed to a new parse() method.

CommentParserTest.php:
parser.test.js:
* Can be simplified, now that we don't need a useless node and title
  to test internal methods that don't use them.

testUtils.js:
* Can be simplified, now that we don't need to override internal
  ResourceLoader stuff just to change the parser config.

Change-Id: Iadb7757debe000025e52770ca51ebcf24ca8ee66
2022-02-19 19:51:57 +01:00
David Lynch 2f1e2f80e0 Allow logged out users to be enrolled in the A/B test
For logged out users we store their test state and an anonymous
identifier in local storage. So long as the test is enabled, we include
these in any logging that occurs.

This is done entirely client-side, to avoid any cache issues caused by
state depending on cookies from PHP for logged out users.

Bug: T291307
Change-Id: Ib39e2f2146cdfdac9df5690ee3de75718f0f2731
2022-01-10 18:10:50 -06:00
David Lynch 91af0594b5 Apply an empty-state to pages with the new topic tool enabled
This includes the dtrepliedto URL functionality from
I3f81e4d77faed367606e47678b8896051982359d.

Bug: T274831
Bug: T274832
Bug: T277329
Change-Id: I035d04f30c8312b0cb42902d3bf940df1482ffb3
2021-08-04 18:46:28 -05:00
Bartosz Dziewoński ee524d6bd6 Remove cookie hack for loading unavailable tools
Bug: T277783
Change-Id: I521db842b4b7a98d8d255d418abd0ccb167c5aa0
2021-05-25 20:27:46 +02:00
Bartosz Dziewoński 2352fefb58 Migrate cookie hack users to beta feature
Bug: T277783
Change-Id: I455cab2acd0729b1c117b65cc1ede0ad9eb651cf
2021-04-14 20:36:32 +02:00
Bartosz Dziewoński 253da36101 Check if you can edit the page before opening the tools
The information is already included in the VisualEditor metadata request.

Bug: T276393
Bug: T270803
Change-Id: I45a232dcd23418da0711834bcc369a9a718006b0
2021-03-25 17:04:31 +01:00
Ed Sanders d0bcec6196 Enable DT server side via a cookie to preserve user enable hack
Bug: T265499
Change-Id: Ied330c633732651d1c4e136646afd676ceb570c7
2020-10-19 21:42:58 +01:00
Ed Sanders a2431fe006 Refactor CommentParser
* Pass rootNode to the constructor
* Rename getters to match CommentItem/HeadingItem/ThreadItem
  value classes.
* Always build the thread tree so CommentItem's always have
  and ID and replies/parent.

Change-Id: I508be9534de59016ff806e3d84edcbb1c76cb0c6
2020-07-20 23:38:10 +01:00
Ed Sanders 7ae5bbf384 Move #getAuthors from parser to ThreadItem
Change-Id: I16e513000e5366b3044b17a99da07d8d0f47a61f
2020-07-20 15:13:59 +01:00
Bartosz Dziewoński ffafc1a752 Another attempt to fix page re-initialization after updating
* Run the 'wikipage.content' hook before our initialization.
  This way collapsible elements and other changes to the page layout
  are processed before we measure where the new reply is and try to
  highlight and scroll it into view. (T252903)

* Remove the code dealing with 'mw-parser-output' and 'dt-init-done'.
  This was needed to avoid initializing twice on the same element,
  which can't happen now. (T254807)

This is much closer to the original approach Ed proposed in
I05a3c766668999f05cfe06473652429025595196 before I changed it:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/550693/7..8

Bug: T252903
Bug: T254807
Change-Id: Ibc3fcbd3c92c8eceda19b68cee9e69f6e92456f5
2020-06-24 22:56:40 +02:00
Ed Sanders 9fab4add17 Config: Separate useVisualEditor into enableVisual and use2017Wikitext
Currently use2017Wikitext is missing some implementations.

Change-Id: Ib5f9bcc588561a80ca11de85518e6fae64e5b104
2020-05-06 18:03:36 +01:00
Bartosz Dziewoński e9b583d1c3 parser: Improve merging multiple comments on one line
Now also works if the "follow-up" comment is wrapped in e.g. `<small>`.

Change-Id: Ic37cb6afdb42021f109a1818f5c4299d907ed094
2020-03-14 13:34:42 +00:00
Bartosz Dziewoński 04365c0188 Merge RL modules which are only loaded by 'ext.discussionTools.init'
Bug: T240474
Change-Id: I1b83aa18666be8f1ea6a3602b299f92574d42cb7
2020-03-14 14:33:23 +01:00
Bartosz Dziewoński 9cb497fc97 Check wgIsProbablyEditable before showing 'Reply' buttons
Bug: T240582
Change-Id: I127cd937ed2725c649dc34a8d18a29560c09fb44
2020-03-10 21:19:33 +01:00
Bartosz Dziewoński 25eb55000f Fix re-initialization after page is updated
I did this wrong in a6147ffac8, the
'dt-init-done' class was never cleared. Put it on another element.

Bug: T241861
Change-Id: I136bd9c12bcc80cff01f5d26a8a53524f0c533c6
2020-01-04 18:49:55 +01:00
Bartosz Dziewoński d7aded339c Fix crash when opening VisualEditor NWE while DiscussionTools enabled
The hook 'wikipage.content' fires whenever new "page content" is added
dynamically (e.g. after a VisualEditor edit). It's used by the code
for sortable tables, collapsible content, etc., to ensure they behave
correctly after the page content is changed without reloading the page.

We use this hook to add our "Reply" links. However, VisualEditor (and
NWE) also fires this hook for the contents of the edit notices box (to
support collapsible boxes there: T179315). Our code was crashing
because it could not find talk page content inside of that, and this
crashed VisualEditor as well.

Use .each() to handle any number of results (0, 1 or more), instead of
assuming there is always 1.

Bug: T241396
Change-Id: I877b1ae06bf1d7cd585ec6f9c1fb596cc3b86e7e
2020-01-02 14:44:18 +00:00
Bartosz Dziewoński 3e5a67010f Use module.exports/require() rather than mw.dt namespace for defining classes
The packageFiles system makes it easier to export site config data
from PHP to JS, which we need a lot of, but it's awkward when mixing
it with defining and accessing classes via a namespace like mw.dt.

The only thing remaining in mw.dt is mw.dt.pageThreads, which is
described to be "for debugging", so we should keep it easy to type.
Also we still use the namespace for documenting classes.

Everything else can be reached by require()'ing a ResourceLoader
module, for example instead of `mw.dt.ui.ReplyWidget`
you'd do `require( 'ext.discussionTools.ReplyWidget' )`.
(When debugging from browser console, use `mw.loader.require` instead.)

Change-Id: I6496abcf58c21658d6fd0f3fc1db1f7380a89df7
2019-12-10 22:47:40 +01:00
Ed Sanders a6147ffac8 Highlight comment after saving
* Init on wikipage.content hook
* Update page state variables after save

Change-Id: I05a3c766668999f05cfe06473652429025595196
2019-12-03 16:40:35 +00:00
Ed Sanders 87696c9c3c Move postReply code to controller
Change-Id: Ie66273d9b9f70b625ab7757c93b5884a01c70751
2019-11-21 08:24:57 -05:00
Ed Sanders 2b36ebe668 Implement basic saving
Depends-On: I63fa04598e0d703fe1ba715c9c5a0abbb0d7ba5b
Change-Id: Ie15f94a2b779da559615c3b1fac55c98aca59fd4
2019-11-21 08:24:09 -05:00
Ed Sanders 8a0a400449 Fix opening/closing widgets multiple times
For now don't allow more that one widget to be open at once.

Change-Id: I3bb5ad8e79853f9b4115b761bd97e9d6d835a5c4
2019-11-21 08:22:25 -05:00
Ed Sanders 41676098fa Wrap up the plain textbox in a ReplyWidget
Depends-On: I765d657c172d96c3b2e2ae5998083e4926a31f15
Change-Id: I3c71fc014b723b0762e2c2be2e0295c57ecfb40d
2019-11-21 08:22:24 -05:00
Ed Sanders 83a4539900 Fetch Parsoid document for modification
Change-Id: I479954bef3657ddce593795fd4e6b882ee31ce4d
2019-11-05 14:14:41 +00:00
Ed Sanders 16de8fb288 Rewrite list modifier in plain JS and move to separate file
Change-Id: Idc4867f1fe266de21e8964e5887aabd545d6c7ee
2019-11-05 14:13:18 +00:00
Bartosz Dziewoński 37c9f49cff Re-add debug highlighter
We removed it in c40c112514 when we added
a more practical use for the parser, but I keep wishing I had it to
experiment with the parser code.

Now it's off by default and can be used by adding &dtdebug=1 to the URL.

Change-Id: I6a92bfe7f55af0949b391606b04c3cfa0f996f2a
2019-10-24 23:21:40 +02:00
Ed Sanders 396b76dc14 Separate parser from init so it can be loaded separate
e.g. for unit tests

Change-Id: I711427721915193e070e1590ab1afc07425840a9
2019-10-23 13:44:49 +01:00
Ed Sanders c40c112514 Create simple reply widget demo
Change-Id: I03a98495364babf1b80bf64121efb09097ebe85a
2019-10-20 16:51:07 +00:00