Commit graph

235 commits

Author SHA1 Message Date
Ed Sanders 776fca861f Update categories list when reloading page
Change-Id: I0f6b61eec33dca26e128bd60bb027a5a42a3f9ee
2022-08-24 13:13:12 +01:00
Ed Sanders dec755c802 Fix updating of subtitle when reloading page for new comments
The subtitle prop and some others were missing from the action=parse
request. Use the same props as the VE edit API.

Change-Id: I8e9cc735d3ee50dfe0fbe0349713d88654ad9fd1
2022-08-24 13:05:07 +01:00
Ed Sanders 9adafd43a1 Show latest comment info in subtitle
Bug: T306675
Change-Id: I1400dbb50cdf8a0a5e23ce533c84fad96f3fae16
2022-08-23 19:31:40 +00:00
Ed Sanders c221a2fb7b Update permalinks when refreshing the page
Bug: T315830
Change-Id: I56620e9d31799640241430ceba6da959a0c8405e
2022-08-22 12:15:34 +01:00
jenkins-bot 47158f28dc Merge "Fire new 'wikipage.tableOfContents' hook to update TOC after save" 2022-08-01 19:49:39 +00:00
Bartosz Dziewoński f4a9d5b8f9 Fire new 'wikipage.tableOfContents' hook to update TOC after save
Bug: T294950
Depends-On: Icaeda68ded94a04edef7a3629385eeb232048684
Depends-On: I1644a74370b42b04d0db167879f7de2207ebfcf5
Change-Id: Ic3ef4e332ade8918778b6aaaa8eaf7e98f0a8d7d
2022-07-28 23:37:29 +02:00
Ed Sanders 98b5371a8c Have "Read as wiki page" link remove all DT content changes
As well as visual enhancements:
* Reply links
* Mobile lede section hiding

Change-Id: I14d591830620edf8bbaccb76b4bce0e87971d7c3
2022-06-30 23:02:50 +01:00
jenkins-bot cd86854235 Merge "Pass useskin/mobileformat when previewing/refreshing page contents" 2022-06-27 21:57:02 +00:00
Ed Sanders d00fa80ff4 Use $.html to refresh page after save
As per If549a0e647ce8.

Change-Id: I6afdc4a80615617678d2d31c2c9e5830b07a6ef0
2022-06-27 17:34:32 +01: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
Ed Sanders 7fc5a0c29d Topic containers: Design iterations
Bug: T310914
Change-Id: I9000f9902d612c58c6b3bc8b762232ca6dd9724f
2022-06-25 12:54:39 +00:00
Ed Sanders da64c43ccc Show thread metadata in section headers
Bug: T269950
Change-Id: Ifa47ddcbccf288be0bbecd5961eab7c5122aab7b
2022-06-23 17:17:09 +01:00
Bartosz Dziewoński 1ec97b18d9 Fix race condition causing highlights to not be cleared
We cleared the highlight outside the setTimeout(), then set a new one
inside the setTimeout(). If this method was called twice quickly, two
highlights would be created, and the first one of them would become
impossible to clear.

Move the setTimeout() outside of the method to avoid this.

Bug: T311021
Change-Id: Ic8b2cf2a782a429c4ea073871efd215f4b300ed8
2022-06-20 22:51:39 +02:00
Bartosz Dziewoński a0750129e7 Set rootNode for items from in ThreadItemSet#newFromAnnotatedNodes
It's needed for the fix for T303396 to work correctly (in the case
where there's exactly 1 thread item on the page), and for the
highlight improvements in Iadbf83e02801fd9bd6336c84015994ee2819ce51.

Change-Id: I2b2f5535ebbf792910133622a271ac1491c74de6
2022-06-20 19:03:09 +02:00
Bartosz Dziewoński df22a66e42 topicsubscription: Reduce code duplication
Rather than making our own ThreadItem objects from scratch,
reuse those used by the rest of the code.

Change-Id: I67f5ea3ad26baffe51b66d0c75467ac00185dd0a
2022-06-20 19:02:46 +02:00
Ed Sanders af5b9a9b46 ReplyWidgetVisual: Pass in memory-wrapped store to VE
We switched to our memory-wrapped store everywhere outside the
VE surface, but not in the VE surface itself.

Change the way we construct MemoryStorage objects so that they can
be constructed from a specific mw.SafeStorage instance.

Ensure MemoryStorage's cache is populated with initial storage object
data, and that the cache is copied over when we create derivative
objectes.

Bug: T310438
Change-Id: I652428f114dc5169195887cb8ca719ae196bb76f
2022-06-17 14:05:54 +01:00
Bartosz Dziewoński 28124e7f1e Add attributes for Minerva click tracking
Bug: T295490
Change-Id: I05fa96280c8dacc801b071d22086568ee0f11d86
2022-05-27 03:55:09 +02:00
jenkins-bot 37b28fb36b Merge "Fix reply links sometimes not working after visiting action=edit&section=new with new topic tool enabled" 2022-05-15 13:45:06 +00:00
Bartosz Dziewoński 28db9b8350 Fix error message when trying to reply to transcluded comment on a protected page
If the user can't edit, tell them why, instead of trying to
advise them to use the edit button that they cannot see.

Bug: T303110
Change-Id: Ibc41732a55443331e432987e630976610901c599
2022-05-13 01:56:51 +02:00
Bartosz Dziewoński f534e78cde Fix reply links sometimes not working after visiting action=edit&section=new with new topic tool enabled
getPageData() had an optimization where, when it was called with
isNewTopic=true, it would skip querying 'linterrors' and
'transcludedfrom' data and return fake empty responses.

The issue is that they were cached, and then returned when it was
called with isNewTopic=false later.

Remove this optimization, as we make those queries anyway on init.

Change-Id: I1990b16f574c1aec385bd0fa46a9f39c6c2c1df2
2022-05-12 03:38:31 +02:00
Bartosz Dziewoński 1ad185e097 Avoid duplicating page content if there are multiple .mw-parser-output elements
Bug: T306388
Change-Id: Iaee2999f02929d562ae9f78ef50913d515c72bb3
2022-04-19 21:46:59 +02:00
Ed Sanders 64c76f54a3 Don't reload the page on mobile
Bug: T301839
Depends-On: I0985dd5e8db6f82df882c6f4de4ef3821a0eef13
Change-Id: Ic02de79627b813c1fa6f0e537288206bfb1dbd1c
2022-04-12 18:23:57 +01:00
David Lynch 0fc474d66f Log saveSuccess more consistently
Cases where saveSuccess wasn't logged:
* creating a new page with the New Topic tool
* any replies on mobile
* successful replies made through transclusions which then couldn't
  purge the current page

These were all cases where we abandoned the post-save process early to
reload the page.

Bug: T305541
Change-Id: I1366a3e0a4b03ac67f926284f1aa718ae552d852
2022-04-06 11:37:29 -05:00
Ed Sanders 457f6eb7d1 Fix highlighting of comments when reloading
The CommentController stores a list of the new comments that
triggered the reload warning. Just highlight all the comments
in this list, as we always reload to the revision we got from
the same API call.

Bug: T303261
Change-Id: I960f3cf33e25004bad6ab6df907121a87555aaf4
2022-03-09 14:47:03 +00:00
Ed Sanders 4f91a0b883 Highlight new comments when refreshing
Bug: T300215
Change-Id: I72655e05dccbe96f9dfa4ccca4e91b3edf133d97
2022-03-04 00:40:29 +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 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
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
Ed Sanders 1032db4878 Move (auto) topic subscription initialisation to separate file
Bug: T302805
Change-Id: Ia901cba731233719dd1d5916eb5211a551d34091
2022-03-01 21:27:08 +00:00
Ed Sanders c70c1e76f3 Only bind page-level handlers once
Raise scope of pageThreads variable (renamed from `result`)
so we don't have to re-bind when it is updated, and use a
flag to ensure we only bind the handlers once.

Bug: T302810
Change-Id: I0a5b122b8e3f656f28f3dd4fa6aca8e7839be06b
2022-03-01 21:26:36 +00:00
Ed Sanders f5d4df12a9 Move highlightPublishedComment to highlighter.js
Bug: T302805
Change-Id: I429148b16f790e1d1f5cbbd84fc35139727b4402
2022-03-01 14:44:21 +00:00
Ed Sanders ecbe75c453 Move highlighting methods to separate file
Bug: T302805
Change-Id: Ie4a8ea3f351015ab5bb4b817ef997cf6d77428da
2022-03-01 14:29:10 +00:00
Bartosz Dziewoński be74938855 Warn when target comments in a link can't be found
Links are generated to:
* Single comments, by a user or by a notification
* Potentially multiple comments (new comments since T),
  usually just by notifications.

If in either case no comments are found to highlight, warn the
user so they get some visual feedback that the notification worked
as expected, but that the comment was just deleted since.

Bug: T301602
Change-Id: I090c904481cf6f3e9f964fa43b10001e75b0bc90
2022-02-28 21:58:59 +00:00
Ed Sanders dc8b4e8d4f Highlight all comments since the oldest in a thread bundle
For topic subscriptions, further restrict this to comments
in the same thread.

Bug: T302014
Change-Id: Ifba218871122901031a891034e709b886fc406da
2022-02-28 21:58:10 +00:00
Bartosz Dziewoński 8e44b43df0 Split off ThreadItemSet from CommentParser
Goal:
-----
Finishing the work from Iadb7757debe000025e52770ca51ebcf24ca8ee66
by changing CommentParser::parse() to return a data object, instead of
the whole parser.

Changes:
--------
ThreadItemSet.php:
ThreadItemSet.js:
* New data class to access the results of parsing a discussion. Most
  methods and properties are moved from CommentParser with no changes.

CommentParser.php:
Parser.js:
* parse() returns a new ThreadItemSet.
* Remove methods moved to ThreadItemSet.
* Placeholder headings are generated slightly differently, as we process
  things in a different order.
* Grouping threads and computing IDs/names is no longer lazy. We always
  needed IDs/names anyway.
* computeId() explicitly uses a ThreadItemSet to check the existing IDs
  when de-duplicating.

controller.js:
* Move the code for turning some nodes annotated by CommentFormatter
  into a ThreadItemSet (previously a Parser) from controller#init to
  ThreadItemSet.static.newFromAnnotatedNodes, and rewrite it to handle
  assigning parents/replies and recalculating legacy IDs more nicely.
* mw.dt.pageThreads is now a ThreadItemSet.

Change-Id: I49bfe019aa460651447fd383f73eafa9d7180a92
2022-02-21 16:22:32 +00: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
jenkins-bot e82a4d86f3 Merge "Don't clear target comment highlight when Ctrl-clicking" 2022-02-08 19:49:44 +00:00
Ed Sanders 025130fcd2 Don't prompt to reload the page if the reply widget is open
Only show the reload prompt if the 'disappeared' error is detected
when the reply widget is loading. Don't show it if we failed
to save, as it suggests you will not lose content if you reload.

Change-Id: I106f274e180dc97b540d729e31aae575c43f29f0
2022-02-07 22:45:35 +00:00
jenkins-bot 4ac8e94084 Merge "ReplyWidget: Introduce a 'refresh' teardown mode that preserves auto-save" 2022-02-07 21:45:13 +00:00
Bartosz Dziewoński 909f1383d4 Don't clear target comment highlight when Ctrl-clicking
It annoys me when Ctrl-click clears it but middle-click does not.

Change-Id: I8636140df25d44ac79cb2bc0d1aebecc62c4db5d
2022-02-07 21:29:01 +00:00
Ed Sanders 7cad692afa Move ApiDiscussionTools to ApiDiscussionToolsPageInfo
Also remove 'paction' param, and instead make 'transcludedFrom' a
property of the result object.

Change-Id: I0a289f6d71e4708afff0b52066b1ed6faf76b9ae
2022-02-07 16:50:02 +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
jenkins-bot b0b965512e Merge "Create MemoryStorage wrapper around mw.SafeStorage" 2022-02-02 17:27:37 +00:00
Ed Sanders cb5d585b93 Update wgCurRevisionId/wgRevisionId when refreshing the page
Change-Id: I2b1a7a6fe539a8a4bd5e3f865e4bb7464913d9e0
2022-02-02 16:46:57 +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
Bartosz Dziewoński fb474efb2b controller: Separate updating page contents from saving the page
Bug: T300502
Change-Id: I52c0a648ee15cc61890413a269708a6cb2bd4df8
2022-02-02 00:42:41 +01: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
Ed Sanders cb828828e2 controller: Fix typo in documentation
Change-Id: Ia68bcac6be0c59146655c5cbce872ea9b9304e37
2022-01-31 15:03:05 +00:00
Bartosz Dziewoński 35d6a0d853 Restore scrolling to comments when clicking a bundled notification
Follow-up to ebd37369ce.

Bug: T299813
Change-Id: Idd95f21921a89633f5d85aa993ba07aaab59ff20
2022-01-22 03:48:37 +01:00
Ed Sanders 34011b7a07 Parser: Pass in title of page being parsed
Will be used to parse selflinks in the future.

Change-Id: I2bc29d1c5c69cb6309f582f162f9af7d96ce8913
2022-01-12 21:17:59 +00:00