From patchwork Mon Jul 19 23:34:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1507319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lYvQZeD0; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTJBK5zS6z9sRR for ; Tue, 20 Jul 2021 09:35:53 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GTJBK4r9Lz302S for ; Tue, 20 Jul 2021 09:35:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lYvQZeD0; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::f4a; helo=mail-qv1-xf4a.google.com; envelope-from=3uaz2yaukcu88rev2x55x2v.t536ratyd5812z9a9.5g2rs9.58x@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lYvQZeD0; dkim-atps=neutral Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GTJBD3Rvkz2ydS for ; Tue, 20 Jul 2021 09:35:48 +1000 (AEST) Received: by mail-qv1-xf4a.google.com with SMTP id l4-20020a0ce8440000b02902d89f797d08so16658912qvo.17 for ; Mon, 19 Jul 2021 16:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=QvLbmlApkfdg/LlZmkMv/6CgtL1G77a6jFzURIqJUVw=; b=lYvQZeD0XlciyU9XEam6GhgmAFSseiH1i7/7JIPFNr7jqqXUtYuuO3mKFwK4dmIDe7 jYz4dlYHFxmoieOp4dcmpLrbIMOhFUKEL04uB/HeKPRJodBy6GV/7jQujGNCeqDrMDKv tzMHJ5h5+tDwjmNm/7PZvAlqQHx9ef3BnSJ3NfqJm/tcyhE8HlgqorQryt7Zh1ww/vU6 dLhPFK6F2rDzvUObUQr0HSTrt0MJsRxv/N2pL/DtLpL/xmrPgVMIWAvLlfkuxHX3/ktG viUd9I1H/XvPDuOaDvWT+DlZyd0KiTJ0rU4GXga6aY8uvgjeNknFG/30bx0hVpiG7Xpr F7ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=QvLbmlApkfdg/LlZmkMv/6CgtL1G77a6jFzURIqJUVw=; b=UaBvbQtYctfIy1G98O59ZjIXUhNT7nUgAbwqra4O4vnrKxfZ1J6dkOFTYnkFI8SHWo z8WjCQyCJC8ODuaC8qZXnrFy2kZ//4KnnkEK5oJemKlw2kqKQaCZlZWEI1sYJ9DhILYL BJlDHPt7AK5xKFt3Q5ag7EFlvBSytuXOxwX4iAzfnpq6mr1eG/XGVNZb9+k6uQFjYXBS ztRDu0pC4lcjNt08AW56j/LA9jC9x4wzYdjScGWLD0WHmiBPmvsaQjzunY49rsu9or34 dbbE+XyVxkgO/3Nrduw4uJTBsLrau/MDouq5FoSDiAmhKsiI68rh0EQCDsqMxyOC52Ka bDGA== X-Gm-Message-State: AOAM532rF7+DaC4TO/8VhIbGimzlPKiQK2BQnuP8ilR5utb2t3gR6vh7 qYMkuhrKXmyz7Y/A54IxNDUGb5248JIUtIsfhb5yR963Rl+PO7SJsQfOby0+35nKQsaxPZD6LMS FtmqPoZNWJze5Rx28CsGFgD3GEwED0C0y8+mBfmJr/H9U1340suV2IGljCacXDDnm X-Google-Smtp-Source: ABdhPJw840mvs5bL0a3ESx4dZUYEiH6uCgEQO19K51ilOekqRoNe0o8k5RXMviQCr7tYbwVm6vtUXKg9dQ== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:ad4:4b2a:: with SMTP id s10mr27521237qvw.30.1626737744454; Mon, 19 Jul 2021 16:35:44 -0700 (PDT) Date: Mon, 19 Jul 2021 23:34:24 +0000 In-Reply-To: <20210719233428.2045872-1-raxel@google.com> Message-Id: <20210719233428.2045872-2-raxel@google.com> Mime-Version: 1.0 References: <20210719233428.2045872-1-raxel@google.com> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 1/5] static: added JS Cookie Library to get csrftoken for fetch requests From: Raxel Gutierrez To: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" As per Django docs[1], the library is useful to add csrftoken when making AJAX requests in JavaScript. More details in the README GitHub link provided. [1] https://docs.djangoproject.com/en/3.2/ref/csrf/#ajax Signed-off-by: Raxel Gutierrez --- htdocs/README.rst | 9 +++++++++ htdocs/js/js.cookie-2.2.1.min.js | 3 +++ templates/base.html | 1 + 3 files changed, 13 insertions(+) create mode 100644 htdocs/js/js.cookie-2.2.1.min.js diff --git a/htdocs/README.rst b/htdocs/README.rst index 62f15c2..dfa7ca8 100644 --- a/htdocs/README.rst +++ b/htdocs/README.rst @@ -122,6 +122,15 @@ js :GitHub: jQuery plug-in to drag and drop rows in HTML tables :Version: ??? +``js.cookie.min.js`` + + Library used to handle cookies. + + This is used to get the ``csrftoken`` cookie for AJAX POST requests. + + :GitHub: https://github.com/js-cookie/js-cookie/ + :Version: 2.2.1 + ``selectize.min.js`` Selectize is the hybrid of a ``textbox`` and `` +
+
+ {% if patchform %} +
+
+ {{ patchform.state.errors }} + {{ patchform.state }} +
+
+ {{ patchform.delegate.errors }} + {{ patchform.delegate }} +
+
+ {{ patchform.archived.errors }} + {{ patchform.archived.label_tag }} {{ patchform.archived }} +
+ +
+ {% endif %} + {% if user.is_authenticated %} +
+
+ + +
+ {% if bundles %} +
+ + +
+ {% endif %} + {% if bundle %} +
+ + +
+ {% endif %} +
+ {% endif %} +
+ {% include "patchwork/partials/pagination.html" %} +
@@ -174,9 +208,9 @@ $(document).ready(function() { {% for patch in page.object_list %} - + {% if user.is_authenticated %} - {% endif %} @@ -188,24 +222,24 @@ $(document).ready(function() { {% endif %} - - - - - - - - + + + + + + {% empty %} @@ -217,86 +251,6 @@ $(document).ready(function() { {% if page.paginator.count %} {% include "patchwork/partials/pagination.html" %} - -
- -{% if patchform %} -
-

Properties

-
+ + {{ patch.name|default:"[no subject]"|truncatechars:100 }} + {% if patch.series %} {{ patch.series|truncatechars:100 }} {% endif %} {{ patch|patch_tags }}{{ patch|patch_checks }}{{ patch.date|date:"Y-m-d" }}{{ patch.submitter|personify:project }}{{ patch.delegate.username }}{{ patch.state }}{{ patch|patch_tags }}{{ patch|patch_checks }}{{ patch.date|date:"Y-m-d" }}{{ patch.submitter|personify:project }}{{ patch.delegate.username }}{{ patch.state }}
- - - - - - - - - - - - - - - - -
Change state: - {{ patchform.state }} - {{ patchform.state.errors }} -
Delegate to: - {{ patchform.delegate }} - {{ patchform.delegate.errors }} -
Archive: - {{ patchform.archived }} - {{ patchform.archived.errors }} -
- -
- - -{% endif %} - -{% if user.is_authenticated %} -
-

Bundling

- - - - - - {% if bundles %} - - - - - {% endif %} - {% if bundle %} - - - - - {% endif %} -
Create bundle: - - -
Add to bundle: - - -
Remove from bundle: - - -
-
-{% endif %} - -
-
- - {% endif %} diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 3efe90c..6c30f0b 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -129,6 +129,8 @@ def set_bundle(request, project, action, data, patches, context): bundle.save() messages.success(request, "Bundle %s created" % bundle.name) elif action == 'add': + if not data['bundle_id']: + return ['No bundle was selected'] bundle = get_object_or_404(Bundle, id=data['bundle_id']) elif action == 'remove': bundle = get_object_or_404(Bundle, id=data['removed_bundle_id']) From patchwork Mon Jul 19 23:34:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1507321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lXwjfl8Z; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTJBW66rYz9sRR for ; Tue, 20 Jul 2021 09:36:03 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GTJBW4xcxz3bTf for ; Tue, 20 Jul 2021 09:36:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lXwjfl8Z; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::849; helo=mail-qt1-x849.google.com; envelope-from=3wgz2yaukcvki1o5c7ff7c5.3fdg1k38nfibc9jkj.fqc12j.fi7@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=lXwjfl8Z; dkim-atps=neutral Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GTJBP0McDz3bT5 for ; Tue, 20 Jul 2021 09:35:57 +1000 (AEST) Received: by mail-qt1-x849.google.com with SMTP id j16-20020ac855100000b029025bf786be09so10599009qtq.20 for ; Mon, 19 Jul 2021 16:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xch3p7E4LOCJprFSxnEkypaNhM86l1z2rp1ppGytIgE=; b=lXwjfl8ZVWlczZT9pWSRdJtMPns2eM+eh31rx+VqzuLSdYBpk8tH20YOQsg2Pq2bZL uGOgdZpEHLVwI4Y5SvbJhwHiCeerRgMWzpjaoso36KtPRQPU6Tir/VduuyPM11G09bol I/7w9cBR6occguin+92YehA0PfnbxxaNJf38MDZ8zp67elNv7PvJ2wkJvHjiGvkolIFI 9Ez8QhqGcAMDy5nDMyhIoveGepXnG4G2GYHua+s44Y1F+2psXoL5/32E3/Mb6O752luy 81JOpf5yjtnFhb2aN+Z08bqyg1AQh3xA4wmD0FifcNt+9OqjNG8u1h8Sz3a2Gv3JjK3o 7PFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xch3p7E4LOCJprFSxnEkypaNhM86l1z2rp1ppGytIgE=; b=eNsLDusMvPOD46HLYUJlXtsQfWJztnbDN6wJN9E3XNUJX//VQxcYVGaVQMANjhwKfA 3ze4gbGYwzaPiKeT+8WuTzgJ8zVa4NQStRgn7qT2v1JDPyBg67YBbqShLG0gGmC/aKs9 2UZF5BssDWOQ2IJN3LLFrxvhZw52/vZyfucfw9JB4q2N+nSmgfLJO8e5hLzkrf1Butmz icdKvJu3zN5ADJ7DpGE0CbWjU5qi2CkwQJ1g9fKV6ChSxb8pMxBnSZmKr6h6L8HzLi/A W5EPQZN1wYuqT9bjrxZeqTvqjuv/QIHCXR5eF+unh+zsjVJc1SsKlJDdW+mV+1PQdJ1R SbzA== X-Gm-Message-State: AOAM531u2FYDRL64yF6utSfCSStPstAXe0nbxKlzK2gddGOEiUFiSEr+ Uh1vHhdfsS7XLYvol3uD3h499fihy2+FKLgjaDPHRXTSMPbpK5fa5RtJwi2puTPaMFJWYXWAAyc YuLE6A2jn52zF8ODEZ/6lo5bGjpZpHZppbcK/zejf0DgMKLWqS85nNaM9tQTFrk4C X-Google-Smtp-Source: ABdhPJxnuw/uYlknGfeVCr5bdc/HOXAz+lo1Kzs+LgEpzs3fRfxOpOzg9rDQZuaUAse/CoWK3SP8Ptlx5g== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:a05:6214:188c:: with SMTP id cx12mr19707644qvb.7.1626737754430; Mon, 19 Jul 2021 16:35:54 -0700 (PDT) Date: Mon, 19 Jul 2021 23:34:26 +0000 In-Reply-To: <20210719233428.2045872-1-raxel@google.com> Message-Id: <20210719233428.2045872-4-raxel@google.com> Mime-Version: 1.0 References: <20210719233428.2045872-1-raxel@google.com> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 3/5] patch-list: improved list action bar ui From: Raxel Gutierrez To: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Added styling to the new patch list html code to make the change property and bundle action forms more usable. Post in mailing list about the design mockups shows how the new UI looks[1]. [1] https://lists.ozlabs.org/pipermail/patchwork/2021-July/006943.html Signed-off-by: Raxel Gutierrez --- htdocs/css/style.css | 64 +++++++++++++++++++++++++++----------------- patchwork/forms.py | 27 ++++++++++++++----- 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 243caa0..8746083 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -1,3 +1,7 @@ +:root { + --light-color: #F7F7F7; +} + h2 { font-size: 25px; margin: 18px 0 18px 0; @@ -122,10 +126,6 @@ a.colinactive:hover { div.filters { } -div.patchforms { - margin-top: 1em; -} - /* list order manipulation */ table.patchlist tr.draghover { @@ -149,7 +149,7 @@ input#reorder-change { .paginator { text-align: right; clear: both; - margin: 8px 0 15px; + margin: 8px 0 15px; } .paginator .prev-na, @@ -346,40 +346,54 @@ table.bundlelist td padding-right: 2em; } +.patch-list-actions { + width: 100%; + display: inline-flex; + flex-wrap: wrap; + justify-content: space-between; +} + /* forms that appear for a patch */ +.patchforms { + display: inline-flex; + flex-wrap: wrap; + margin: 16px 0px; +} + div.patchform { - border: thin solid #080808; - padding-left: 0.6em; - padding-right: 0.6em; - float: left; - margin: 0.5em 5em 0.5em 10px; + display: flex; + flex-wrap: wrap; + align-items: center; } -div.patchform h3 { - margin-top: 0em; - margin-left: -0.6em; - margin-right: -0.6em; - padding: 0.3em 0.3em 0.3em 0.6em; - background-color: #222; - color: #999; - font-size: 100%; +.change-property, .archive-patch, .add-bundle { + padding: 4px; + margin-right: 8px; + box-sizing: border-box; + border-radius: 4px; + background-color: var(--light-color); } -div.patchform ul { - list-style-type: none; - padding-left: 0.2em; - margin-top: 0em; +.patchform-submit { + font-weight: bold; + padding: 4px; +} + +#patchform-bundle, #add-to-bundle, #remove-bundle { + margin-left: 16px; } -/* forms */ -table.form { +.create-bundle { + padding: 4px; + margin-right: 8px; + box-sizing: border-box; + border-radius: 4px; } span.help_text { font-size: 80%; } - table.form td { padding: 0.6em; vertical-align: top; diff --git a/patchwork/forms.py b/patchwork/forms.py index 24322c7..b684026 100644 --- a/patchwork/forms.py +++ b/patchwork/forms.py @@ -122,10 +122,11 @@ class PatchForm(forms.ModelForm): class OptionalModelChoiceField(forms.ModelChoiceField): - no_change_choice = ('*', 'no change') + no_change_choice = ('*', 'No change') to_field_name = None - def __init__(self, *args, **kwargs): + def __init__(self, placeholder, *args, **kwargs): + self.no_change_choice = ('*', placeholder) super(OptionalModelChoiceField, self).__init__( initial=self.no_change_choice[0], *args, **kwargs) @@ -161,17 +162,29 @@ class OptionalBooleanField(forms.TypedChoiceField): class MultiplePatchForm(forms.Form): action = 'update' archived = OptionalBooleanField( - choices=[('*', 'no change'), ('True', 'Archived'), - ('False', 'Unarchived')], + choices=[('*', 'No change'), ('True', 'Archive'), + ('False', 'Unarchive')], coerce=lambda x: x == 'True', - empty_value='*') + empty_value='*', + label="Archived") def __init__(self, project, *args, **kwargs): super(MultiplePatchForm, self).__init__(*args, **kwargs) self.fields['delegate'] = OptionalModelChoiceField( - queryset=_get_delegate_qs(project=project), required=False) + queryset=_get_delegate_qs(project=project), + placeholder="Delegate to", + label="Delegate to", + required=False) self.fields['state'] = OptionalModelChoiceField( - queryset=State.objects.all()) + queryset=State.objects.all(), + placeholder="Change state", + label="Change state") + self.fields['state'].widget.attrs.update( + {'class': 'change-property'}) + self.fields['delegate'].widget.attrs.update( + {'class': 'change-property'}) + self.fields['archived'].widget.attrs.update( + {'class': 'archive-patch'}) def save(self, instance, commit=True): opts = instance.__class__._meta From patchwork Mon Jul 19 23:34:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1507322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Qfo3N6HH; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTJBc1xmwz9sRR for ; Tue, 20 Jul 2021 09:36:08 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GTJBc0vSnz30Bw for ; Tue, 20 Jul 2021 09:36:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Qfo3N6HH; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::84a; helo=mail-qt1-x84a.google.com; envelope-from=3wwz2yaukcvoj2p6d8gg8d6.4geh2l49ogjcdaklk.grd23k.gj8@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Qfo3N6HH; dkim-atps=neutral Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GTJBQ5Kpzz303P for ; Tue, 20 Jul 2021 09:35:58 +1000 (AEST) Received: by mail-qt1-x84a.google.com with SMTP id j15-20020ac84c8f0000b0290257b7db4a28so10643267qtv.9 for ; Mon, 19 Jul 2021 16:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+wzBbJQ6p/C7w5579kqtR6yKxuZkqRFSNSywaPsfDpI=; b=Qfo3N6HHM3EnaAbCu6l9OOmIQpK3rktvEIbmoDHxzF81s0Up+GwuA7gcqQQLxvDBup WPYAuhfAIAYyG7NepkUW6HJGSd1B9bDAHtDP9Yzoxii6MOsaaJyhUcaWY1Yj8xxPfwgd u0BruriLDAg4M89Y66nHbcbXkXF7SGOL6wWTqWxHzuW0q2RteVq4BAAc/1vnqoU6qC/T O5qloyWTkOyNU6ptjG6wrQFLo6eJuAHXIH3QOXn25XueZ2OhWr0u7l1/wi/5uwEwiZWQ b9kIMb+rJdJFZychexEHRuKX8PRrfcfPlcw6lB7qNN5sEigeR6mSIcFNI+LHEMCEmRwK QVJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+wzBbJQ6p/C7w5579kqtR6yKxuZkqRFSNSywaPsfDpI=; b=hacv+JGyW+ZMGlmyEkhsx1pi0xMGX9P/TKmAr9byA2C22ZlChYfFWoipibFG9iCjmy IxbXWdrYC3+EOOGkIJw/ZzcHQWGTIrZ0PUgfQrRF8/owUfc1x98wJaWGb6wHs5FJ8rGi Cqms6BP8Elb1qyfYFVZG3v9wNOtKdyhp5axU68OaEP4N3tizPSHhXSX6ctfVOPNBncSP on6X2mEVVa/5VhPJiO9Ymj9IpJU7bEUjUz79yl1Uhocu9boEB8Edqcfm+oBzwDeFGiOc /tiIfIq9qVeQshniXfMt9QCUgtaN1kBSDgmx7gadkNVDPhCjZGXg2MJNR8/ZL97XzWi7 Y/Sg== X-Gm-Message-State: AOAM532nPebOBRHPmrpjDEznxpjtklHNd+fNwF4MH/GGiOiDB/SsY2+K 5qBbf8jFAC1W+3CX140tudl9UEpr27sHpFHL0ri+kPVt2CsXc2AXZ2IyvsXi7gLgmaEL4QjHCjn rNoVND/F77Oz4AQ/Wcrsfo1gB7V9khVH0BFVMga1f2y3nL2bc1ddhTww25R3KPypG X-Google-Smtp-Source: ABdhPJwhLPP7QeZfaKBc8PmKSlcho/Hj+1tILJRwRMNFY9Wou7LN3RC7om6cADiACavJg54plzOz4bXFFw== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:a05:6214:20ef:: with SMTP id 15mr27345064qvk.54.1626737755739; Mon, 19 Jul 2021 16:35:55 -0700 (PDT) Date: Mon, 19 Jul 2021 23:34:27 +0000 In-Reply-To: <20210719233428.2045872-1-raxel@google.com> Message-Id: <20210719233428.2045872-5-raxel@google.com> Mime-Version: 1.0 References: <20210719233428.2045872-1-raxel@google.com> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 4/5] static: utils.js for modular handling of requests & messages From: Raxel Gutierrez To: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Added file to have a general utilities JavaScript module file for functions that are reused throughout various Patchwork js files. First added function for making fetch requests to update properties through 'PATCH' requests with the REST api endpoints. Also, added functions for handling update & error messages for these requests. The subsequent patch will make use of these functions which will be also reused in future features the make use fetch requests to update object fields. Signed-off-by: Raxel Gutierrez --- htdocs/README.rst | 7 +++++ htdocs/js/utils.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 htdocs/js/utils.js diff --git a/htdocs/README.rst b/htdocs/README.rst index 4441bf3..2bae34c 100644 --- a/htdocs/README.rst +++ b/htdocs/README.rst @@ -147,3 +147,10 @@ js :Website: https://selectize.github.io/selectize.js/ :GitHub: https://github.com/selectize/selectize.js :Version: 0.11.2 + +``utils.js.`` + + General utility module for functions used throughout other static Patchwork + js files (fetch requests, handling update & error messages). + + Part of Patchwork. diff --git a/htdocs/js/utils.js b/htdocs/js/utils.js new file mode 100644 index 0000000..34d41f5 --- /dev/null +++ b/htdocs/js/utils.js @@ -0,0 +1,71 @@ +/** + * Sends fetch requests to update objects' properties using REST api endpoints. + * @param {string} url Path to the REST api endpoint. + * @param {{field: string, value: string}} data + * field: Name of the property field to update. + * value: Value to update the property field to. + * @param {{none: string, some: string}} updateMessage + * none: Message when object update unsuccessful due to errors. + * some: Message when object update successful. + */ +async function updateProperty(url, data, updateMessage) { + const request = new Request(url, { + method: 'PATCH', + mode: "same-origin", + headers: { + "X-CSRFToken": Cookies.get("csrftoken"), + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }); + + await fetch(request) + .then(response => { + if (!response.ok) { + response.text().then(text => { + // Error occurred, so update message specifies no objects updated + handleUpdateMessages(updateMessage.none); + handleErrorMessages(JSON.parse(text).detail); + }); + } else { + // Update message for successful changes + handleUpdateMessages(updateMessage.some); + } + }); +} + +/** + * Populates update messages for fetch requests. + * @param {string} messageContent Text for update message. + */ +function handleUpdateMessages(messageContent) { + let messages = document.getElementById("messages"); + if (messages == null) { + messages = document.createElement("div"); + messages.setAttribute("id", "messages"); + } + let message = document.createElement("div"); + message.setAttribute("class", "message"); + message.textContent = messageContent; + messages.appendChild(message); + if (messages) $(messages).insertAfter("nav"); +} + +/** + * Populates error messages for fetch requests. + * @param {string} errorMessage Text for error message. + */ +function handleErrorMessages(errorMessage) { + let container = document.getElementById("main-content"); + let errorHeader = document.createElement("p"); + let errorList = document.createElement("ul"); + let error = document.createElement("li"); + errorHeader.textContent = "The following error was encountered while updating comments:"; + errorList.setAttribute("class", "errorlist"); + error.textContent = errorMessage; + errorList.appendChild(error); + container.prepend(errorList); + container.prepend(errorHeader); +} + +export { updateProperty, handleUpdateMessages, handleUpdateMessages}; \ No newline at end of file From patchwork Mon Jul 19 23:34:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1507323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=mz9fQA8z; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTJBh43pRz9sRR for ; Tue, 20 Jul 2021 09:36:12 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GTJBh2zzHz3bZJ for ; Tue, 20 Jul 2021 09:36:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=mz9fQA8z; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::74a; helo=mail-qk1-x74a.google.com; envelope-from=3xqz2yaukcvwl4r8faiiaf8.6igj4n6bqilefcmnm.itf45m.ila@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=mz9fQA8z; dkim-atps=neutral Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GTJBS34drz3bSn for ; Tue, 20 Jul 2021 09:36:00 +1000 (AEST) Received: by mail-qk1-x74a.google.com with SMTP id d14-20020a05620a240eb02903b9402486c5so5999130qkn.13 for ; Mon, 19 Jul 2021 16:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KFcrO4+Yha8UFyhDZqLpRb9hcVk6sjqcL7KrFeCEJGo=; b=mz9fQA8znxl755cqR1NmCqJmY/BvsktPevlvB87P5smWik3iBlTb3/cDf4pUhbj4XL UUahxfj442faASvDp2Tdu1wUHCxRX7+sPyV/u4wvgQ4kaK8dKf+Vv5rY8QIv7e5HDPM4 AqN4k4xXTtCUUWpiS+0XLaLx4g+UT3lQk5lFhp6sS+goPQ8UENlS92gOPRp5cgSuTSqL FbTBAGUEBLKN6nKMgMPn9NOeQGExql5+c5iNxtjSmscUek++/SJjQlxBv/t9w3Dlme43 Xhd+VRB9BHukHYapcqQLuvWSm6iWIiS/K8EY+80dZiYHZmAOM+iSkloN3utSt6j6AQlD hfoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KFcrO4+Yha8UFyhDZqLpRb9hcVk6sjqcL7KrFeCEJGo=; b=gYRZaRxoy2M6lsGCXu1u/ZEczKL3dra3TtrtuR7CtXUlnDzfFVtzwBJzq51VJZ+BOx k3uJ6i9bRrZJvgQeoS62UU6qNa4xDMP2Ggeuf7INW827mvI1pge8Lnjvz3lHjaUjmT4w iUMqiCeeTXenx+lElSbJeM8XEHTivts2aVz0tIl2ZphYaLd/guJqv5MipGTXcWRh3FRb ynvXZkw6DHakfjLpt2BW9y5Og+DuA26zrLCOMZQLu9/jHuzdR7KoXpIaeYZOPllM6SGe LTumMOs5jpLyVQcFnIKuNyRV7YDaOffvM5IgxQ4WgwMC4DWJbRxZUBeoMygf7sksG0aW eMHw== X-Gm-Message-State: AOAM5332EC/q1YRlS0S1e1Wi7DRbmqVn5JQrIGe4SaUOJmSXKRaBspx/ XQqfrjYUvkO7S6WOYHUzzouyzgCFUO2Ts9rC+02juOi/0gNc0nTk1O/pbZxRvAqico6GfMTyewQ dmAdiMmYOvYcH7vgsLU9pAaAj78U9bdXrVQRLxIWPMhy7AkPhQo50fVbpncdHSsvG X-Google-Smtp-Source: ABdhPJwq/FzP5/EbMcd3zQR29BlJY6TWP02i0ZiHHfwBbPb+oKCbF3nhdKuDBFV4Vaeh8NLbxxYStmUW0w== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:a05:6214:300c:: with SMTP id ke12mr22878699qvb.38.1626737757256; Mon, 19 Jul 2021 16:35:57 -0700 (PDT) Date: Mon, 19 Jul 2021 23:34:28 +0000 In-Reply-To: <20210719233428.2045872-1-raxel@google.com> Message-Id: <20210719233428.2045872-6-raxel@google.com> Mime-Version: 1.0 References: <20210719233428.2045872-1-raxel@google.com> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 5/5] patch-list: added inline dropdown changes functionality From: Raxel Gutierrez To: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Added dropdown for the row values of the Delegate and State columns for each individual patch to make one-off changes to patches. Changed the generic_list method to pass the list of states and maintainers in patch list view context to populate the dropdown options. The static patch-list.js file now uses the modularity of the fetch request and update/error messages handling of utils.js. Signed-off-by: Raxel Gutierrez --- htdocs/css/style.css | 2 +- htdocs/js/patch-list.js | 34 +++++++++++++++++++ htdocs/js/utils.js | 2 +- .../patchwork/partials/patch-list.html | 31 +++++++++++++++-- patchwork/views/__init__.py | 3 ++ templates/base.html | 2 +- 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 8746083..2a45ec7 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -366,7 +366,7 @@ div.patchform { align-items: center; } -.change-property, .archive-patch, .add-bundle { +.change-property, select[class^="change-property-"], .archive-patch, .add-bundle { padding: 4px; margin-right: 8px; box-sizing: border-box; diff --git a/htdocs/js/patch-list.js b/htdocs/js/patch-list.js index 8c7640f..b88bad5 100644 --- a/htdocs/js/patch-list.js +++ b/htdocs/js/patch-list.js @@ -1,4 +1,17 @@ +import { updateProperty } from "./utils.js"; + $( document ).ready(function() { + // Change listener for dropdowns that change an individual patch's delegate and state properties + $("select[class^='change-property-']").change((event) => { + const property = event.target.getAttribute("value"); + const { url, data } = getPatchProperties(event.target, property); + const updateMessage = { + 'none': "No patches updated", + 'some': "1 patch updated", + }; + updateProperty(url, data, updateMessage); + }); + $("#patchlist").stickyTableHeaders(); $("#check-all").change(function(e) { @@ -9,4 +22,25 @@ $( document ).ready(function() { } e.preventDefault(); }); + + /** + * Returns the data to make property changes to a patch through fetch request. + * @param {Element} propertySelect Property select element modified. + * @param {string} property Patch property modified (e.g. "state", "delegate") + * @return {{property: string, value: string}} + * property: Property field to be modified in request. + * value: New value for property to be modified to in request. + */ + function getPatchProperties(propertySelect, property) { + const selectedOption = propertySelect.options[propertySelect.selectedIndex]; + const patchId = propertySelect.parentElement.parentElement.dataset.patchId; + const propertyValue = (property === "state") ? selectedOption.text + : (selectedOption.value === "*") ? null : selectedOption.value + const data = {}; + data[property] = propertyValue; + return { + "url": "/api/patches/" + patchId + "/", + "data": data, + }; + } }); \ No newline at end of file diff --git a/htdocs/js/utils.js b/htdocs/js/utils.js index 34d41f5..254b5ae 100644 --- a/htdocs/js/utils.js +++ b/htdocs/js/utils.js @@ -68,4 +68,4 @@ function handleErrorMessages(errorMessage) { container.prepend(errorHeader); } -export { updateProperty, handleUpdateMessages, handleUpdateMessages}; \ No newline at end of file +export { updateProperty }; \ No newline at end of file diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html index 629922c..48b47db 100644 --- a/patchwork/templates/patchwork/partials/patch-list.html +++ b/patchwork/templates/patchwork/partials/patch-list.html @@ -5,7 +5,7 @@ {% load static %} {% block headers %} - + {% endblock %} {% include "patchwork/partials/filters.html" %} @@ -238,8 +238,33 @@ {{ patch|patch_checks }} {{ patch.date|date:"Y-m-d" }} {{ patch.submitter|personify:project }} - {{ patch.delegate.username }} - {{ patch.state }} + + + + + + {% empty %} diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 6c30f0b..cdd6f55 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -13,6 +13,7 @@ from patchwork.models import Bundle from patchwork.models import BundlePatch from patchwork.models import Patch from patchwork.models import Project +from patchwork.models import State from patchwork.models import Check from patchwork.paginator import Paginator @@ -177,6 +178,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, 'project': project, 'projects': Project.objects.all(), 'filters': filters, + 'maintainers': project.maintainer_project.all(), + 'states': State.objects.all(), } # pagination diff --git a/templates/base.html b/templates/base.html index e1fac82..9bdb35f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -114,7 +114,7 @@ {% endfor %} {% endif %} -
+
{% block body %} {% endblock %}