From patchwork Fri Aug 20 04:50:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1518918 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=Z5qiAr9i; 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 4GrTkG5Nhcz9sWl for ; Fri, 20 Aug 2021 14:51:34 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GrTkG3tZmz3cjX for ; Fri, 20 Aug 2021 14:51:34 +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=Z5qiAr9i; 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=3pjqfyqukczsm5s9gbjjbg9.7jhk5o7crjmfgdnon.jug56n.jmb@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=Z5qiAr9i; 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 4GrTjN3SyYz3bmn for ; Fri, 20 Aug 2021 14:50:48 +1000 (AEST) Received: by mail-qk1-x74a.google.com with SMTP id q13-20020a05620a038d00b003d38f784161so5714761qkm.8 for ; Thu, 19 Aug 2021 21:50: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; bh=msKDKUmtDWKJmYvE8CxOLhiyS9H8DVoQQreyfB+ekYk=; b=Z5qiAr9iuvao0h+vfA3eyf/RKvDmBeyiLqG+JQK1yiO5PSF3mTfMFgntOJF8D8xdnK //3OqB6sxEqanfF+TmqwLDdXoCy3rw6zEP6gS7S9EANWMw/bFq+X4Pqnk34bkROuAkih S+Rz2ebDqojyvHsX3DOhKX/ap+h35cO8gS+1pxiPUGLXneCTcdJohTemr7qA9Z+WH7Jz +NLduhhJD9dpEkNUlNCtvhkeKISkZiY0byz69vfFqzVu9pLFIFWkbUGLXgIlli1ChKAO hD9MdMfBhDLPKbPADvuCIZcT0T9gH5Ib1M38MQqF2tPFqLgd2SXLS6iOLeRQCX2Yr1Cx Eqew== 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=msKDKUmtDWKJmYvE8CxOLhiyS9H8DVoQQreyfB+ekYk=; b=Z7VJmSpS3WXX8peVbArTQ1iHtxPPSsHz6U9JT4hL0NE0CfNf9fEECdo/f2SchF/cq6 lfD1g7gvjKg677jlO+vIz0WrPFZW9hMlfnZOsoQO1JqWZIWFMF+4D6bqVhk1arfMcbaO ChElW3GCWtcW1RJv9pi2hgyridvsgEYpw0ReAHOvdvMxJTH/MJA2FUyrI8KN8tEQb0yB OTYMG8ja0fIS20mLZSoERSsnyXKktbAT4ag7JvH7cWp1UKlJXi9O66Uono4fXl4mKCbb areWFCdYfFVorEEK260K6r1jyDgxQp86qamsC7oCQWiN7Gq8DFqUbd0lw2opgUGVWWCT xQ3w== X-Gm-Message-State: AOAM532gI379xnbgNVU0Bph8XxcQIW3ZbVAmSqyOS3pLZMp6EakdyK7a fZO4QYnusQ6aCzo+oJFGyk7QFcMs3PwkVetzA+HX0xrZOv8lb9CM5WrZJkhVDrZXIOG5BX8oGh1 qNozFoTLEx27PBnkebMjdSD3abMRj/evazi7qWQSe1Xm/c0lW+v3J61nVHg1Hd/xV X-Google-Smtp-Source: ABdhPJyA7HVA5+gd4kXGFa/dC4es2lJxwe4eS4b6hyQt13L1hsNfLltVrQdfAamwYMF/aDXUDzVTcaq7RQ== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:ad4:45a8:: with SMTP id y8mr18312092qvu.49.1629435046104; Thu, 19 Aug 2021 21:50:46 -0700 (PDT) Date: Fri, 20 Aug 2021 04:50:29 +0000 In-Reply-To: <20210820045030.3364156-1-raxel@google.com> Message-Id: <20210820045030.3364156-9-raxel@google.com> Mime-Version: 1.0 References: <20210820045030.3364156-1-raxel@google.com> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog Subject: [PATCH v4 8/9] patch-detail: add label and button for comment addressed status 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" Add new label to patch and cover comments to show the status of whether they are addressed or not and add an adjacent button to allow users to change the status of the comment. Only users that can edit the patch (i.e. patch author, delegate, project maintainers) as well as comment authors can change the status of a patch comment. For cover comments, there are no delegates, so only maintainers and cover/cover comment authors can edit the status of the cover comment. Before [1] and after [2] images for reference. Use new comment detail REST API endpoint to update the addressed field value when "Addressed" or "Unaddressed" buttons are clicked. After a successful request is made, the appearance of the comment status label and buttons are toggled appropriately. For unsuccessful requests (e.g. network errors prevents reaching the server), the error message is populated to the page. A future improvement on this behavior is to add a spinner to the button to provide a feedback that the request is in a pending state until it's handled. [1] https://imgur.com/3ZKzgjN [2] https://imgur.com/hWZrrnM Signed-off-by: Raxel Gutierrez --- htdocs/css/style.css | 38 ++++++++++++ htdocs/js/submission.js | 20 +++++++ patchwork/templates/patchwork/submission.html | 60 +++++++++++++++---- patchwork/views/patch.py | 4 +- 4 files changed, 110 insertions(+), 12 deletions(-) diff --git a/htdocs/css/style.css b/htdocs/css/style.css index a2a2e3c3..9156aa6e 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -1,4 +1,5 @@ :root { + --light-color:rgb(247, 247, 247); --success-color:rgb(92, 184, 92); --warning-color:rgb(240, 173, 78); --danger-color:rgb(217, 83, 79); @@ -27,6 +28,10 @@ pre { top: 17em; } +.hidden { + visibility: hidden; +} + /* Bootstrap overrides */ .navbar-inverse .navbar-brand > a { @@ -315,6 +320,39 @@ table.patch-meta tr th, table.patch-meta tr td { font-family: "DejaVu Sans Mono", fixed; } +div[class^="comment-status-bar-"] { + display: flex; + flex-wrap: wrap; + align-items: center; +} + +.comment-status-label { + margin: 0px 8px; +} + +button[class^=comment-action] { + background-color: var(--light-color); + border-radius: 4px; +} + +.comment-action-addressed { + border-color: var(--success-color); +} + +.comment-action-unaddressed { + border-color: var(--warning-color); +} + +.comment-action-addressed:hover { + background-color: var(--success-color); + color: var(--light-color); +} + +.comment-action-unaddressed:hover { + background-color: var(--warning-color); + color: var(--light-color); +} + .quote { color: #007f00; } diff --git a/htdocs/js/submission.js b/htdocs/js/submission.js index 9676f348..47cffc82 100644 --- a/htdocs/js/submission.js +++ b/htdocs/js/submission.js @@ -1,4 +1,7 @@ +import { updateProperty } from "./rest.js"; + $( document ).ready(function() { + const patchMeta = document.getElementById("patch-meta"); function toggleDiv(link_id, headers_id, label_show, label_hide) { const link = document.getElementById(link_id) const headers = document.getElementById(headers_id) @@ -14,6 +17,23 @@ $( document ).ready(function() { } } + $("button[class^='comment-action']").click((event) => { + const submissionType = patchMeta.dataset.submissionType; + const submissionId = patchMeta.dataset.submissionId; + const commentId = event.target.parentElement.dataset.commentId; + const url = `/api/${submissionType}/${submissionId}/comments/${commentId}/`; + const data = {'addressed': event.target.value} ; + const updateMessage = { + 'error': "No comments updated", + 'success': "1 comment(s) updated", + }; + updateProperty(url, data, updateMessage).then(isSuccess => { + if (isSuccess) { + $("div[class^='comment-status-bar-'][data-comment-id='"+commentId+"']").toggleClass("hidden"); + } + }) + }); + // Click listener to show/hide headers document.getElementById("toggle-patch-headers").addEventListener("click", function() { toggleDiv("toggle-patch-headers", "patch-headers"); diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 36b15d0e..2238e82e 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -5,6 +5,7 @@ {% load person %} {% load patch %} {% load static %} +{% load utils %} {% block headers %} @@ -19,7 +20,12 @@

{{ submission.name }}

- +
{% if submission.list_archive_url %} @@ -271,18 +277,50 @@ {% if forloop.first %}

Comments

{% endif %} - +{% is_editable item user as comment_is_editable %}
-
- {{ item.submitter|personify:project }} - {{ item.date }} UTC | - #{{ forloop.counter }} - -
-
-{{ item|commentsyntax }}
-
+
+ {{ item.submitter|personify:project }} + {{ item.date }} UTC | + #{{ forloop.counter }} + + {% if item.addressed %} +
+ {% else %} + + {% if item.addressed %} + +
+  {{ item|commentsyntax }}
+  
{% endfor %} diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index 3e6874ae..00b0147f 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -109,7 +109,8 @@ def patch_detail(request, project_id, msgid): comments = patch.comments.all() comments = comments.select_related('submitter') - comments = comments.only('submitter', 'date', 'id', 'content', 'patch') + comments = comments.only('submitter', 'date', 'id', 'content', 'patch', + 'addressed') if patch.related: related_same_project = patch.related.patches.only( @@ -128,6 +129,7 @@ def patch_detail(request, project_id, msgid): patch.check_set.all().select_related('user'), ) context['submission'] = patch + context['editable'] = editable context['patchform'] = form context['createbundleform'] = createbundleform context['project'] = patch.project
Message ID