Add Organization Wide Labels (#10814)
* Add organization wide labels Implement organization wide labels similar to organization wide webhooks. This lets you create individual labels for organizations that can be used for all repos under that organization (so being able to reuse the same label across multiple repos). This makes it possible for small organizations with many repos to use labels effectively. Fixes #7406 * Add migration * remove comments * fix tests * Update options/locale/locale_en-US.ini Removed unused translation string * show org labels in issue search label filter * Use more clear var name * rename migration after merge from master * comment typo * update migration again after rebase with master * check for orgID <=0 per guillep2k review * fmt * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * remove unused code * Make sure RepoID is 0 when searching orgID per code review * more changes/code review requests * More descriptive translation var per code review * func description/delete comment when issue label deleted instead of hiding it * remove comment * only use issues in that repo when calculating number of open issues for org label on repo label page * Add integration test for IssuesSearch API with labels * remove unused function * Update models/issue_label.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Use subquery in GetLabelIDsInReposByNames * Fix tests to use correct orgID * fix more tests * IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well * update comment for clarity * Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition * Don't sort repos by date in IssuesSearch API After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures: SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45 Returns different results for MySQL than other engines. However, the similar query: SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30 Returns the same results. This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function. * linter is back! * code review * remove now unused option * Fix newline at end of files * more unused code * update to master * check for matching ids before query * Update models/issue_label.go Co-Authored-By: 6543 <6543@obermui.de> * Update models/issue_label.go * update comments * Update routers/org/setting.go Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>tokarchuk/v1.17
parent
36d9237e60
commit
8d99ee2773
@ -0,0 +1,22 @@ |
|||||||
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package migrations |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
|
||||||
|
"xorm.io/xorm" |
||||||
|
) |
||||||
|
|
||||||
|
func addOrgIDLabelColumn(x *xorm.Engine) error { |
||||||
|
type Label struct { |
||||||
|
OrgID int64 `xorm:"INDEX"` |
||||||
|
} |
||||||
|
|
||||||
|
if err := x.Sync2(new(Label)); err != nil { |
||||||
|
return fmt.Errorf("Sync2: %v", err) |
||||||
|
} |
||||||
|
return nil |
||||||
|
} |
@ -0,0 +1,237 @@ |
|||||||
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package org |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"net/http" |
||||||
|
"strconv" |
||||||
|
"strings" |
||||||
|
|
||||||
|
"code.gitea.io/gitea/models" |
||||||
|
"code.gitea.io/gitea/modules/context" |
||||||
|
"code.gitea.io/gitea/modules/convert" |
||||||
|
api "code.gitea.io/gitea/modules/structs" |
||||||
|
"code.gitea.io/gitea/routers/api/v1/utils" |
||||||
|
) |
||||||
|
|
||||||
|
// ListLabels list all the labels of an organization
|
||||||
|
func ListLabels(ctx *context.APIContext) { |
||||||
|
// swagger:operation GET /orgs/{org}/labels organization orgListLabels
|
||||||
|
// ---
|
||||||
|
// summary: List an organization's labels
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: page
|
||||||
|
// in: query
|
||||||
|
// description: page number of results to return (1-based)
|
||||||
|
// type: integer
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: page size of results, maximum page size is 50
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/LabelList"
|
||||||
|
|
||||||
|
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Query("sort"), utils.GetListOptions(ctx)) |
||||||
|
if err != nil { |
||||||
|
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, convert.ToLabelList(labels)) |
||||||
|
} |
||||||
|
|
||||||
|
// CreateLabel create a label for a repository
|
||||||
|
func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) { |
||||||
|
// swagger:operation POST /orgs/{org}/labels organization orgCreateLabel
|
||||||
|
// ---
|
||||||
|
// summary: Create a label for an organization
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/CreateLabelOption"
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
|
|
||||||
|
form.Color = strings.Trim(form.Color, " ") |
||||||
|
if len(form.Color) == 6 { |
||||||
|
form.Color = "#" + form.Color |
||||||
|
} |
||||||
|
if !models.LabelColorPattern.MatchString(form.Color) { |
||||||
|
ctx.Error(http.StatusUnprocessableEntity, "ColorPattern", fmt.Errorf("bad color code: %s", form.Color)) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
label := &models.Label{ |
||||||
|
Name: form.Name, |
||||||
|
Color: form.Color, |
||||||
|
OrgID: ctx.Org.Organization.ID, |
||||||
|
Description: form.Description, |
||||||
|
} |
||||||
|
if err := models.NewLabel(label); err != nil { |
||||||
|
ctx.Error(http.StatusInternalServerError, "NewLabel", err) |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.JSON(http.StatusCreated, convert.ToLabel(label)) |
||||||
|
} |
||||||
|
|
||||||
|
// GetLabel get label by organization and label id
|
||||||
|
func GetLabel(ctx *context.APIContext) { |
||||||
|
// swagger:operation GET /orgs/{org}/labels/{id} organization orgGetLabel
|
||||||
|
// ---
|
||||||
|
// summary: Get a single label
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to get
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
|
|
||||||
|
var ( |
||||||
|
label *models.Label |
||||||
|
err error |
||||||
|
) |
||||||
|
strID := ctx.Params(":id") |
||||||
|
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil { |
||||||
|
label, err = models.GetLabelInOrgByName(ctx.Org.Organization.ID, strID) |
||||||
|
} else { |
||||||
|
label, err = models.GetLabelInOrgByID(ctx.Org.Organization.ID, intID) |
||||||
|
} |
||||||
|
if err != nil { |
||||||
|
if models.IsErrOrgLabelNotExist(err) { |
||||||
|
ctx.NotFound() |
||||||
|
} else { |
||||||
|
ctx.Error(http.StatusInternalServerError, "GetLabelByOrgID", err) |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, convert.ToLabel(label)) |
||||||
|
} |
||||||
|
|
||||||
|
// EditLabel modify a label for an Organization
|
||||||
|
func EditLabel(ctx *context.APIContext, form api.EditLabelOption) { |
||||||
|
// swagger:operation PATCH /orgs/{org}/labels/{id} organization orgEditLabel
|
||||||
|
// ---
|
||||||
|
// summary: Update a label
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to edit
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// - name: body
|
||||||
|
// in: body
|
||||||
|
// schema:
|
||||||
|
// "$ref": "#/definitions/EditLabelOption"
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/Label"
|
||||||
|
// "422":
|
||||||
|
// "$ref": "#/responses/validationError"
|
||||||
|
|
||||||
|
label, err := models.GetLabelInOrgByID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")) |
||||||
|
if err != nil { |
||||||
|
if models.IsErrOrgLabelNotExist(err) { |
||||||
|
ctx.NotFound() |
||||||
|
} else { |
||||||
|
ctx.Error(http.StatusInternalServerError, "GetLabelByRepoID", err) |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if form.Name != nil { |
||||||
|
label.Name = *form.Name |
||||||
|
} |
||||||
|
if form.Color != nil { |
||||||
|
label.Color = strings.Trim(*form.Color, " ") |
||||||
|
if len(label.Color) == 6 { |
||||||
|
label.Color = "#" + label.Color |
||||||
|
} |
||||||
|
if !models.LabelColorPattern.MatchString(label.Color) { |
||||||
|
ctx.Error(http.StatusUnprocessableEntity, "ColorPattern", fmt.Errorf("bad color code: %s", label.Color)) |
||||||
|
return |
||||||
|
} |
||||||
|
} |
||||||
|
if form.Description != nil { |
||||||
|
label.Description = *form.Description |
||||||
|
} |
||||||
|
if err := models.UpdateLabel(label); err != nil { |
||||||
|
ctx.ServerError("UpdateLabel", err) |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.JSON(http.StatusOK, convert.ToLabel(label)) |
||||||
|
} |
||||||
|
|
||||||
|
// DeleteLabel delete a label for an organization
|
||||||
|
func DeleteLabel(ctx *context.APIContext) { |
||||||
|
// swagger:operation DELETE /orgs/{org}/labels/{id} organization orgDeleteLabel
|
||||||
|
// ---
|
||||||
|
// summary: Delete a label
|
||||||
|
// parameters:
|
||||||
|
// - name: org
|
||||||
|
// in: path
|
||||||
|
// description: name of the organization
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: id
|
||||||
|
// in: path
|
||||||
|
// description: id of the label to delete
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
|
||||||
|
if err := models.DeleteLabel(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil { |
||||||
|
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
ctx.Status(http.StatusNoContent) |
||||||
|
} |
@ -0,0 +1,106 @@ |
|||||||
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package org |
||||||
|
|
||||||
|
import ( |
||||||
|
"code.gitea.io/gitea/models" |
||||||
|
"code.gitea.io/gitea/modules/auth" |
||||||
|
"code.gitea.io/gitea/modules/context" |
||||||
|
) |
||||||
|
|
||||||
|
// RetrieveLabels find all the labels of an organization
|
||||||
|
func RetrieveLabels(ctx *context.Context) { |
||||||
|
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Query("sort"), models.ListOptions{}) |
||||||
|
if err != nil { |
||||||
|
ctx.ServerError("RetrieveLabels.GetLabels", err) |
||||||
|
return |
||||||
|
} |
||||||
|
for _, l := range labels { |
||||||
|
l.CalOpenIssues() |
||||||
|
} |
||||||
|
ctx.Data["Labels"] = labels |
||||||
|
ctx.Data["NumLabels"] = len(labels) |
||||||
|
ctx.Data["SortType"] = ctx.Query("sort") |
||||||
|
} |
||||||
|
|
||||||
|
// NewLabel create new label for organization
|
||||||
|
func NewLabel(ctx *context.Context, form auth.CreateLabelForm) { |
||||||
|
ctx.Data["Title"] = ctx.Tr("repo.labels") |
||||||
|
ctx.Data["PageIsLabels"] = true |
||||||
|
|
||||||
|
if ctx.HasError() { |
||||||
|
ctx.Flash.Error(ctx.Data["ErrorMsg"].(string)) |
||||||
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels") |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
l := &models.Label{ |
||||||
|
OrgID: ctx.Org.Organization.ID, |
||||||
|
Name: form.Title, |
||||||
|
Description: form.Description, |
||||||
|
Color: form.Color, |
||||||
|
} |
||||||
|
if err := models.NewLabel(l); err != nil { |
||||||
|
ctx.ServerError("NewLabel", err) |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels") |
||||||
|
} |
||||||
|
|
||||||
|
// UpdateLabel update a label's name and color
|
||||||
|
func UpdateLabel(ctx *context.Context, form auth.CreateLabelForm) { |
||||||
|
l, err := models.GetLabelInOrgByID(ctx.Org.Organization.ID, form.ID) |
||||||
|
if err != nil { |
||||||
|
switch { |
||||||
|
case models.IsErrOrgLabelNotExist(err): |
||||||
|
ctx.Error(404) |
||||||
|
default: |
||||||
|
ctx.ServerError("UpdateLabel", err) |
||||||
|
} |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
l.Name = form.Title |
||||||
|
l.Description = form.Description |
||||||
|
l.Color = form.Color |
||||||
|
if err := models.UpdateLabel(l); err != nil { |
||||||
|
ctx.ServerError("UpdateLabel", err) |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels") |
||||||
|
} |
||||||
|
|
||||||
|
// DeleteLabel delete a label
|
||||||
|
func DeleteLabel(ctx *context.Context) { |
||||||
|
if err := models.DeleteLabel(ctx.Org.Organization.ID, ctx.QueryInt64("id")); err != nil { |
||||||
|
ctx.Flash.Error("DeleteLabel: " + err.Error()) |
||||||
|
} else { |
||||||
|
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success")) |
||||||
|
} |
||||||
|
|
||||||
|
ctx.JSON(200, map[string]interface{}{ |
||||||
|
"redirect": ctx.Org.OrgLink + "/settings/labels", |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
// InitializeLabels init labels for an organization
|
||||||
|
func InitializeLabels(ctx *context.Context, form auth.InitializeLabelsForm) { |
||||||
|
if ctx.HasError() { |
||||||
|
ctx.Redirect(ctx.Repo.RepoLink + "/labels") |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if err := models.InitializeLabels(models.DefaultDBContext(), ctx.Org.Organization.ID, form.TemplateName, true); err != nil { |
||||||
|
if models.IsErrIssueLabelTemplateLoad(err) { |
||||||
|
originalErr := err.(models.ErrIssueLabelTemplateLoad).OriginalError |
||||||
|
ctx.Flash.Error(ctx.Tr("repo.issues.label_templates.fail_to_load_file", form.TemplateName, originalErr)) |
||||||
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels") |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.ServerError("InitializeLabels", err) |
||||||
|
return |
||||||
|
} |
||||||
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels") |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
{{template "base/head" .}} |
||||||
|
<div class="organization settings labels"> |
||||||
|
{{template "org/header" .}} |
||||||
|
<div class="ui container"> |
||||||
|
<div class="ui grid"> |
||||||
|
{{template "org/settings/navbar" .}} |
||||||
|
<div class="ui twelve wide column content"> |
||||||
|
<div class="ui grid"> |
||||||
|
<div class="left floated twelve wide column"> |
||||||
|
{{$.i18n.Tr "org.settings.labels_desc" | Str2html}} |
||||||
|
</div> |
||||||
|
<div class="right floated three wide column"> |
||||||
|
<div class="ui right"> |
||||||
|
<div class="ui green new-label button">{{.i18n.Tr "repo.issues.new_label"}}</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="ui divider"></div> |
||||||
|
{{template "repo/issue/labels/label_new" .}} |
||||||
|
{{template "base/alert" .}} |
||||||
|
{{template "repo/issue/labels/label_list" .}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
{{template "repo/issue/labels/edit_delete_label" .}} |
||||||
|
{{template "base/footer" .}} |
@ -0,0 +1,59 @@ |
|||||||
|
<div class="ui small basic delete modal"> |
||||||
|
<div class="ui icon header"> |
||||||
|
<i class="trash icon"></i> |
||||||
|
{{.i18n.Tr "repo.issues.label_deletion"}} |
||||||
|
</div> |
||||||
|
<div class="content"> |
||||||
|
<p>{{.i18n.Tr "repo.issues.label_deletion_desc"}}</p> |
||||||
|
</div> |
||||||
|
<div class="actions"> |
||||||
|
<div class="ui red basic inverted cancel button"> |
||||||
|
<i class="remove icon"></i> |
||||||
|
{{.i18n.Tr "modal.no"}} |
||||||
|
</div> |
||||||
|
<div class="ui green basic inverted ok button"> |
||||||
|
<i class="checkmark icon"></i> |
||||||
|
{{.i18n.Tr "modal.yes"}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="ui small edit-label modal"> |
||||||
|
<div class="header"> |
||||||
|
{{.i18n.Tr "repo.issues.label_modify"}} |
||||||
|
</div> |
||||||
|
<div class="content"> |
||||||
|
<form class="ui edit-label form" action="{{$.Link}}/edit" method="post"> |
||||||
|
{{.CsrfTokenHtml}} |
||||||
|
<input id="label-modal-id" name="id" type="hidden"> |
||||||
|
<div class="ui grid"> |
||||||
|
<div class="three wide column"> |
||||||
|
<div class="ui small input"> |
||||||
|
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required maxlength="50"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="five wide column"> |
||||||
|
<div class="ui small fluid input"> |
||||||
|
<input class="new-label-desc-input" name="description" placeholder="{{.i18n.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> |
||||||
|
</div> |
||||||
|
</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> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
<div class="actions"> |
||||||
|
<div class="ui negative button"> |
||||||
|
{{.i18n.Tr "modal.no"}} |
||||||
|
</div> |
||||||
|
<div class="ui positive right labeled icon button"> |
||||||
|
{{.i18n.Tr "modal.modify"}} |
||||||
|
<i class="checkmark icon"></i> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
@ -0,0 +1,97 @@ |
|||||||
|
<h4 class="ui top attached header"> |
||||||
|
{{.i18n.Tr "repo.issues.label_count" .NumLabels}} |
||||||
|
<div class="ui right"> |
||||||
|
<div class="ui right floated secondary filter menu"> |
||||||
|
<!-- Sort --> |
||||||
|
<div class="ui dropdown type jump item"> |
||||||
|
<span class="text"> |
||||||
|
{{.i18n.Tr "repo.issues.filter_sort"}} |
||||||
|
<i class="dropdown icon"></i> |
||||||
|
</span> |
||||||
|
<div class="menu"> |
||||||
|
<a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active{{end}} item" href="{{$.Link}}?sort=alphabetically&state={{$.State}}">{{.i18n.Tr "repo.issues.label.filter_sort.alphabetically"}}</a> |
||||||
|
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&state={{$.State}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a> |
||||||
|
<a class="{{if eq .SortType "leastissues"}}active{{end}} item" href="{{$.Link}}?sort=leastissues&state={{$.State}}">{{.i18n.Tr "repo.milestones.filter_sort.least_issues"}}</a> |
||||||
|
<a class="{{if eq .SortType "mostissues"}}active{{end}} item" href="{{$.Link}}?sort=mostissues&state={{$.State}}">{{.i18n.Tr "repo.milestones.filter_sort.most_issues"}}</a> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> <!-- filter menu --> |
||||||
|
</h4> |
||||||
|
|
||||||
|
<div class="ui attached segment"> |
||||||
|
<div class="labelspage"> |
||||||
|
{{if and (not $.PageIsOrgSettingsLabels) (or $.CanWriteIssues $.CanWritePulls) (eq .NumLabels 0) (not $.Repository.IsArchived) }} |
||||||
|
{{template "repo/issue/labels/label_load_template" .}} |
||||||
|
<div class="ui divider"></div> |
||||||
|
{{else if and ($.PageIsOrgSettingsLabels) (eq .NumLabels 0)}} |
||||||
|
{{template "repo/issue/labels/label_load_template" .}} |
||||||
|
{{end}} |
||||||
|
{{range .Labels}} |
||||||
|
<li class="item"> |
||||||
|
<div class="ui grid middle aligned"> |
||||||
|
<div class="four wide column"> |
||||||
|
<div class="ui label has-emoji" style="color: {{.ForegroundColor}}; background-color: {{.Color}}">{{svg "octicon-tag" 16}} {{.Name}}</div> |
||||||
|
</div> |
||||||
|
<div class="six wide column"> |
||||||
|
<div class="ui has-emoji"> |
||||||
|
{{.Description}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="three wide column"> |
||||||
|
{{if $.PageIsOrgSettingsLabels}} |
||||||
|
<a class="ui right open-issues" href="/issues?labels={{.ID}}">{{svg "octicon-issue-opened" 16}} {{$.i18n.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a> |
||||||
|
{{else}} |
||||||
|
<a class="ui right open-issues" href="{{$.RepoLink}}/issues?labels={{.ID}}">{{svg "octicon-issue-opened" 16}} {{$.i18n.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a> |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
<div class="three wide column"> |
||||||
|
{{if and (not $.PageIsOrgSettingsLabels ) (not $.Repository.IsArchived) (or $.CanWriteIssues $.CanWritePulls)}} |
||||||
|
<a class="ui right delete-button" href="#" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trashcan" 16}} {{$.i18n.Tr "repo.issues.label_delete"}}</a> |
||||||
|
<a class="ui right edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" data-description="{{.Description}}" data-color={{.Color}}>{{svg "octicon-pencil" 16}} {{$.i18n.Tr "repo.issues.label_edit"}}</a> |
||||||
|
{{else if $.PageIsOrgSettingsLabels}} |
||||||
|
<a class="ui right delete-button" href="#" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trashcan" 16}} {{$.i18n.Tr "repo.issues.label_delete"}}</a> |
||||||
|
<a class="ui right edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" data-description="{{.Description}}" data-color={{.Color}}>{{svg "octicon-pencil" 16}} {{$.i18n.Tr "repo.issues.label_edit"}}</a> |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</li> |
||||||
|
{{end}} |
||||||
|
{{if and (not .PageIsOrgSettingsLabels) (.OrgLabels) }} |
||||||
|
<li class="item"> |
||||||
|
<div class="ui grid middle aligned"> |
||||||
|
<div class="ten wide column"> |
||||||
|
{{$.i18n.Tr "repo.org_labels_desc" | Str2html}} |
||||||
|
{{if .IsOrganizationOwner}} |
||||||
|
<a class="ui" href="{{.OrganizationLink}}/settings/labels">({{$.i18n.Tr "repo.org_labels_desc_manage"}})</a>: |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</li> |
||||||
|
{{if (not $.PageIsOrgSettingsLabels)}} |
||||||
|
<div class="orglabel"> |
||||||
|
{{range .OrgLabels}} |
||||||
|
<li class="item"> |
||||||
|
<div class="ui grid middle aligned"> |
||||||
|
<div class="three wide column"> |
||||||
|
<div class="ui label has-emoji" style="color: {{.ForegroundColor}}; background-color: {{.Color}}">{{svg "octicon-tag" 16}} {{.Name}}</div> |
||||||
|
</div> |
||||||
|
<div class="seven wide column"> |
||||||
|
<div class="ui has-emoji"> |
||||||
|
{{.Description}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="three wide column"> |
||||||
|
<a class="ui right open-issues" href="{{$.RepoLink}}/issues?labels={{.ID}}">{{svg "octicon-issue-opened" 16}} {{$.i18n.Tr "repo.issues.label_open_issues" .NumOpenRepoIssues}}</a> |
||||||
|
</div> |
||||||
|
<div class="three wide column"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</li> |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
{{end}} |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
@ -0,0 +1,30 @@ |
|||||||
|
<div class="ui centered grid"> |
||||||
|
<div class="twelve wide computer column"> |
||||||
|
<div class="ui attached left aligned segment"> |
||||||
|
<!-- <h4 class="ui header"> |
||||||
|
{{.i18n.Tr "repo.issues.label_templates.title"}} |
||||||
|
<a target="_blank" rel="noopener noreferrer" |
||||||
|
href="https://discuss.gogs.io/t/how-to-use-predefined-label-templates/599"> |
||||||
|
<span class="octicon octicon-question"></span> |
||||||
|
</a> |
||||||
|
</h4> --> |
||||||
|
<p>{{.i18n.Tr "repo.issues.label_templates.info"}}</p> |
||||||
|
<br/> |
||||||
|
<form class="ui form center" action="{{.Link}}/initialize" method="post"> |
||||||
|
{{.CsrfTokenHtml}} |
||||||
|
<div class="field"> |
||||||
|
<div class="ui selection dropdown"> |
||||||
|
<input type="hidden" name="template_name" value="Default"> |
||||||
|
<div class="default text">{{.i18n.Tr "repo.issues.label_templates.helper"}}</div> |
||||||
|
<div class="menu"> |
||||||
|
{{range $template, $labels := .LabelTemplates}} |
||||||
|
<div class="item" data-value="{{$template}}">{{$template}}<br/><i>({{$labels}})</i></div> |
||||||
|
{{end}} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<button type="submit" class="ui blue button">{{.i18n.Tr "repo.issues.label_templates.use"}}</button> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,27 @@ |
|||||||
|
<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 input"> |
||||||
|
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.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="{{.i18n.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> |
||||||
|
</div> |
||||||
|
</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> |
||||||
|
<div class="buttons"> |
||||||
|
<div class="ui blue small basic cancel button">{{.i18n.Tr "repo.milestones.cancel"}}</div> |
||||||
|
<button class="ui green small button">{{.i18n.Tr "repo.issues.create_label"}}</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
Loading…
Reference in new issue