We have two bundles related to jQuery-UI inside common.py:
'jquery-ui': {
'source_filenames': (
'js/libs/jquery-ui-1.10.3.custom/css/ui-lightness/jquery-ui-1.10.3.custom.min.css',
'styles/libs/jqueryui/moz-jquery-plugins.css',
'css/jquery-ui-customizations.scss',
),
'output_filename': 'build/styles/jquery-ui.css',
}
...
'jquery-ui': {
'source_filenames': (
'js/libs/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js',
'js/libs/jquery-ajax-prefilter.js',
'js/moz-jquery-plugins.js',
),
'output_filename': 'build/js/jquery-ui.js',
}
It is being used in the following files:
kuma/kuma/dashboards/jinja2/dashboards/revisions.html
kuma/kuma/users/jinja2/users/ban_user_and_cleanup_summary.html
kuma/kuma/users/jinja2/users/ban_user_and_cleanup.html
kuma/kuma/users/jinja2/users/user_detail.html
kuma/kuma/users/jinja2/users/user_edit.html
kuma/kuma/wiki/jinja2/wiki/create.html
kuma/kuma/wiki/jinja2/wiki/edit.html
kuma/kuma/wiki/jinja2/wiki/move.html
kuma/kuma/wiki/jinja2/wiki/translate.html
Determine answers to the following:
/users/If we cannot entirely remove jQuery-UI, we might want to look at upgrading it as the legacy version of this library is currently set to 1.11.4 and we are on 1.10.3.
Some of this is related to wiki editing which will go away at some point in 2020 but, dashboards and /users/ is unrelated and will still live on for some time(years?)
Research
Share thought, comments, ideas
How badly does the above break if we remove jQuery-UI?
The following would need to be replaced
1.1 How much work would it be to fix what breaks?
Autocomplete
The autocomplete input is built as a jquery-ui custom widget extension
This could be replaced w/ a 100% vanilla solution using <datalist> + AJAX fetch but browser compatibility for that element is spotty at best (https://caniuse.com/#feat=datalist)
The awesomeplete lib could be used as a non-vanilla solution.
The source for the autocomplete widget definition is located in /kuma/static/js/moz-jquery-plugins.js
On evaluation, the widget is attached to the global $ namespace. It gets called as part of a $ chain, for example...
kuma/static/js/dashboard.js
$('#id_topic').mozillaAutocomplete({
minLength: 3,
labelField: 'label',
autocompleteUrl: '/' + currentLocale + '/dashboards/topic_lookup',
buildRequestData: function (req) {
// Should add locale value here
req.locale = getFilterLocale();
req.topic = req.term;
return req;
}
});
Datepicker
The datepicker input is a built-in feature of jquery-ui
It could be replace w/ <input type="date"> but again, browser support isn't 100% (https://caniuse.com/#search=input-date)
The datepicker is bound to a HTML element as part of a $ call chain. Ex...
kuma/static/js/dashboard.js
$('#id_start_date, #id_end_date').datepicker();
Tag-It
The tag-it input is a built-in feature of jquery-ui
There is no vanilla HTML/JS feature that mimics a 'list of tags w/ autocompletion' input.
The awesomeplete lib will work as an alternative.
The tagit is bound to a HTML element as part of a $ call chain. Ex...
kuma/static/users.js
$('#tagit-interests').tagit({
availableTags: window.INTEREST_SUGGESTIONS,
allowSpaces: true,
singleField: true,
singleFieldNode: $('#id_user-interests'),
onTagAdded: rebuildExpertiseTaglist,
onTagRemoved: rebuildExpertiseTaglist,
onTagClicked: rebuildExpertiseTaglist
});
Bound Elements
#id_user - mozillaAutocomplete#id_topic - mozillaAutocomplete#id_start_date - datepicker#id_end_date - datepickerThe elements are bound in kuma/static/js/dashboard.js
No jquery-ui element bindings found, no .ui-* styles used
No jquery-ui element bindings found, no .ui-* styles used
No jquery-ui element bindings found, no .ui-* styles used
Bound Element
#tagit-interests - tagitThe element is bound in kuma/static/js/users.js
Bound Element
#tagit_tags - tagitThe element is bound in kuma/static/js/wiki-tags-edit.js
Note: This uses a redundant version of tag-it, see Appendix A for details
Bound Element
#tagit_tags - tagitThe element is bound in kuma/static/js/wiki-tags-edit.js
Note: This uses a redundant version of tag-it, see Appendix A for details
Bound Element
#parent-suggestion - mozillaAutocompleteThe element is bound in kuma/static/js/wiki-move.js
Bound Element
#tagit_tags - tagitThe element is bound in kuma/static/js/wiki-tags-edit.js
Note: This uses a redundant version of tag-it, see Appendix A for details
As I was digging though the source searching for references to jquery-ui, I round that the wiki pages that include a tags listing are using a completely separate and redundant import of the tag-it extension. It can be found in kuma/static/js/libs/tag-it.js.
kuma/settings/common.py*
'wiki-edit': {
'source_filenames': (
'js/wiki-edit.js',
'js/wiki-edit-draft.js',
'js/libs/tag-it.js', # <-- redundant import
'js/wiki-tags-edit.js',
),
'output_filename': 'build/js/wiki-edit.js',
},
Since, tag-it is already included in the jquery-ui bundle it should be possible to remove this copy altogether.
Wow, thanks so much for all of this @evanplaice 馃憤 really, really appreciate it. I will have a detailed read through all of this.
Sure thing. It's a lot of fun to dig through git history. I considered linking to relevant commits but it's a bit of a mess; the history goes back 6 years w/ multiple refactors.
I'd start working on the refactor but I had issues getting a local admin login running. Followed the directions to a t but I'm getting '403 Forbidden' when I actually try to login.
Hey @evanplaice, could you provide some error logs? Thanks so much
Of course.
Here's a screencast of the process. Cloning the repo finishes at 4:30.
https://youtu.be/n1pp9cBvfzk
Here are the logs
docker-compose logs -f outputhttps://gist.github.com/evanplaice/48838e986cc88f50ee6b2bd530b95fc1
I managed to login to the SQL container. Looks like the super user account was created successfully.
mysql> SELECT username, email, password, is_superuser FROM auth_user WHERE username = "evan";
+----------+----------------------+-------------------------------------------------------------------------------+--------------+
| username | email | password | is_superuser |
+----------+----------------------+-------------------------------------------------------------------------------+--------------+
| evan | [email protected] | pbkdf2_sha256$36000$n5rvnkPrUT3J$Ctut1zMtYBqsrmXHdLl7nUnUJAQ3TBCazSoiGQnqa0s= | 1 |
+----------+----------------------+-------------------------------------------------------------------------------+--------------+
1 row in set (0.00 sec)
Thanks, @evanplaice, I will have a look.
Most helpful comment
The following would need to be replaced
Autocomplete
The autocomplete input is built as a
jquery-uicustom widget extensionThis could be replaced w/ a 100% vanilla solution using
<datalist>+ AJAX fetch but browser compatibility for that element is spotty at best (https://caniuse.com/#feat=datalist)The awesomeplete lib could be used as a non-vanilla solution.
The source for the autocomplete widget definition is located in /kuma/static/js/moz-jquery-plugins.js
On evaluation, the widget is attached to the global
$namespace. It gets called as part of a $ chain, for example...kuma/static/js/dashboard.js
Datepicker
The datepicker input is a built-in feature of
jquery-uiIt could be replace w/
<input type="date">but again, browser support isn't 100% (https://caniuse.com/#search=input-date)The datepicker is bound to a HTML element as part of a
$call chain. Ex...kuma/static/js/dashboard.js
Tag-It
The tag-it input is a built-in feature of
jquery-uiThere is no vanilla HTML/JS feature that mimics a 'list of tags w/ autocompletion' input.
The awesomeplete lib will work as an alternative.
The tagit is bound to a HTML element as part of a
$call chain. Ex...kuma/static/users.js
kuma/dashboards/jinja2/dashboards/revisions.html
Bound Elements
#id_user- mozillaAutocomplete#id_topic- mozillaAutocomplete#id_start_date- datepicker#id_end_date- datepickerThe elements are bound in
kuma/static/js/dashboard.jskuma/users/jinja2/users/ban_user_and_cleanup_summary.html
No jquery-ui element bindings found, no
.ui-*styles usedkuma/users/jinja2/users/ban_user_and_cleanup.html
No jquery-ui element bindings found, no
.ui-*styles usedkuma/users/jinja2/users/user_detail.html
No jquery-ui element bindings found, no
.ui-*styles usedkuma/users/jinja2/users/user_edit.html
Bound Element
#tagit-interests- tagitThe element is bound in
kuma/static/js/users.jskuma/wiki/jinja2/wiki/create.html
Bound Element
#tagit_tags- tagitThe element is bound in
kuma/static/js/wiki-tags-edit.jsNote: This uses a redundant version of
tag-it, see Appendix A for detailskuma/wiki/jinja2/wiki/edit.html
Bound Element
#tagit_tags- tagitThe element is bound in
kuma/static/js/wiki-tags-edit.jsNote: This uses a redundant version of
tag-it, see Appendix A for detailskuma/wiki/jinja2/wiki/move.html
Bound Element
#parent-suggestion- mozillaAutocompleteThe element is bound in
kuma/static/js/wiki-move.jskuma/wiki/jinja2/wiki/translate.html
Bound Element
#tagit_tags- tagitThe element is bound in
kuma/static/js/wiki-tags-edit.jsNote: This uses a redundant version of
tag-it, see Appendix A for detailsAppendix A - Redundant Tag-It lib
As I was digging though the source searching for references to jquery-ui, I round that the wiki pages that include a tags listing are using a completely separate and redundant import of the
tag-itextension. It can be found inkuma/static/js/libs/tag-it.js.kuma/settings/common.py*
Since, tag-it is already included in the jquery-ui bundle it should be possible to remove this copy altogether.