Commit graph

66 commits

Author SHA1 Message Date
DannyS712 5f9c1ab053 ext.abuseFilter.edit.js - minor cleanup
Avoid saving variables only used once, and other cleanup

Change-Id: Id47ebb889fa41373694f226c1a8f39cb2a6d8250
2020-09-17 17:53:33 +00:00
jaredblumer 12f9be5e69 eslint: Update to eslint-config-wikimedia 0.16.0
* Update ESLint config with Selenium WebdriverIO test suite
* Update modules and Selenium pageobjects and specs per ESLint
requirements
* Update grunt-eslint package to 23.0.0 as required by
eslint-config-wikimedia 0.16.0

Bug: T254495
Change-Id: Ibfcf9115adedf9f2c3e7dac1ac626b41fc97b7c4
2020-06-08 21:17:50 -04:00
Ed Sanders d86b74d3de eslint: Add /mediawiki rules
Change-Id: I1853e273fad3308349c79d188bc30de98fe116c4
2020-02-22 15:59:28 +00:00
Daimona Eaytoy b235e1040a Restyle edit box dimensions
Now it's always wider, and so is the "notes" field. Moreover, the
fallback textarea has the exact same size. Plus removed a parameter
which only made it hard to write a CSS rule for the textarea. Since the
textarea is generated by the same code, and we're always using it for
the same thing (filter syntax, regardless of the final goal), make it
always use the same name.

Bug: T230591
Change-Id: Ibb308e80d954c0e81aa09249c38c39572f157948
2019-08-17 18:53:13 +02:00
MarcoAurelio f07bf610c0 build: Update npm dependencies
- eslint-config-wikimedia  0.12.0  →  0.13.1
 - grunt-banana-checker      0.7.0  →   0.7.1
 - grunt-eslint             21.0.0  →  22.0.0
 - grunt-stylelint          0.10.1  →  0.11.0
 - stylelint                 9.9.0  →  10.1.0

Also npm audit (fix) them afterwards.

Addresses CVE-2019-10744.

Change-Id: I3153e269decab7f2637e2a41934e0ee07a5df760
2019-07-31 17:29:00 +00:00
Fomafix d73105191d Simplify by using mw.util.getUrl
Change-Id: I97a0716e3ff69894c86fae04234d43fcab335b4a
2019-07-03 08:43:40 +02:00
Daimona Eaytoy 553facee1e Move the throttle help tooltip to a message
Follow-up of I982d67aa62a899916a26452aceb9646df8c31232. The help text
was meant to be localized, and I probably forgot to do so in the
mentioned patch.

Change-Id: If394b02819911f9c97519b5c972977c38e6d83fa
2019-03-18 17:38:45 +01:00
jenkins-bot 001a83272d Merge "Add help links for throttle groups" 2019-03-17 09:59:25 +00:00
Daimona Eaytoy c49707e463 Make text fields use readonly instead of disabled
So that they're easier to read, and because readonly is semantically
more appropriate.

Bug: T217143
Change-Id: I76be8e7fb1cf46efd0c03cde74344be6cb2a0902
2019-02-27 11:52:59 +01:00
Daimona Eaytoy 6e2b66f96d build: Update eslint-config-wikimedia to 0.10.1
And exclude no-global-selectors for now...

Change-Id: I0cea497ff8d8c749ea4f365c968428af01e85d18
2019-02-18 19:26:42 +01:00
Daimona Eaytoy fe03de6e4f Add help links for throttle groups
Several people have reported throttle groups being hard to use, mostly
because the field doesn't have options with the usable groups. This is
because users can combine valid groups in many ways, and thus we don't
provide options. However, let's add an help link pointing to mw.org.

Change-Id: I982d67aa62a899916a26452aceb9646df8c31232
2019-01-24 12:58:41 +01:00
jenkins-bot 9ce4afb010 Merge "Add names to anonymous JS function" 2019-01-19 13:27:43 +00:00
jenkins-bot b35ba5af45 Merge "Warn the user if they try to leave the page with unsaved changes" 2019-01-19 12:57:50 +00:00
jenkins-bot 575646393b Merge "Improve code readability" 2019-01-19 12:11:06 +00:00
Daimona Eaytoy 38749b46bb Warn the user if they try to leave the page with unsaved changes
While editing filters, sometimes it happen that you make some change,
forget about it and then reload/close the page, and no warnings will be
issued. This patch makes use of the core module used for normal page
editing to display a warning if trying to leave a filter editing page
with any unsaved change (both to the filter pattern or other form
elements).

Change-Id: I78d79215565d5c82028b1a2a4276497ccbffdea2
2018-12-04 13:06:46 +01:00
Ed Sanders 052c68f639 build: Update eslint-config-wikimedia to 0.9.0
Change-Id: Ia31860b5fcf43ec512fb82c2c332ac08cbf12cf1
2018-11-23 15:50:29 +00:00
Ed Sanders 663a66dc0a Remove obsolete aliases from closures
Bug: T208951
Change-Id: I1330672b62c9d8f49cf31264995e7a07b467178f
2018-11-23 15:44:58 +00:00
Daimona Eaytoy 7427333ed5 Improve code readability
Simplify some logic constructs, reduce the amount of return statements
inside methods, explicitly declare variables before using them, reduce
code duplication, add names to JS anonymous function to produce clearer
stack traces.

Change-Id: Ife4546a91c30d4c519d09a712ba56a2f33abe579
2018-11-19 16:01:37 +01:00
Daimona Eaytoy 9d02b3947a Add names to anonymous JS function
To have clearer stack traces.

Change-Id: Ia086cef5dc916c21a94af7856715754b6bfb496b
2018-11-19 15:46:09 +01:00
Daimona Eaytoy d3a8491c3f Change throttle selector to restore old functionality, overall improvement
Long (sigh) explanation in T203587#4569698. Also, simplified the way
TagMultiselect are generated, this one and the one for change tags.
This new selector is back-compat both with the old textarea and the OOUI
checkboxMultiselect; actually, this one is //fully// compatible with the
old textarea.
Add validation for throttle parameters and unit tests for validation
(split from I976c95658cddb2585910b6f8a5f047aadc4e4d47).
Added a trim when retrieving throttle identifier to allow syntax like
'ip, user'.
Improved the message shown on history.
Re-added the maintenance script to clean DB.

As I wrote in the task, a review by two other people would be great, at
least for the maintenance script (it could potentially break the DB).

Bug: T203587
Bug: T203336
Bug: T203584
Bug: T203585
Depends-On: I3b2e763bd8835207dc5df1db43d3e1881e6961c3
Change-Id: I7831dbb0bab55807392ac1f7915d6cb0cb713593
2018-11-14 12:51:36 +01:00
Daimona Eaytoy f780704d14 Open the page for editing warning message in a new tab
Or in a new window, depending on user settings. In any case, not in the
current window without warning before leaving.

Change-Id: Ia64db1f9491d9cc55bee99321f0f14bd78785140
2018-10-12 10:40:05 +02:00
se4598 9d12e1b353 Allow selecting custom disallow message
You can now select a custom message to be displayed for disallowing a edit
the same way as for warn mode. This can be the same or a totally different
message.

This also solves the usecase, when a edit filter is set to warn AND disallow,
to be able to show the user a custom message, but the generic is shown
on the second try (disallow). Now it can be only set to disallow.

Bug: T27086
Change-Id: Ic1de03a6944c43a346fa317ee0a217551f0d284a
2018-10-11 10:35:01 +02:00
Daimona Eaytoy e60dacbbea Fix code comments
Fixed some comments adding explanations, fixing syntax, and parameter types
for docblocks. Also fixed some whitespace mess, and added a missing use
statement.

Change-Id: I3547c90bdaa2cab5443e8bf0c63b217fe6ba663f
2018-10-03 16:45:03 +02:00
jenkins-bot 9cd7886f73 Merge "Change events used with the Ace editor" 2018-09-05 17:28:15 +00:00
Daimona Eaytoy 063bdf0a4b Change events used with the Ace editor
Use an Ace-builtin "change" event on the editor so that it also triggers
for search&replace. Also, use "change" instead of "keyup" on the
textarea, just to be sure not to miss anything.

Bug: T203391
Change-Id: Ib246c30a575d140642c74e8ac08b24bdeaaf0347
2018-09-03 16:05:14 +02:00
Daimona Eaytoy db4a0a1eec Break long lines in JS code
Bug: T203365
Change-Id: If9d5f8d4c341f2f273eda3f1fd54d59a04a9d263
2018-09-03 10:49:24 +02:00
Daimona Eaytoy 4399be933d Use OOUI infusion for the change tags field in ViewEdit
Since this is what it's meant to be for. Better, cleaner, safer.

Change-Id: Ib5f632ac708aeff62b50c91ef60c547036481834
2018-08-22 15:27:06 +02:00
Daimona Eaytoy 2fc44e9d18 Focus the Ace editor after having added text from dropdown
The classic editor (textarea) already takes focus, while for Ace we need
to explicitly call its focus() method.

Bug: T202480
Change-Id: I8dcf54e46e730b2879b09b4e21198b2ef1131706
2018-08-22 10:57:15 +02:00
Matěj Suchánek 37908c7935 Fix jQuery selector when editing filters
Bug: T200604
Change-Id: Ife88ae0f4b9dca0492c1d9dbfc22a975dd7b6b31
2018-07-28 15:23:14 +02:00
Daimona Eaytoy b825e396b5 Switch editing interface to OOUI & improve NoJS usability
This settles almost everything, leaving the tags part ready to be
further improved in the follow-ups.
Also, replaced some fields with totally different ones, improved the
warn preview area and improved a bit nojs experience by hiding unusable
buttons.

Bug: T132284
Bug: T154749
Change-Id: I7a5caa862a32f9792140c6a4d9708a2d20472672
2018-07-17 14:49:50 +02:00
Daimona Eaytoy 94b570673e Ace: use built-in function indexToPosition
I copied that function from github, but I realised that ace already
includes it, so no reason to have unnecessary function declarations.
Also, this fixes a minor bug that prevents the caret from moving to the
very last character when checking syntax.

Change-Id: Ia243b75803008b801dc24faaacbe7844618ccb45
2018-06-04 11:21:44 +00:00
Daimona Eaytoy 632c8e77e2 Don't let enabled filters be marked as deleted
Adds both client-side and server-side validation.

Bug: T156619
Change-Id: If16975dd394cfdb3c57ff263366c2fc865de362a
2018-05-02 22:20:53 +00:00
Daimona Eaytoy fa413d431e Use the old textarea if JavaScript is disabled
Basically, with this we always start with a functioning textarea. If JS
is enabled (and CodeEditor installed), it gets then replaced by the Ace
editor.

Bug: T192241
Change-Id: Id4dc1debf0240d5b336f4d9ab5b363c240f08807
2018-04-23 23:43:23 +00:00
Daimona Eaytoy 7450fb1d62 Switch /test and /examine/# to OOUI
Standardized Special:AbuseFilter/test and /examine/# to OOUI. They need
to be updated together, since they share the same load filter button
(now centralized) which needs to be handled in a different way.

Bug: T132284
Bug: T58367
Bug: T58368
Depends-On: If3d6a994142e34686bb7fc9f09093f751b599485
Change-Id: Ib935e8c9706e987468e52ec2ad1c7219b35fb9d5
2018-03-30 13:12:36 -04:00
Daimona Eaytoy 520ebea2cb Switch footer of editor to OOUI
Conversion of the builder dropdown, the syntax checker button and also
the button for switching editor coming from ace.

Bug: T132284
Depends-On: If3d6a994142e34686bb7fc9f09093f751b599485
Change-Id: Ic7f17437f4f0dcc0ea0edbab24eb976e2f76bdbd
2018-03-30 12:58:45 -04:00
jenkins-bot c67ab4a061 Merge "Revert "Revert "Switch editor to Ace and provide syntax highlight""" 2018-03-30 15:29:01 +00:00
Daimona Eaytoy 3350183fe3 Revert "Revert "Switch editor to Ace and provide syntax highlight""
Make Ace use a fixed size in em.

This reverts commit 272775ff81.

Change-Id: I9b439b20df91eb367bcef4b6f33ff087aded0b62
2018-03-30 11:10:16 -04:00
jenkins-bot 899fd5783b Merge "Revert "Switch editor to Ace and provide syntax highlight"" 2018-03-30 02:14:15 +00:00
Huji 272775ff81 Revert "Switch editor to Ace and provide syntax highlight"
This reverts commit 89e6778793.

Change-Id: I41aee10fdd5633d56692334696fb750f41b15433
2018-03-30 02:07:00 +00:00
jenkins-bot f903aa92d4 Merge "Switch editor to Ace and provide syntax highlight" 2018-03-30 02:02:00 +00:00
Daimona Eaytoy 89e6778793 Switch editor to Ace and provide syntax highlight
Replace the conditions textarea with Ace editor for editing and testing
filter. This uses a soft dependency on CodeEditor; if the latter isn't
installed, the classic textarea is used. The user is still able to
switch between the editors on the go; the new buttons may look a bit
ugly now, but after switching to OOUI they should get much better.
Finally, added a custom syntax highlight for AbuseFilter rules.

Bug: T39192
Change-Id: If3d6a994142e34686bb7fc9f09093f751b599485
2018-03-23 12:39:22 +01:00
Melos 799a2fb1ed Always show abuse filter public comments as plain text
Public comments are parsed in some places and they are
shown as plain text in others. Always show them as
plain text instead of parse them.

Bug: T173249
Bug: T141670
Change-Id: I173ffab1a99c1536cca260b76be0d95a4966b139
2018-03-15 20:14:00 -04:00
James D. Forrester de2a7b07d4 build: Replace jshint with eslint
Bug: T186753
Change-Id: I067adf86a220d59ff1693bef74d7590d4c63d3c2
2018-02-08 16:26:50 +00:00
Alex Monk 086dd0d741 Use prop instead of removeAttr for syntax check disabled status
Bug: T169385
Change-Id: Ia3f598a3ccd0c12ec0c35450ed12f0ddbd739962
2017-08-09 16:58:00 +00:00
Matěj Suchánek 20c10c8159 Remove all CSS classes from indicator to avoid collision
When you tested filter against the change (with failure) and then
checked the syntax (with success), the new CSS class was overriden by
the old one, that's why the red X stayed.

Bug: T129753
Change-Id: I34cdba72f0b0e24e97083ba6b47554d0c8b826cf
2017-07-14 17:55:19 +00:00
Matěj Suchánek eb8541eab5 Use mw.Api.parse() for previewing warnings
And add the filter id as the second parameter to the message.

Bug: T68351
Change-Id: Iee8ac20d3cc9c0f6340ec6f339b0e51d7c88f976
2017-05-31 09:06:31 +02:00
helderwiki 20dabefe22 Improve error handling for HTTP requests
The API provides more details about HTTP errors, so show these to
the user instead of a generic "An unknown error occurred."

Bug: 68767
Change-Id: I3188b9729c815a07c65a7dbef4d40deebe29b87d
2014-08-02 11:56:32 +00:00
se4598 8125decd66 fix "JQMIGRATE: jQuery.fn.toggle(handler, handler...) is deprecated"
Bug: 65804
Change-Id: Ie25caa8ee2c2be9c5a2c13b3415fcd2d32ad7fb1
2014-06-08 20:59:50 +02:00
Sorawee Porncharoenwase 37d1a5c3b1 Preload abusefilter-warning if created page is blank
This patch makes a new warning message preload the text 
of MediaWiki:abusefilter-warning when the message is created 
through the filter editing view. Generally, it will make 
users more convenient because filter warnings
usually have a pattern, and preloading a pattern from the page
will save time. This patch doesn't work when
MediaWiki:abusefilter-warning hasn't created yet.

Change-Id: Ia327463c52060bfd55c0a1fa6fcec592cc3c3999
2014-01-26 15:22:28 +00:00
Helder.wiki c6a0a7daca Load filter conditions when the user presses ENTER
Cleanup:
- Trim the field value before trying to load the filter
- Add the pattern to the box using .val() instead of .text(), to
  update the content even if the user has made changes to it

Bug: 51402
Change-Id: I4ae671941571dce206448424f8e996cb99ac8d41
2013-07-23 14:01:02 -03:00