Commit graph

293 commits

Author SHA1 Message Date
Bartosz Dziewoński f7a8ba08fb Ignore transcluded items when finding permalinks
* Keep the information about this in the API result, which we were
  previously omitting
* Use it instead of duplicating the logic client-side

Bug: T356131
Change-Id: I7e7342e9d94a171b5ef56e646871c18c8c39c44c
2024-02-04 00:07:37 +01:00
Ed Sanders df7d101cd2 Use decodeURI for comment ID searches as well as heading searches
Bug: T356199
Change-Id: I8d366c706692caf89a2af9f11c14a9aad9422b7c
2024-02-02 17:34:26 +00:00
David Lynch 7b941aae1c Add an exception for ConvenientDiscussions-style permalinks
Bug: T349653
Change-Id: I775774084bb8abf2bc99475b426d581bed306306
2024-01-30 16:44:30 -06:00
David Lynch c4bbf8756a decodeURI fragments before sending them to discussiontoolsfindcomment
Section titles containing non-ASCII characters were being passed through
URL-encoded, resulting in no results being found.

Bug: T356199
Change-Id: Iac56ee434a37baf3d170aec992d2f2d8679b6f1f
2024-01-30 14:14:18 -06:00
David Lynch d74eccad34 Comment-not-found toast not showing when enablePermalinksFrontend==false
results[ 0 ] would be undefined, causing a later JS error before the
toast could be shown.

Bug: T355165
Change-Id: Ia591a1e4db0acfa377201c355938a32f680393ce
2024-01-16 11:13:18 -06:00
Ed Sanders 4f217f4dab controller: Use replyWidgetPromise when opening new topic tool
This prevents an exception being thrown if you open the
new topic tool when a reply widget is still loading.

Change-Id: I17da48ddf91394d05cc82613ce5517f1e176750b
2024-01-05 16:20:30 +00:00
Ed Sanders 811dce7bf7 CommentController#showAndFocus: Use replyWidgetPromise
We shouldn't assume callers of this method have waited
for the replyWidget to be built.

Bug: T354292
Change-Id: Ic66b4f04b8786b07f520e329adda37efcf498dad
2024-01-05 15:26:19 +00:00
David Lynch 95121b7364 Stop comment-not-found notification always showing when requestedSince
`TEST && false || true` is always true regardless of `TEST`, we want
`TEST && (false || true)` instead.

Bug: T353568
Change-Id: I72fa6b87f43a9d8439883dfedc35fe82974b35de
2023-12-16 09:20:19 -06:00
Ed Sanders c82783a5b6 Find a heading by title in archives
* Looks for heading IDs matching "h-<heading text>-%" that once
  existed on the target page.
* For such IDs, finds where those items currently exist,
  presumably in an archive.

Pros:
* Doesn't need to know anything about the local wiki's archiving
  conventions, so can be deployed universally.

Cons:
* ID conflicts will return matches in unrelated archives, e.g.
  MassMessages.

Bug: T349653
Change-Id: Ie94efd0503e9f4689d3421babe445f9f4e2b4fb7
2023-12-06 18:39:28 +00:00
Ed Sanders 4733eb0362 Show new location of missing comments in notification
Bug: T304579
Change-Id: I5c9229a25875f0bb73c2a4dbfd0e1ac25f9c893e
2023-12-06 18:39:27 +00:00
David Lynch b3a838fc38 Notify when we can't find a comment from a reply-link
This requires something like an invalid timestamp, to produce a reply
link whose associated comment ID is going to not be findable.

Bug: T350633
Change-Id: Ib50c11096b9af9961b74309b60524a4b986e04aa
2023-11-07 11:59:03 -06:00
jenkins-bot f669b6365d Merge "Don't clear comment highlight when clicking on another link" 2023-10-13 17:44:19 +00:00
Ed Sanders 185396a8e5 Merge ReplyWidget[Plain/Visual] modules
Only a fraction of a percentage of users are still using
ReplyWidgetPlain, and keeping these modules separate:
* Adds to code complexity
* Adds to ResourceLoader module bloat
* Causes bugs when we use VE dependencies in the
  core ReplyWidget class

The disadvantage is that ReplyWidgetPlain will now be
loading all of the VE dependencies, but this will make
switching to visual mode faster.

Bug: T348834
Change-Id: Ifb0cfd43fdab761c3321ad01fa9fefca26473f86
2023-10-13 11:58:12 +01:00
Kosta Harlan 60bcf84dbb overflow menu: Factor code into its own file
Why:

- We'll reuse this functionality on desktop, so it makes sense to
  extract it to a standalone file

What:

- Remove relevant code from mobile.js and place in overflowMenu.js

Bug: T342251
Change-Id: I98f1253e8d6db31c1f71203b50911b6f1b92778b
2023-10-12 06:03:11 +00:00
Kosta Harlan c6c7dd2fb0 overflow menu: Add hooks for registering and interacting with items
Why:

- We want to allow extensions to register interactive menu items in the
  overflow menu.

What:

- Create a PHP hook to allow extensions to provide menu items
  for rendering in the overflow menu
  - The hook allows for registering resource loader modules required by
    the menu item
  - The hook passes in some contextual information, like the thread
    item data, context source object, and if the page is editable
- Create a JS hook that fires when a user selects one of the menu items
- Example implementation: Ie9afbedb4f24cbd75eb48bb21dc9f6d8d732d853

Misc:

- Remove b/c code that existed to handle a transitional period where
  JSON encoded overflow menu data did not necessarily exist in the
  parser cache
- Rename code instances of ellipsis button / data / menu to refer to
  "overflow menu"
  - Some renames will have to wait until parser cache is updated; these
    are noted with TODOs

Bug: T342251
Change-Id: I5f2a51791f8ba7619d1399a4b93111e9bb44e172
2023-10-05 15:50:33 +01:00
Ed Sanders 58cb277ced Factor out permalink code into separate file
Change-Id: Ib56a0b9766529f517ae8c5f743f891b06f3cf690
2023-10-05 10:55:00 +01:00
Bartosz Dziewoński d27d9ab7b0 Don't clear comment highlight when clicking on another link
When the user clicks anywhere on the page after following a permalink
(e.g. from a notification), we would remove the comment highlight and
the hash from the URL. Don't do it if the click is on another link:
this avoids inserting extra history entries when clicking on several
permalinks in a row.

Change-Id: I5d77dae4608f74b2be09b9cb92e39a8662529a9f
2023-10-03 22:07:12 +02:00
Bartosz Dziewoński efceaaa2ad Fix temp user popup appearing on every new page creation
Follow-up to c0f5a95504.
I missed that this code path can also be reached when
a temp user has not in fact been created.

Bug: T345569
Change-Id: Ia37760c674074b12baa17d842fa4f4d95ca20c5e
2023-09-04 17:17:06 +02: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
Ed Sanders 2f280e11c4 Wait for mobile.init before doing initial highlightTargetComment
Change-Id: If0e4f1d0e917a058eae26fd4848382ea1ac5241a
2023-08-15 17:04:17 +01:00
Bartosz Dziewoński 90f8fe5ec1 Reload page or redirect when saving an edit creates a temp account
Depends-On: I6cdc014fb39d35ce1f091b53dc3a9c4a3c95f9e9
Depends-On: I01e13ce1ebab462eeb0ba3847d4205a88965a127
Bug: T338002
Change-Id: I768e4fa2030d781bbc65428371bda17a87bd6a42
2023-07-10 22:55:58 +00:00
jenkins-bot 6de3603990 Merge "ApiDiscussionToolsEdit: Allow not returning the new revision content" 2023-06-22 21:31:32 +00:00
jenkins-bot 7c0f099529 Merge "Redo wrapper for localStorage integration" 2023-06-19 15:54:16 +00: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
jenkins-bot 3a796a228c Merge "Remove a mobile hack for post-edit messages" 2023-06-15 16:33:43 +00:00
Ed Sanders 8a8c7270cf Set URL fragment when recovering auto-save on mobile
This triggers Toggler.js in MF to open the section, which
may not be stored in sessionStorage, as DT can recover
from localStorage.

Bug: T338920
Change-Id: I695e2d423b5159ef4cdcefc0f4d4d0a05f46879b
2023-06-14 18:04:19 +01:00
Bartosz Dziewoński 6bf6105d2a ApiDiscussionToolsEdit: Allow not returning the new revision content
Sometimes we call this API and then reload the page (or navigate to
another URL), without using the page content it returns. Save some
work and some data transfer and don't generate it in those cases.

Depends-On: Ic5fac61f3ef9b2dfce6ff757f1d414a9f41f217d
Change-Id: If1aea90488e3f22cc31ac1f360139ae65acf000a
2023-06-12 20:28:45 +00:00
Bartosz Dziewoński f6e24150e9 Remove a mobile hack for post-edit messages
No longer needed since Ie0a49e5f37ac5e47066ce74d7e618d933cb30809
in MediaWiki core.

Change-Id: Id8f19cddd594cd82e2348992634015348e356e28
2023-06-12 20:28:36 +00:00
David Lynch ab23c23d48 Delay the load of VE modules until we're sure they're needed
Bug: T336020
Change-Id: I492d7b17a1ee3563f531fd565647ffd1307bddd4
2023-06-09 14:53:44 -05: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 3c8bd658cf Close mobile lede section dialog when opening a tool
Bug: T327574
Change-Id: Icdf9ca05d3a1dec189cf4604a01141b07363dec3
2023-04-18 21:21:48 +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
jenkins-bot e87d68f8c0 Merge "Revert "Remove dtenable API hack"" 2023-03-15 16:25:22 +00:00
David Lynch 722ce7d6be Clicking "reply" was broken
Follow up to I4ee024cc4760542790319f302f42b1b2389ac897

Bug: T269310
Change-Id: Ibb7b3eda52965035ed34b101582fda32f6867ba0
2023-03-09 13:26:33 -06:00
jenkins-bot 663170fb2d Merge "Support '&preload=...' etc. in new topic tool when '&dtpreload=1' is set" 2023-03-08 20:55:32 +00:00
Bartosz Dziewoński ffb8e164cb Revert "Remove dtenable API hack"
This reverts commit a1217913ae.

Unfortunately still needed. The reply links can be disabled by just
CSS, but to enable them, we also need to generate the HTML markup,
which isn't done unconditionally. An issue with links disappearing
was reported here:
https://en.wikipedia.org/wiki/Wikipedia_talk:Talk_pages_project#c-Pelagic-20230226035400-PPelberg_(WMF)-20230223000100

Change-Id: I905d3267191193362c278d23145912f4aa0ce139
2023-02-26 22:11:59 +00:00
Bartosz Dziewoński 5af3e90fec Support '&preload=...' etc. in new topic tool when '&dtpreload=1' is set
To avoid affecting existing preload forms, the new topic tool is only
used when the 'dtpreload' query parameter is also set.

Bug: T269310
Change-Id: I4ee024cc4760542790319f302f42b1b2389ac897
2023-02-15 16:39:38 +01:00
Bartosz Dziewoński d0fb22a686 Special case opening new topic tool when VE or 2017WTE is open
Depends-On: Ica75f8334ef32ffbcc59109a46624acdf271847d
Bug: T317035
Change-Id: I87dc4b85df8deae5b16ae30a2ed054bfdcfdaa73
2023-02-06 23:04:10 +00:00
jenkins-bot f42b6db413 Merge "Always reset ReplyLinksController before re-initializing" 2023-02-02 18:04:11 +00:00
jenkins-bot d7f30dcd19 Merge "Restore autosave for new topic when only title was provided" 2023-02-02 17:57:02 +00:00
Ed Sanders a1217913ae Remove dtenable API hack
This hack isn't necessary any more as reply links are always
added and enabled/disabled by CSS.

Change-Id: Ifecdd4299396f6cab7b192cde18d3001b9553f61
2023-02-02 17:20:37 +00:00
Bartosz Dziewoński 06919f9444 Always reset ReplyLinksController before re-initializing
Previously we only did it when re-initializing after saving a reply
using our tools, but it could happen for a different reason, such as a
NWE edit.

Bug: T317035
Change-Id: Ia8152fc83f74689802f8dbbc20607c9026a2a5ab
2023-01-24 16:42:43 +01:00
Bartosz Dziewoński a5a026ceba Restore autosave for new topic when only title was provided
Bug: T315730
Change-Id: Ib68ebd23d3c4ef8e577023465236b4391b00bf2c
2023-01-24 14:28:17 +01:00
jenkins-bot 87d67d4a1c Merge "Use localStorage for auto-save" 2023-01-21 09:58:30 +00:00
Ed Sanders 9d331d0c86 Use localStorage for auto-save
Bug: T218663
Depends-On: Idcf50a527e2386122d077c497477057657824646
Change-Id: I514e5340d8bce3dd10a1142e7cced49edee5c9db
2023-01-21 09:25:55 +00:00
Bartosz Dziewoński 360e3584c6 Delay API requests for preloading metadata until user interaction
Instead of doing them right after page load, only do them on
hover/touch/focus, when we can expect that the user is about to
click/tap/activate a reply link, but which lets us start the work a
fraction of a second earlier.

Bug: T325598
Change-Id: Ida4cb70d8e9ab423ad2dabca7258f92e9fca3157
2023-01-06 01:24:00 +00:00
David Lynch 013872ae22 Only preload getPageData if there's thread data for the page
This should avoid hitting the API if the DT JS is loaded off of talk
pages. At worst, if this is overly restrictive, later calls should still
load it when someone actually interacts with a reply widget.

Bug: T325477
Change-Id: If898dd4a21f1d2620c5a1e79908647070c441854
2022-12-19 03:03:02 -06:00
Jon Robson fbd951906a Use new stable API for subtitle modification
Bug: T324876
Depends-On: Id8436324e2ae2fd9f488b65b3b7bfc19611870d1
Change-Id: I4b178f67b6718fa9a84827e1804ec4eb1483f735
2022-12-13 01:13:29 +00:00
Francois Pignon de107bb6a8 Optimize some jQuery selectors
Bug: T324523
Change-Id: I57a86f3f29cd33e93db31338420af15fdb3113b9
2022-12-05 23:56:09 +00:00
Bartosz Dziewoński 37fda5e181 Clear pageDataCache whenever re-initializing
Bug: T323661
Change-Id: Ia080f4a8e79551bd16a1ce96f6851a76159d8da7
2022-12-01 21:49:08 +01:00