Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qa] Switched to prettier for CSS/JS formatting #427

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
sudo apt-get -qq -y install gettext
pip install -U pip wheel
pip install -U -r requirements-test.txt
sudo npm install -g jshint
sudo npm install -g prettier
pip install -e .[rest]
pip install -U ${{ matrix.django-version }}

Expand Down
49 changes: 0 additions & 49 deletions .jshint

This file was deleted.

15 changes: 0 additions & 15 deletions .stylelintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions openwisp_users/static/openwisp-users/css/admin.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
input.readonly{
input.readonly {
border: 1px solid rgba(0, 0, 0, 0.05) !important;
background-color: rgba(0, 0, 0, 0.070);
background-color: rgba(0, 0, 0, 0.07);
}
32 changes: 17 additions & 15 deletions openwisp_users/static/openwisp-users/js/addform.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
(function ($) {
'use strict';
"use strict";
$(document).ready(function () {
var superuser = $('#id_is_superuser'),
staff = $('#id_is_staff'),
orgs = $('#openwisp_users_organizationuser-group');
var superuser = $("#id_is_superuser"),
staff = $("#id_is_staff"),
orgs = $("#openwisp_users_organizationuser-group");
superuser.change(function (e) {
// when enabling superuser
if (superuser.is(':checked')) {
if (superuser.is(":checked")) {
// hide organization details because they're not needed
orgs.hide();
// reset all org fields
orgs.find('.field-is_admin input').prop('checked', false);
orgs.find('.field-organization select').val('');
orgs.find(".field-is_admin input").prop("checked", false);
orgs.find(".field-organization select").val("");
// enable staff too
if (!staff.is(':checked')) {
staff.trigger('click');
if (!staff.is(":checked")) {
staff.trigger("click");
}
// when disabling superuser, show organizations
// when disabling superuser, show organizations
} else {
orgs.show();
}
});
staff.change(function (e) {
// enable also is_admin in org unless superuser
if (!superuser.is(':checked')) {
orgs.find('.field-is_admin input').prop('checked', staff.is(':checked'));
if (!superuser.is(":checked")) {
orgs
.find(".field-is_admin input")
.prop("checked", staff.is(":checked"));
}
});
staff.trigger('change');
superuser.trigger('change');
staff.trigger("change");
superuser.trigger("change");
});
}(django.jQuery));
})(django.jQuery);
53 changes: 29 additions & 24 deletions openwisp_users/static/openwisp-users/js/org-autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function ($) {
'use strict';
"use strict";
$(document).ready(function () {
// The select2 library requires data in a specific format
// https://select2.org/data-sources/formats.
Expand All @@ -9,51 +9,56 @@
// Django expects an empty string (for None) or a UUID string.
// Hence, we need to update the value of selected option before
// submission of form.
var formElement = $('select#id_organization');
while (formElement.prop('tagName') !== 'FORM'){
var formElement = $("select#id_organization");
while (formElement.prop("tagName") !== "FORM") {
formElement = formElement.parent();
}
formElement.submit(function(){
var target = $('select#id_organization option:selected');
if (target.val() === 'null') {
target.val('');
formElement.submit(function () {
var target = $("select#id_organization option:selected");
if (target.val() === "null") {
target.val("");
}
});

if (!$('select#id_organization').val()) {
var orgField = $('#id_organization'),
pathName = window.location.pathname.split('/');
if (!$("select#id_organization").val()) {
var orgField = $("#id_organization"),
pathName = window.location.pathname.split("/");
// If the field is rendered empty on a change form, then the
// the object is shared systemwide (no organization).
if (pathName[pathName.length - 2] == 'change') {
orgField.val('null');
orgField.trigger('change');
if (pathName[pathName.length - 2] == "change") {
orgField.val("null");
orgField.trigger("change");
return;
}

// If only one organization option is available, then select that
// organization automatically
$.ajax({
url: orgField.data('ajax--url'),
url: orgField.data("ajax--url"),
data: {
app_label: orgField.data('app-label'),
model_name: orgField.data('model-name'),
field_name: orgField.data('field-name')
app_label: orgField.data("app-label"),
model_name: orgField.data("model-name"),
field_name: orgField.data("field-name"),
},
success: function (data) {
if (data.results.length === 1) {
var option = new Option(data.results[0].text, data.results[0].id, true, true);
orgField.append(option).trigger('change');
var option = new Option(
data.results[0].text,
data.results[0].id,
true,
true,
);
orgField.append(option).trigger("change");
// manually trigger the `select2:select` event
orgField.trigger({
type: 'select2:select',
type: "select2:select",
params: {
data: data.results[0]
}
data: data.results[0],
},
});
}
}
},
});
}
});
}(django.jQuery));
})(django.jQuery);
6 changes: 3 additions & 3 deletions run-qa-checks
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash
set -e

jshint ./openwisp_users/static/openwisp-users/js/*.js

echo ''
echo 'Compiling translations'
cd openwisp_users
Expand All @@ -12,7 +10,9 @@ cd ..
openwisp-qa-check \
--migrations-to-ignore 2 \
--migration-path './openwisp_users/migrations' \
--migration-module openwisp_users
--migration-module openwisp_users \
--csslinter \
--jslinter

echo ''
echo 'Running checks for testapp'
Expand Down