Commit Graph

173 Commits

Author SHA1 Message Date
Abijeet
c82cd6dee0 Drop support for MW 1.40
Bug: T369064
Change-Id: Id3dde7df0fe963a35c68ff5b6bdf56a268eacc6e
2024-07-04 06:46:52 +00:00
bwang
02f44318b4 Add skin-invert to ULS
Bug: T366738
Change-Id: Ia53bbd48cab5b96984778765238e9f9af0850be7
2024-06-17 15:46:46 -05:00
ksarabia
1f611b310d Add notheme to dialog
* Ensure white text is fixed in dark mode.

Bug: T365990
Change-Id: I5a3db5b322ef9b9d925d513645d771a94db8b04e
2024-06-05 12:12:28 -05:00
thiemowmde
668527a562 Avoid repeated initialization when clicking very fast
There is potentially a lot of time between when the attribute is
checked and when it is finally set. At least the two RessourceLoader
modules need to load. This can take a while, even on fast internet
connections. Just double clicking with the mouse can trigger the code
twice without the attribute being set.

The proposed solution is not the only one, but I believe moving this
single line is the most trivial one.

Bug: T358637
Change-Id: Ic9b99859841439febb83e91f70930e8676a4968a
2024-04-29 06:44:04 +00:00
thiemowmde
b086aebcc8 Avoid calling expensive ActionsMenuItemsRegistry.getItems
Change-Id: I6ba87ea91d1aca151882f96f4e164b07064bf040
2024-04-18 12:01:47 +00:00
Abijeet
ad5753ad40 Remove support for MediaWiki <= 1.39
With release of MediaWiki 1.41 we no longer need to support MW 1.39

Bug: T355105
Change-Id: I7957ca8aefee168ef11bc20905abd9944faecd73
2024-01-23 12:06:44 +00:00
NikG
0b7ae1dce6 Avoid loading ext.uls.compactlinks module for Vector 2022 skin
Bug: T353850
Change-Id: I43551be73da2126fd84ffaa0d37faec58bc47135
2024-01-16 10:43:26 +00:00
Jdlrobson
6f9ffac1c3 Use Codex styles for buttons in language overlay (attempt 2)
* Replace all instances of mw-ui markup with Codex markup
* Use codex-search-styles
* Where codex-search-styles is not installed (e.g. 1.39)
register an alias which points to @wikimedia/codex as that is
available.

Bug: T340255
Bug: T340257
Change-Id: I4f3ddfb68ea6c033ee7a49729187f4ddbc8abe5c
2023-12-20 18:53:41 +05:30
Jdlrobson
5481573341 Revert "Use Codex styles for buttons in language overlay"
This reverts commit d29050d080.

Reason for revert: I had mistakenly assumed the @wikimedia/codex
module was loaded on clicking the language button. It appears to
be added on page load.

Given T248718 it's still unclear what our policy on loading
@wikimedia/codex on page load is and given several people are out
I think it would be better to attempt this again next week, possibly
delaying further if needed.

Bug: T353071
Bug: T248718
Change-Id: I09334a1faec06a7400e61013ddda374156bf5d72
2023-12-08 22:00:26 +00:00
Jon Robson
d29050d080 Use Codex styles for buttons in language overlay
* Replace all instances of mw-ui markup with Codex markup
* Use @wikimedia/codex as it is available in 1.39
and codex-search-styles is not.

Bug: T340255
Change-Id: Id85cf3b4af782c0d93bfa3bed5f3e6cbed856f1b
2023-12-07 14:19:23 +00:00
Abijeet
d413fc2721 Fix TypeError: mw.user.isNamed is not a function
This is happening due to operator precedence. Taking a simpler
example:

  return i || typeof i === 'function' ? i() : (i + 3); where i is 1

Explanation from ChatGPT:

* First, the typeof operator is evaluated for i. Since i is 1, typeof i
returns the string 'number'. The result of this operation is `'number'.
* Then, the === operator is applied to 'number' and 'function'. The
result is false because these two strings are not equal.
* Now, we have the logical OR (||) operator. The i (which is 1) is
compared to the result of the typeof and === operations combined, which
is false. Since 1 is considered truthy, the || operation results in 1.
* After the || operation, we have the conditional (ternary) operator ? :.
In this case, the condition to the left of ? is 1, which is truthy, so
the expression after ? is evaluated.
* i() is the expression after ?. Since i is not a function, and the
condition to the left is truthy, it attempts to call i() but throws
a "TypeError: i is not a function" error.

Fiddle that demonstrates the issue: https://jsfiddle.net/t2v1w6ae/2/

Bug: T347847
Change-Id: If5e8405141dfafd53c4495c91265545ec01acab3
2023-10-27 15:24:26 +00:00
Abijeet
939c03bad1 ext.uls.interface.js: Inline isNamed() method
This module does not use ext.uls.common

Bug: T344635
Change-Id: Ib21c7f9020b8f51241299f4fb5b721c68de6a8e4
2023-08-22 19:37:27 +05:30
Abijeet
88f0045b94 ULS Frontend: Save preferences only for named users
Add a new method isNamed in ext.uls.common to use the isNamed
method if available else use the isAnon method as usual.

mw.user.isNamed was added in MW 1.40

Bug: T337780
Change-Id: I747c042a95e8edc793a2265a15ed6ba8ae9f1997
2023-08-21 11:08:26 +00:00
Jon Robson
76e7805881 Don't load mediawiki.ui.button on page load (attempt 2)
The stylesheet is needed on legacy Vector but not modern
Vector 2022 meaning Vector 2022 loads two sets of styles
for buttons.

This is a short term fix until UniversalLanguageSelector can
use Codex.

Bug: T340255
Change-Id: Ie34949e31e93dcfcabc07fa418dec06022159ca7
2023-07-17 21:28:23 +00:00
NikG
a6a338c0f7 ULS: Use quick actions icon inside page language selector
Currently, inside the page language selector of multilingual wikis
(like Commons), the user can access the language settings by clicking
the display and input setting buttons that are provided at the bottom
of the language selector. However, instead of these buttons, the quick
actions trigger should be used instead for a consistent user experience.

The trigger will only provide access to the language settings, and other
quick action items won't have any effect in this case.

Bug: T314021
Change-Id: Iaaf61c85518b4d3d44d4a92dbf5dc7fdb96282fa
2023-03-30 05:52:06 +00:00
NikG
fcba642756 Align page language selector in multilingual wikis
Align page language selector in multilingual wikis with the trigger button.

Bug: T314021
Change-Id: I68e3c55662d027a079c5204def04cdac0b105667
2023-03-29 04:21:47 +00:00
NikG
dde48f50ab Add separate buttons for 'add languages' and language settings menus
Bug: T323694
Change-Id: I23cb4687d841025905224a52b843572206fa9ddb
2023-01-25 11:47:24 +00:00
NikG
965ffc3b1a Add language settings button inside dropdown for non-content pages
NOTE: This patch is identical to patch with change-id:
Ifdf2a529b30e5a2df8867b606a525c9f7b3bdb6c

The above patch has been merged but reverted because of the usage
of '$skin->getTemplateDate()' method, which should be avoided. The
current patch replaces the usage of this method, with the usage of
the output page title ($out->getTitle()). All the rest of the code
has been kept the same.

Bug: T316559
Change-Id: Ibef9f6fd46d9055c3e0865905fb8aa8d031c1940
2023-01-11 18:05:29 +02:00
Jdlrobson
570a7d3b4e Revert "Add language settings button inside dropdown for non-content pages"
This reverts commit 5d576d05b4.

Reason for revert: Using Skin::getTemplateData method outside the
skin rendering layer is dangerous and likely a performance issue as
it means generating the rendering data twice and makes various hooks
execute multiple times.
It has caused T326538 and may be causing other issues.

Bug: T326538
Change-Id: Ie5d079deae414eb199d2a40b98d04b57439eaac4
2023-01-09 20:25:46 +00:00
NikG
5d576d05b4 Add language settings button inside dropdown for non-content pages
Bug: T316559
Change-Id: Ifdf2a529b30e5a2df8867b606a525c9f7b3bdb6c
2023-01-09 05:02:57 +00:00
NikG
de77ea992e Remove unused code from ext.uls.interface.js
During the implementation of the “addEmptyState” method, a part of code
was copied from the “addActionsMenuTrigger” method. This part is the
rendering of the action menu items (Translate button, Open Language
Settings button, etc) that is common for both the empty state and the
actions menu. During this copy, two unused lines were also copied. These
lines basically create the trigger for the actions menu (the “ellipsis”
or “cog” icon button at the bottom right corner of non-empty ULS), which
is not rendered for the ULS empty state.

This patch removes these unused lines.

Change-Id: I4776c2038cb6e1c74401c4caa6705e98181c6dca
2022-11-02 05:07:32 +00:00
Santhosh Thottingal
3450f90678 Add support for empty states to the current language selector
Bug: T290436
Change-Id: I42c5d44ec15e291d71723c9738ddb8f0d1cf0b09
2022-07-01 09:16:40 +00:00
Santhosh Thottingal
cfd6d48bc1 Load OOUI widgets only when ULS is opened
OOUI widgets are required for the actions menu dialog, but no need
to have them loaded unconditionally.

Bug: T309793
Change-Id: Icc09b88aa70af1316bd67a56b13a411ebc8f7f8a
2022-06-06 12:35:48 +05:30
NikG
9fc25cc862 Require action menu items registry at the top of uls interface module
"ext.uls.actions.menu.items.registry.js" should be required at the
top of the "ext.uls.interface.js" file. The latter is the main file
of the "ext.uls.interface" module, and it's the only one that is
executed when the module is added as an external dependency. Since,
the "mw.uls.ActionsMenuItemsRegistry" object is needed outside ULS
extension (inside ContentTranslation), the corresponding file should
be required at the top of the main file so that it's available.

Bug: T289840
Change-Id: I70ced03c09b7907c6dbf2aa35a29d5fd14b790e6
2022-04-13 07:02:57 +00:00
Santhosh Thottingal
5e6838ebdf Add actions menu inside content language selector
This patch replaces the display and input settings menu bar at the
bottom of the content language selector, with a floating icon that
opens a menu containing all the available language actions. In case
that only the language settings action is available, the language
settings menu is being opened instead.

In order to provide extensibility and support the addition of new
action items from other extensions, a registry class that inherits
from OO.Registry class is created. This class is used to create a
singleton registry object that holds all action items that should
be rendered inside the menu. Other modules/extensions can use this
registry to add new actions items to the menu, by passing the item
as argument, in the following form:
{ name: "", icon: "", text: "", handler: function() {} }

Bug: T289840
Change-Id: Iee017a9e3e6a654145e9fdd2b7df35baa348697d
2022-04-11 05:24:08 +00:00
Ed Sanders
02e17c5242 build: Update eslint-config-wikimedia to 0.22.1
Change-Id: I02692eeabb23c5b99997faa7a17d42f019148ed1
2022-03-08 09:41:49 +00:00
Abijeet
03cf7863ec Stop propagating first click handler when loading languagesettings
The languagesettings dialog does not open when clicking the
uls.trigger for the first time. This issue occurs when the user is
not logged in, ULSPosition is personal, and ULSAnonCanChangeLanguage
is false.

Without this change, the following happens:
* uls.languagesettings is loaded via uls.interface
* uls.languagesettings::hide is called via uls.languagesettings::init
* click method is triggered immediately via script in uls.interface
* uls.languagesettings::show is called
* uls.languagesettings::hide is called - triggered via ::show
  method - $( document.documentElement ).trigger( 'click' ); but
  dialog is not visible yet, so this does nothing
* uls.languagesettings::show displays the uls.languagesettings
* hide method called again via click handler for documentElement

With this change in place the hide method is not called again due to
e.stopPropagation();

Additionally add a parameter autoOpen that can be set to open the dialog
automatically.

Bug: T301882
Change-Id: I54e8172ae017c4a9c6ab5b841d9328b2f24f97a8
2022-03-08 09:39:43 +00:00
Santhosh Thottingal
5bd64b167c Improve the loading time of ULS language selector by fetching modules early
Start fetching them on mouseover without waiting for click.

Bug: T299202
Change-Id: I1ba3b8516bd01ad1bf8bb4c57d72d10ca59e06ca
2022-01-27 14:31:07 +00:00
Clare Ming
f539619b1c Simplify function to check for standalone language button.
Change-Id: I4d4afa0e5098736e40e49924e87f471b3d09257a
2022-01-14 05:58:42 +00:00
jdlrobson
26aa8d450c Hide sticky header language button with preference disabled
Adds a class to body when the ULS dialog is disabled.

Bug: T297579
Change-Id: I791c65c6a7ac5221dcf24e5db01c22c3e2e9f81a
2022-01-06 05:13:45 +00:00
bwang
c95e8e70c5 Handle "Enter" keyboard event for checkbox hack selectors
"Enter" key support for Vector ULS button was previously handled by the core checkbox hack. With the upcoming changes to the checkbox hack implementation, it needs to be handled separately.
Context: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/747877/10/resources/src/mediawiki.page.ready/checkboxHack.js#b275

Change-Id: Id74a80cda6cf460cc2b579269b8d5b2ce81c8ca5
2021-12-21 22:17:34 +00:00
Fomafix
6ee366a2c8 Reuse userCanChangeLanguage()
Change-Id: I52893ca8e2579520d21579bd7fdcb9af858a52b9
2021-11-21 19:39:25 +00:00
jdlrobson
869c721e91 Language button should prevent default click behavior
In Vector the language button is a checkbox. It uses the checkbox
hack to provide non-JS dropdown behaviour.

When the JS upgrades such a button, the checkbox behavior continues
to work. An unsatisfying hack in Vector workarounds this problem.

This provides a neater way to disable that behavior
in Vector once the button is clicked by adding support for the
well documented checkbox hack.

Bug: T283757
Change-Id: I97a69c30b27cb1ded06451389e086229561c3589
2021-09-13 07:04:33 +00:00
bwang
9e952f28af Add support for multiple ULS buttons
- Update document click handler for loading ULS
- Use data attributes to ensure ULS isnt loaded multiple times for an element

Bug: T289815
Change-Id: Iba6cbbd6c6e48a1abfda342421822e3ff2715362
2021-09-07 15:21:26 -05:00
Niklas Laxström
03d099eddc Fix regressions in ULS entry point setup
* Link in preferences is again opening ULS
* "personal" entry point now works even with compact languages
  preference disabled

I added lots of comments and refactored this code to give things
better names to make this code easier to understand and maintain
and hopefully reduce the amount of bugs in the future.

Bug: T282956
Bug: T286574
Change-Id: I9cd6776ea6664e33fd63c49dfa77c5f004fba799
2021-07-16 19:23:34 +00:00
jdlrobson
09a2b33bd6 Restore compact languages button user preference
The compact languages button user preference will be applied to
any compact language button provided by the skin, this allows users
to opt out of the feature as before.

This will be used immediately in Vector in
I436554d9d51470d277d59c2c71e08124735e12fd

Bug: T282149
Change-Id: I726c61d4c6895a28b999781752535e0ddc961744
2021-06-14 15:24:53 +00:00
Timo Tijhof
977e6c68c2 ext.uls.interface: remove some needless uses of jQuery
* $(node).prop(foo) -> node.foo

* For objects only expected to represent a single element,
  use native querySelector() and its natural null return
  fallback, instead of `$(), $.length, $()` etc.

* Fix a few minor non-voting eslint warnings that were in the CI
  output about line length and unknown type "bool".

* Remove presumed outdated comment about Vector splitting,
  per T234907.

* Rename ulsPosition to configPosition to be more clearly
  different from ulsPopupPosition.

* Remove various 'uls' prefixes of local variables,
  since this is ULS code in the ULS repository.

Change-Id: I1c617bf48283f47dc948550111c515faf173d1eb
2021-05-20 18:57:09 +00:00
Sam Smith
8e85f0d611 Fire hook when compact language links are opened
Following on from Icc64044d, we fire the
mw.uls.compact_language_links.open hook whenever that treatment is
opened (and not only the first time that the triggering element is
clicked).

Bug: T281928
Change-Id: I6fa966c22c738ca12bcbeb0225c03f3f8394ecee
2021-05-11 12:48:10 +01:00
Sam Smith
c914a7d0ab Fire hook when user clicks language button
This allows us to correctly instrument (via the
UniversalLanguageSelector instrument) this action so interaction rates
between treatments can be compared.

Bug: T273232
Bug: T273928
Change-Id: Icc64044d51c567482d4f286637366cefb7beeb3e
2021-05-10 20:46:37 +00:00
jdlrobson
ec8edeb8ec Use ev.currentTarget not ev.target
In modern Vector, the ULS trigger button has a child node which is
a span. When clicks are received on the span, they will result
in positioning relating to the span rather than the button.

The ev.currentTarget should be read outside the asynchronous function
to avoid bubbling.

Bug: T276248
Change-Id: I6e138c88e29b335b8e0bc22cf0aa07c289a5eb74
2021-04-26 16:59:47 +00:00
Niklas Laxström
2a044e1e0a Small cleanups and typo fixes
Change-Id: I4faeb4673fd5e903d2931d6071262a893d4009f5
2021-04-21 11:48:15 +00:00
Niklas Laxström
929e707c49 Simplify undo tooltip positioning
OOUI is smart enough to handle this automatically:
https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.PopupWidget-cfg-position
https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.PopupWidget-cfg-autoFlip

Change-Id: Ib8e4ea0e900b3ea0904b34d82c874227462e342e
2021-04-21 11:48:13 +00:00
Timo Tijhof
a6e0c10c54 ext.uls.interface: remove unused "ulsPopup remove" code
The ulsPopup variable is local to the showUndoTooltip() function.
If it is called multiple times, then a previous assignment of an
OO.ui.PopupWidget object would not be found here in subsequent calls.

This check can only ever be false since it is the first statement in
the function (after variable and function declarations, which don't
do anything other than call `$()`).

Change-Id: I7020c103428d01b5e48c65be695471401f588fc4
2021-04-15 07:01:13 +00:00
Niklas Laxström
50b345c83d Avoid JavaScript errors for tipsy if no entry point on the page
Bug: T278313
Change-Id: I48011eec9f7d876b914550012cc76e2209fc783c
2021-04-14 23:41:54 +00:00
libraryupgrader
e2ab4bb1c3 build: Updating dependencies
composer:
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.19.0
  The following rules are failing and were disabled:
  * compat/compat

Additional changes:
* Added the "composer phan" command to conveniently run phan.
* eslint: Renamed `wikimedia/client` profile to `client-es5` (T277085).

Change-Id: Ib31cbcd8c615d2e6abf9ee30f0f4d7b7baa54e2e
2021-04-07 11:10:07 +00:00
Niklas Laxström
3af22f60d4 Fix ULS dialog positioning in some cases
In development environment, ev.currentTarget is the button.
In Beta Cluster, however, once ext.uls.mediawiki is loaded,
it is now the document (the event has bubbled up). I do not
know what causes the difference, but we can use the target.

Bug: T276255
Change-Id: Ie4c425510293a6f2ce81e4bf4a353f2c8d86d412
2021-03-24 10:32:08 +01:00
Niklas Laxström
e8747a022d Avoid content language selector dialog resize shortly after opening
Small dialogs were resizing after loading when display and input
setting buttons were added to it. Now delay showing the dialog until
they are loaded.

Bug: T276248
Change-Id: I7033903737afedbd4be908c84d07656c468ce801
2021-03-22 18:21:16 +00:00
Niklas Laxström
8c835588f2 Fix positioning of input/display settings for new language selector
Unrelated behavior change: ULS language selection dialog is hidden while
display or input settings is open.

Also simplified dead code in addDisplaySettings.

Bug: T276248
Change-Id: Ia91a2b83e7ad4072016649230e2376b0793cbbff
2021-03-22 12:11:39 +00:00
Niklas Laxström
d3a3ac082b ULS: Avoid JS error for undo tooltip with new language button
Change-Id: Ib571152ff14754e186a3e7dd9e1c08bc22239032
2021-03-18 08:43:06 +00:00
Niklas Laxström
dd8842517e Change ULS content language selector positioning
New Vector introduced a new content language selector trigger. This
code was hardcoding a behavior that works for compact language links
but is not so appropriate for other uses in the skin, which are out
of our control.

This patch aims to be a minimal change to allow other kinds of
behavior without changing the amount of tech debt. This changes
the default ULS dialog behavior to match the requirements shown
in the task. Compact language links specific behavior is retained but
only enabled for the compact language links trigger. The behavior
is chosen depending on the value of isUsingStandaloneLanguageButton().

For future changes, I propose that mw-interlanguage-selector class will
not have any styles attached to it. Whoever creates the trigger would
be in charge of styling it. Ideally that code would also define the
positioning and other behavior, but it is less clear how that can be
abstracted in a nice and decoupled way.

Bug: T276248
Change-Id: I52da6c2f5a1f25d64f322a3c8f6105da3b244b66
2021-03-16 22:36:18 +00:00