Skip to content
Open
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: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
htdocs/js/*.min.js binary
htdocs/css/selectize.bootstrap3.css binary
19 changes: 19 additions & 0 deletions docs/api/schemas/latest/patchwork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,15 @@ paths:
schema:
title: ''
type: string
- in: query
name: labels
description: |
List of labels assigned to queried patches, separated by ','.
If a label name begins with a '-', patches with that label won't
be included.
schema:
title: ''
type: string
responses:
'200':
description: 'List of patches'
Expand Down Expand Up @@ -2312,6 +2321,11 @@ components:
type: array
items:
$ref: '#/components/schemas/PatchEmbedded'
labels:
title: Labels
type: array
items:
type: string
PatchDetail:
type: object
title: Patches
Expand Down Expand Up @@ -2390,6 +2404,11 @@ components:
type: array
items:
type: integer
labels:
title: Labels
type: array
items:
type: string
Person:
type: object
title: Person
Expand Down
25 changes: 25 additions & 0 deletions docs/api/schemas/patchwork.j2
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,17 @@ paths:
schema:
title: ''
type: string
{% endif %}
{% if version >= (1, 4) %}
- in: query
name: labels
description: |
List of labels assigned to queried patches, separated by ','.
If a label name begins with a '-', patches with that label won't
be included.
schema:
title: ''
type: string
{% endif %}
responses:
'200':
Expand Down Expand Up @@ -2397,6 +2408,13 @@ components:
type: array
items:
$ref: '#/components/schemas/PatchEmbedded'
{% endif %}
{% if version >= (1, 4) %}
labels:
title: Labels
type: array
items:
type: string
{% endif %}
PatchDetail:
type: object
Expand Down Expand Up @@ -2477,6 +2495,13 @@ components:
type: array
items:
type: integer
{% endif %}
{% if version >= (1, 4) %}
labels:
title: Labels
type: array
items:
type: string
{% endif %}
Person:
type: object
Expand Down
19 changes: 19 additions & 0 deletions docs/api/schemas/v1.4/patchwork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,15 @@ paths:
schema:
title: ''
type: string
- in: query
name: labels
description: |
List of labels assigned to queried patches, separated by ','.
If a label name begins with a '-', patches with that label won't
be included.
schema:
title: ''
type: string
responses:
'200':
description: 'List of patches'
Expand Down Expand Up @@ -2312,6 +2321,11 @@ components:
type: array
items:
$ref: '#/components/schemas/PatchEmbedded'
labels:
title: Labels
type: array
items:
type: string
PatchDetail:
type: object
title: Patches
Expand Down Expand Up @@ -2390,6 +2404,11 @@ components:
type: array
items:
type: integer
labels:
title: Labels
type: array
items:
type: string
Person:
type: object
title: Person
Expand Down
27 changes: 27 additions & 0 deletions docs/deployment/management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,30 @@ patches for these new tags.
.. option:: patch_id

a patch ID number. If not supplied, all patches will be updated.

.. _command-relabel:

relabel
~~~~~~~

.. program:: manage.py relabel

Relabel patches based on the subject line.

.. code-block:: shell

./manage.py relabel [PROJECT [PROJECT...]]

Patchwork extracts labels from square brackets at the beginning of the subject
line, eg. ``[label1, label2] Patch title``.

Only labels created in the admin interface will be recognized.
The script prioritizes project-specific labels if both project-specific and
general labels with the same name exist.

The script will not remove labels manually added to patches, but will re-add
labels manually removed from patches.

.. option:: PROJECT

list of IDs of projects to update. Relabels all projects if none specified.
23 changes: 23 additions & 0 deletions docs/usage/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ or a cover letter or the web URL to a patch or a series:

__ https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Labels
~~~~~~

Labels are a way to organize and prioritize submissions. You can apply labels
to patches and cover letters to signify priority, category, or any other marker
you wish.

Labels can be either global or tied to the project they are created in. Labels
can have an optional description attached, which will provide a little insight
into the purpose of the label. Labels are completely customizable and the
labels available will vary by instance.

Labels are parsed out of the square brackets of the subject line.
For example, subject line ``[RFC, main] Add tests`` may cause the patch to be
labeled with ``RFC`` and ``main``, if such labels were created for the project
or instance. Labels can be created in the admin panel.

.. note::

In order to refresh the list of labels for existing patches, for example
after updating Patchwork or adding a new label in the admin panel,
use the :ref:`command-relabel` management command.

Checks
~~~~~~

Expand Down
7 changes: 6 additions & 1 deletion htdocs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ js

Part of Patchwork.

``selectize-plugins.js.``
Extra plugins for selectize.

Part of Patchwork.

``selectize.min.js``
Selectize is the hybrid of a ``textbox`` and ``<select>`` box. It's jQuery
based and it has autocomplete and native-feeling keyboard navigation; useful
for tagging, contact lists, etc.

:Website: https://selectize.github.io/selectize.js/
:GitHub: https://github.com/selectize/selectize.js
:Version: 0.13.5
:Version: 0.15.2
26 changes: 20 additions & 6 deletions htdocs/css/selectize.bootstrap3.css

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions htdocs/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,18 @@ select[class^=change-property-], .archive-patch-select, .add-bundle {
margin: 0px 4px 0px 4px;
}

.patch-label {
margin: 0 .1em;
}

.labels-field {
padding: 4px;
margin-right: 8px;
box-sizing: border-box;
border-radius: 4px;
min-width: 200px;
}

.patch-form-submit {
font-weight: bold;
padding: 4px;
Expand All @@ -480,13 +492,6 @@ select[class^=change-property-], .archive-patch-select, .add-bundle {
margin-left: 16px;
}

.create-bundle {
padding: 4px;
margin-right: 8px;
box-sizing: border-box;
border-radius: 4px;
}

div.patch-form h3 {
margin-top: 0em;
margin-left: -0.6em;
Expand All @@ -504,9 +509,10 @@ div.patch-form ul {
}

.create-bundle {
padding: 4px;
padding: 6px 12px;
margin-right: 8px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
}

Expand Down
71 changes: 71 additions & 0 deletions htdocs/js/selectize-plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Selectize.define('enter_key_submit', function (options) {
var self = this;

this.onKeyDown = (function (e) {
var original = self.onKeyDown;

return function (e) {
var wasOpened = this.isOpen;
original.apply(this, arguments);

if (e.keyCode === 13 &&
(this.$control_input.val() != '' || !wasOpened))
self.trigger('submit');
};
})();
});

// Submit form on shift+enter or ctrl+enter
Selectize.define('mod_enter_key_submit', function (options) {
var self = this;

this.onKeyDown = (function (e) {
var original = self.onKeyDown;

return function (e) {
var wasOpened = this.isOpen;

if (e.keyCode === 13 && (e.shiftKey || e.ctrlKey)) {
self.trigger('submit');
return;
}

original.apply(this, arguments);
};
})();
});

// Focus search input after item from dropdown is selected for multiselects
Selectize.define('mod_focus_input_after_select', function (options) {
let prevSelect = this.onOptionSelect.bind(this);

this.onOptionSelect = e => {
// delegateTarget - div with dropdown
// delegateTarget.parentElement - input div created by selectize
// ^ contains selected items and actual <input> control
e.delegateTarget.parentElement.getElementsByTagName('input')[0].focus();
prevSelect(e);
};
});

function selectize_labels_input(selector, label_options) {
selector.selectize({
plugins: ['mod_enter_key_submit', 'mod_focus_input_after_select'],
maxItems: null,
persist: false,
hideSelected: true,
// Search for options that begin with a minus sign
respect_word_boundaries: false,
delimiter: ' ',
options: label_options,
render: {
item: function (item, escape) {
return '<div><span title="' + escape(item.description) + '">' + escape(item.text) + '</span></div>';
},
option: function (item, escape) {
console.log(item, escape);
return '<div class="option" title="' + escape(item.description) + '">' + escape(item.text) + '</div>';
},
},
});
}
34 changes: 32 additions & 2 deletions htdocs/js/selectize.min.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions patchwork/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from patchwork.models import Cover
from patchwork.models import CoverComment
from patchwork.models import DelegationRule
from patchwork.models import Label
from patchwork.models import Patch
from patchwork.models import PatchComment
from patchwork.models import PatchRelation
Expand Down Expand Up @@ -44,11 +45,18 @@ class DelegationRuleInline(admin.TabularInline):
fields = ('path', 'user', 'priority')


class LabelInline(admin.TabularInline):
model = Label
fields = ('name', 'description', 'color')
extra = 0


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
list_display = ('name', 'linkname', 'listid', 'listemail')
inlines = [
DelegationRuleInline,
LabelInline,
]


Expand Down Expand Up @@ -91,6 +99,7 @@ class PatchAdmin(admin.ModelAdmin):
'is_pull_request',
)
list_filter = ('project', 'submitter', 'state', 'archived')
readonly_fields = ('labels',)
list_select_related = ('submitter', 'project', 'state')
search_fields = ('name', 'submitter__name', 'submitter__email')
date_hierarchy = 'date'
Expand Down Expand Up @@ -194,3 +203,9 @@ class TagAdmin(admin.ModelAdmin):
@admin.register(PatchRelation)
class PatchRelationAdmin(admin.ModelAdmin):
model = PatchRelation


@admin.register(Label)
class LabelAdmin(admin.ModelAdmin):
list_display = ('name', 'color', 'project')
list_filter = ('project',)
Loading
Loading