mirror of https://github.com/go-gitea/gitea
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the label is named `scope/name`, no other label with the same `scope/` prefix can be set on an issue. The scope is determined by the last occurence of `/`, so for example `scope/alpha/name` and `scope/beta/name` are considered to be in different scopes and can coexist. Exclusive scopes are not enforced by any database rules, however they are enforced when editing labels at the models level, automatically removing any existing labels in the same scope when either attaching a new label or replacing all labels. In menus use a circle instead of checkbox to indicate they function as radio buttons per scope. Issue filtering by label ensures that only a single scoped label is selected at a time. Clicking with alt key can be used to remove a scoped label, both when editing individual issues and batch editing. Label rendering refactor for consistency and code simplification: * Labels now consistently have the same shape, emojis and tooltips everywhere. This includes the label list and label assignment menus. * In label list, show description below label same as label menus. * Don't use exactly black/white text colors to look a bit nicer. * Simplify text color computation. There is no point computing luminance in linear color space, as this is a perceptual problem and sRGB is closer to perceptually linear. * Increase height of label assignment menus to show more labels. Showing only 3-4 labels at a time leads to a lot of scrolling. * Render all labels with a new RenderLabel template helper function. Label creation and editing in multiline modal menu: * Change label creation to open a modal menu like label editing. * Change menu layout to place name, description and colors on separate lines. * Don't color cancel button red in label editing modal menu. * Align text to the left in model menu for better readability and consistent with settings layout elsewhere. Custom exclusive scoped label rendering: * Display scoped label prefix and suffix with slightly darker and lighter background color respectively, and a slanted edge between them similar to the `/` symbol. * In menus exclusive labels are grouped with a divider line. --------- Co-authored-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>pull/22950/head
parent
feed1ff38f
commit
6221a6fd54
@ -0,0 +1,16 @@ |
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_19 //nolint
|
||||
|
||||
import ( |
||||
"xorm.io/xorm" |
||||
) |
||||
|
||||
func AddExclusiveLabel(x *xorm.Engine) error { |
||||
type Label struct { |
||||
Exclusive bool |
||||
} |
||||
|
||||
return x.Sync(new(Label)) |
||||
} |
@ -1,9 +1,7 @@ |
||||
<a |
||||
class="ui label item {{if not .label.IsChecked}}hide{{end}}" |
||||
class="item {{if not .label.IsChecked}}hide{{end}}" |
||||
id="label_{{.label.ID}}" |
||||
href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"{{/* FIXME: use .root.Issue.Link or create .root.Link */}} |
||||
style="color: {{.label.ForegroundColor}}; background-color: {{.label.Color}}" |
||||
title="{{.label.Description | RenderEmojiPlain}}" |
||||
> |
||||
{{.label.Name | RenderEmoji}} |
||||
{{RenderLabel .label}} |
||||
</a> |
||||
|
@ -1,27 +1,47 @@ |
||||
<div class="ui new-label segment hide"> |
||||
<form class="ui form" action="{{$.Link}}/new" method="post"> |
||||
{{.CsrfTokenHtml}} |
||||
<div class="ui grid"> |
||||
<div class="three wide column"> |
||||
<div class="ui small new-label modal"> |
||||
<div class="header"> |
||||
{{.locale.Tr "repo.issues.new_label"}} |
||||
</div> |
||||
<div class="content"> |
||||
<form class="ui new-label form ignore-dirty" action="{{$.Link}}/new" method="post"> |
||||
{{.CsrfTokenHtml}} |
||||
<div class="required field"> |
||||
<label for="name">{{.locale.Tr "repo.issues.label_title"}}</label> |
||||
<div class="ui small input"> |
||||
<input class="new-label-input emoji-input" name="title" placeholder="{{.locale.Tr "repo.issues.new_label_placeholder"}}" autofocus required maxlength="50"> |
||||
<input class="label-name-input emoji-input" name="title" placeholder="{{.locale.Tr "repo.issues.new_label_placeholder"}}" autofocus required maxlength="50"> |
||||
</div> |
||||
</div> |
||||
<div class="three wide column"> |
||||
<div class="ui small fluid input"> |
||||
<input class="new-label-desc-input" name="description" placeholder="{{.locale.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> |
||||
<div class="field label-exclusive-input-field"> |
||||
<div class="ui checkbox"> |
||||
<input class="label-exclusive-input" name="exclusive" type="checkbox"> |
||||
<label>{{.locale.Tr "repo.issues.label_exclusive"}}</label> |
||||
</div> |
||||
<br/> |
||||
<small class="desc">{{.locale.Tr "repo.issues.label_exclusive_desc" | Safe}}</small> |
||||
</div> |
||||
<div class="color picker column"> |
||||
<input class="color-picker" name="color" value="#70c24a" required maxlength="7"> |
||||
</div> |
||||
<div class="column precolors"> |
||||
{{template "repo/issue/label_precolors"}} |
||||
<div class="field"> |
||||
<label for="description">{{.locale.Tr "repo.issues.label_description"}}</label> |
||||
<div class="ui small fluid input"> |
||||
<input class="label-desc-input" name="description" placeholder="{{.locale.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> |
||||
</div> |
||||
</div> |
||||
<div class="buttons"> |
||||
<div class="ui secondary small basic cancel button">{{.locale.Tr "repo.milestones.cancel"}}</div> |
||||
<button class="ui primary small button">{{.locale.Tr "repo.issues.create_label"}}</button> |
||||
<div class="field color-field"> |
||||
<label for="color">{{$.locale.Tr "repo.issues.label_color"}}</label> |
||||
<div class="color picker column"> |
||||
<input class="color-picker" name="color" value="#70c24a" required maxlength="7"> |
||||
<div class="column precolors"> |
||||
{{template "repo/issue/label_precolors"}} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
<div class="actions"> |
||||
<div class="ui secondary small basic cancel button"> |
||||
{{.locale.Tr "cancel"}} |
||||
</div> |
||||
<div class="ui primary small approve button"> |
||||
{{.locale.Tr "repo.issues.create_label"}} |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
|
Loading…
Reference in new issue