2014-08-14 10:12:21 +04:00
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
2019-02-18 19:00:27 +03:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
2014-08-14 10:12:21 +04:00
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
2021-04-05 18:30:52 +03:00
|
|
|
"net/http"
|
2021-11-16 21:18:25 +03:00
|
|
|
"net/url"
|
2015-09-18 00:21:27 +03:00
|
|
|
"strings"
|
|
|
|
|
2016-11-10 19:24:48 +03:00
|
|
|
"code.gitea.io/gitea/models"
|
2021-09-24 14:32:56 +03:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2021-12-12 18:48:20 +03:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-11-24 12:49:20 +03:00
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2021-11-10 08:13:16 +03:00
|
|
|
"code.gitea.io/gitea/models/webhook"
|
2016-11-10 19:24:48 +03:00
|
|
|
"code.gitea.io/gitea/modules/base"
|
|
|
|
"code.gitea.io/gitea/modules/context"
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
2022-03-29 10:23:45 +03:00
|
|
|
repo_module "code.gitea.io/gitea/modules/repository"
|
2016-11-10 19:24:48 +03:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2021-01-26 18:36:53 +03:00
|
|
|
"code.gitea.io/gitea/modules/web"
|
2021-11-22 18:21:55 +03:00
|
|
|
user_setting "code.gitea.io/gitea/routers/web/user/setting"
|
2021-04-06 22:44:05 +03:00
|
|
|
"code.gitea.io/gitea/services/forms"
|
2021-11-18 20:42:27 +03:00
|
|
|
"code.gitea.io/gitea/services/org"
|
2022-06-06 11:01:49 +03:00
|
|
|
repo_service "code.gitea.io/gitea/services/repository"
|
2021-11-22 18:21:55 +03:00
|
|
|
user_service "code.gitea.io/gitea/services/user"
|
2014-08-14 10:12:21 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2016-11-18 06:03:03 +03:00
|
|
|
// tplSettingsOptions template path for render settings
|
|
|
|
tplSettingsOptions base.TplName = "org/settings/options"
|
|
|
|
// tplSettingsDelete template path for render delete repository
|
|
|
|
tplSettingsDelete base.TplName = "org/settings/delete"
|
|
|
|
// tplSettingsHooks template path for render hook settings
|
|
|
|
tplSettingsHooks base.TplName = "org/settings/hooks"
|
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>
2020-04-01 07:14:46 +03:00
|
|
|
// tplSettingsLabels template path for render labels settings
|
|
|
|
tplSettingsLabels base.TplName = "org/settings/labels"
|
2014-08-14 10:12:21 +04:00
|
|
|
)
|
|
|
|
|
2016-11-18 06:03:03 +03:00
|
|
|
// Settings render the main settings page
|
2016-03-11 19:56:52 +03:00
|
|
|
func Settings(ctx *context.Context) {
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["Title"] = ctx.Tr("org.settings")
|
2021-11-25 18:15:58 +03:00
|
|
|
ctx.Data["PageIsOrgSettings"] = true
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["PageIsSettingsOptions"] = true
|
2019-07-23 21:50:39 +03:00
|
|
|
ctx.Data["CurrentVisibility"] = ctx.Org.Organization.Visibility
|
2019-09-30 02:20:27 +03:00
|
|
|
ctx.Data["RepoAdminChangeTeamAccess"] = ctx.Org.Organization.RepoAdminChangeTeamAccess
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.HTML(http.StatusOK, tplSettingsOptions)
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
|
|
|
|
2021-07-08 14:38:13 +03:00
|
|
|
// SettingsPost response for settings change submitted
|
2021-01-26 18:36:53 +03:00
|
|
|
func SettingsPost(ctx *context.Context) {
|
2021-04-06 22:44:05 +03:00
|
|
|
form := web.GetForm(ctx).(*forms.UpdateOrgSettingForm)
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["Title"] = ctx.Tr("org.settings")
|
2021-11-25 18:15:58 +03:00
|
|
|
ctx.Data["PageIsOrgSettings"] = true
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["PageIsSettingsOptions"] = true
|
2019-07-23 21:50:39 +03:00
|
|
|
ctx.Data["CurrentVisibility"] = ctx.Org.Organization.Visibility
|
2014-08-14 10:12:21 +04:00
|
|
|
|
|
|
|
if ctx.HasError() {
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.HTML(http.StatusOK, tplSettingsOptions)
|
2014-08-14 10:12:21 +04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
org := ctx.Org.Organization
|
2021-06-02 15:03:59 +03:00
|
|
|
nameChanged := org.Name != form.Name
|
2014-08-14 10:12:21 +04:00
|
|
|
|
|
|
|
// Check if organization name has been changed.
|
2015-09-18 00:21:27 +03:00
|
|
|
if org.LowerName != strings.ToLower(form.Name) {
|
2022-05-20 17:08:52 +03:00
|
|
|
isExist, err := user_model.IsUserExist(ctx, org.ID, form.Name)
|
2014-08-14 10:12:21 +04:00
|
|
|
if err != nil {
|
2018-01-11 00:34:17 +03:00
|
|
|
ctx.ServerError("IsUserExist", err)
|
2014-08-14 10:12:21 +04:00
|
|
|
return
|
|
|
|
} else if isExist {
|
2015-09-06 17:56:31 +03:00
|
|
|
ctx.Data["OrgName"] = true
|
2016-11-18 06:03:03 +03:00
|
|
|
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form)
|
2014-08-14 10:12:21 +04:00
|
|
|
return
|
2021-11-24 12:49:20 +03:00
|
|
|
} else if err = user_model.ChangeUserName(org.AsUser(), form.Name); err != nil {
|
2022-01-20 18:18:46 +03:00
|
|
|
switch {
|
|
|
|
case db.IsErrNameReserved(err):
|
2015-09-06 17:56:31 +03:00
|
|
|
ctx.Data["OrgName"] = true
|
2022-01-20 18:18:46 +03:00
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(db.ErrNameReserved).Name), tplSettingsOptions, &form)
|
|
|
|
case db.IsErrNamePatternNotAllowed(err):
|
|
|
|
ctx.Data["OrgName"] = true
|
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(db.ErrNamePatternNotAllowed).Pattern), tplSettingsOptions, &form)
|
|
|
|
default:
|
2018-01-11 00:34:17 +03:00
|
|
|
ctx.ServerError("ChangeUserName", err)
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2015-12-23 12:50:14 +03:00
|
|
|
// reset ctx.org.OrgLink with new name
|
2021-11-16 21:18:25 +03:00
|
|
|
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + url.PathEscape(form.Name)
|
2015-09-06 17:56:31 +03:00
|
|
|
log.Trace("Organization name changed: %s -> %s", org.Name, form.Name)
|
2021-06-02 15:03:59 +03:00
|
|
|
nameChanged = false
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
2021-06-02 15:03:59 +03:00
|
|
|
|
2015-09-18 00:21:27 +03:00
|
|
|
// In case it's just a case change.
|
|
|
|
org.Name = form.Name
|
|
|
|
org.LowerName = strings.ToLower(form.Name)
|
2014-08-14 10:12:21 +04:00
|
|
|
|
2022-03-22 10:03:22 +03:00
|
|
|
if ctx.Doer.IsAdmin {
|
2015-12-12 03:24:57 +03:00
|
|
|
org.MaxRepoCreation = form.MaxRepoCreation
|
|
|
|
}
|
|
|
|
|
2015-09-06 17:56:31 +03:00
|
|
|
org.FullName = form.FullName
|
2014-08-14 10:12:21 +04:00
|
|
|
org.Description = form.Description
|
|
|
|
org.Website = form.Website
|
|
|
|
org.Location = form.Location
|
2019-09-23 23:08:03 +03:00
|
|
|
org.RepoAdminChangeTeamAccess = form.RepoAdminChangeTeamAccess
|
2020-06-07 03:45:12 +03:00
|
|
|
|
|
|
|
visibilityChanged := form.Visibility != org.Visibility
|
|
|
|
org.Visibility = form.Visibility
|
|
|
|
|
2022-05-20 17:08:52 +03:00
|
|
|
if err := user_model.UpdateUser(ctx, org.AsUser(), false); err != nil {
|
2018-01-11 00:34:17 +03:00
|
|
|
ctx.ServerError("UpdateUser", err)
|
2014-08-14 10:12:21 +04:00
|
|
|
return
|
|
|
|
}
|
2020-06-07 03:45:12 +03:00
|
|
|
|
|
|
|
// update forks visibility
|
|
|
|
if visibilityChanged {
|
2022-06-06 11:01:49 +03:00
|
|
|
repos, _, err := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{
|
2022-01-20 20:46:10 +03:00
|
|
|
Actor: org.AsUser(), Private: true, ListOptions: db.ListOptions{Page: 1, PageSize: org.NumRepos},
|
|
|
|
})
|
2021-11-19 14:41:40 +03:00
|
|
|
if err != nil {
|
2020-06-07 03:45:12 +03:00
|
|
|
ctx.ServerError("GetRepositories", err)
|
|
|
|
return
|
|
|
|
}
|
2021-11-19 14:41:40 +03:00
|
|
|
for _, repo := range repos {
|
2021-06-02 15:03:59 +03:00
|
|
|
repo.OwnerName = org.Name
|
2022-06-06 11:01:49 +03:00
|
|
|
if err := repo_service.UpdateRepository(repo, true); err != nil {
|
2020-06-07 03:45:12 +03:00
|
|
|
ctx.ServerError("UpdateRepository", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-06-02 15:03:59 +03:00
|
|
|
} else if nameChanged {
|
2021-12-12 18:48:20 +03:00
|
|
|
if err := repo_model.UpdateRepositoryOwnerNames(org.ID, org.Name); err != nil {
|
2021-06-02 15:03:59 +03:00
|
|
|
ctx.ServerError("UpdateRepository", err)
|
|
|
|
return
|
|
|
|
}
|
2020-06-07 03:45:12 +03:00
|
|
|
}
|
|
|
|
|
2014-08-14 10:12:21 +04:00
|
|
|
log.Trace("Organization setting updated: %s", org.Name)
|
|
|
|
ctx.Flash.Success(ctx.Tr("org.settings.update_setting_success"))
|
2015-11-25 03:28:24 +03:00
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
|
|
|
|
2016-11-18 06:03:03 +03:00
|
|
|
// SettingsAvatar response for change avatar on settings page
|
2021-01-26 18:36:53 +03:00
|
|
|
func SettingsAvatar(ctx *context.Context) {
|
2021-04-06 22:44:05 +03:00
|
|
|
form := web.GetForm(ctx).(*forms.AvatarForm)
|
|
|
|
form.Source = forms.AvatarLocal
|
2021-11-22 18:21:55 +03:00
|
|
|
if err := user_setting.UpdateAvatarSetting(ctx, form, ctx.Org.Organization.AsUser()); err != nil {
|
2015-09-07 00:12:02 +03:00
|
|
|
ctx.Flash.Error(err.Error())
|
|
|
|
} else {
|
|
|
|
ctx.Flash.Success(ctx.Tr("org.settings.update_avatar_success"))
|
|
|
|
}
|
|
|
|
|
2016-03-06 19:36:30 +03:00
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
|
|
|
}
|
|
|
|
|
2021-07-08 14:38:13 +03:00
|
|
|
// SettingsDeleteAvatar response for delete avatar on settings page
|
2016-03-11 19:56:52 +03:00
|
|
|
func SettingsDeleteAvatar(ctx *context.Context) {
|
2021-11-22 18:21:55 +03:00
|
|
|
if err := user_service.DeleteAvatar(ctx.Org.Organization.AsUser()); err != nil {
|
2016-03-06 19:36:30 +03:00
|
|
|
ctx.Flash.Error(err.Error())
|
|
|
|
}
|
|
|
|
|
2015-09-07 00:12:02 +03:00
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/settings")
|
|
|
|
}
|
|
|
|
|
2020-02-03 19:46:33 +03:00
|
|
|
// SettingsDelete response for deleting an organization
|
2016-03-11 19:56:52 +03:00
|
|
|
func SettingsDelete(ctx *context.Context) {
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["Title"] = ctx.Tr("org.settings")
|
2021-11-25 18:15:58 +03:00
|
|
|
ctx.Data["PageIsOrgSettings"] = true
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Data["PageIsSettingsDelete"] = true
|
|
|
|
|
|
|
|
if ctx.Req.Method == "POST" {
|
2021-11-18 20:42:27 +03:00
|
|
|
if ctx.Org.Organization.Name != ctx.FormString("org_name") {
|
2021-03-01 17:33:05 +03:00
|
|
|
ctx.Data["Err_OrgName"] = true
|
|
|
|
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil)
|
2015-09-06 18:25:08 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-18 20:42:27 +03:00
|
|
|
if err := org.DeleteOrganization(ctx.Org.Organization); err != nil {
|
2015-03-18 04:51:39 +03:00
|
|
|
if models.IsErrUserOwnRepos(err) {
|
2014-08-14 10:12:21 +04:00
|
|
|
ctx.Flash.Error(ctx.Tr("form.org_still_own_repo"))
|
2015-11-25 03:28:24 +03:00
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/delete")
|
2022-03-30 11:42:47 +03:00
|
|
|
} else if models.IsErrUserOwnPackages(err) {
|
|
|
|
ctx.Flash.Error(ctx.Tr("form.org_still_own_packages"))
|
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/settings/delete")
|
2015-03-18 04:51:39 +03:00
|
|
|
} else {
|
2018-01-11 00:34:17 +03:00
|
|
|
ctx.ServerError("DeleteOrganization", err)
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
|
|
|
} else {
|
2021-11-18 20:42:27 +03:00
|
|
|
log.Trace("Organization deleted: %s", ctx.Org.Organization.Name)
|
2016-11-27 13:14:25 +03:00
|
|
|
ctx.Redirect(setting.AppSubURL + "/")
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.HTML(http.StatusOK, tplSettingsDelete)
|
2014-08-14 10:12:21 +04:00
|
|
|
}
|
2014-09-04 15:17:00 +04:00
|
|
|
|
2016-11-18 06:03:03 +03:00
|
|
|
// Webhooks render webhook list page
|
2016-03-11 19:56:52 +03:00
|
|
|
func Webhooks(ctx *context.Context) {
|
2014-09-04 15:17:00 +04:00
|
|
|
ctx.Data["Title"] = ctx.Tr("org.settings")
|
2021-11-25 18:15:58 +03:00
|
|
|
ctx.Data["PageIsOrgSettings"] = true
|
2014-09-04 15:17:00 +04:00
|
|
|
ctx.Data["PageIsSettingsHooks"] = true
|
2019-03-19 05:33:20 +03:00
|
|
|
ctx.Data["BaseLink"] = ctx.Org.OrgLink + "/settings/hooks"
|
2021-01-15 02:24:03 +03:00
|
|
|
ctx.Data["BaseLinkNew"] = ctx.Org.OrgLink + "/settings/hooks"
|
2015-08-26 16:45:51 +03:00
|
|
|
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
|
2014-09-04 15:17:00 +04:00
|
|
|
|
2022-05-20 17:08:52 +03:00
|
|
|
ws, err := webhook.ListWebhooksByOpts(ctx, &webhook.ListWebhookOptions{OrgID: ctx.Org.Organization.ID})
|
2014-09-04 15:17:00 +04:00
|
|
|
if err != nil {
|
2018-01-11 00:34:17 +03:00
|
|
|
ctx.ServerError("GetWebhooksByOrgId", err)
|
2014-09-04 15:17:00 +04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Data["Webhooks"] = ws
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.HTML(http.StatusOK, tplSettingsHooks)
|
2014-09-04 15:17:00 +04:00
|
|
|
}
|
2015-08-26 16:45:51 +03:00
|
|
|
|
2016-11-18 06:03:03 +03:00
|
|
|
// DeleteWebhook response for delete webhook
|
2016-03-11 19:56:52 +03:00
|
|
|
func DeleteWebhook(ctx *context.Context) {
|
2021-11-10 08:13:16 +03:00
|
|
|
if err := webhook.DeleteWebhookByOrgID(ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
|
2016-07-17 03:33:59 +03:00
|
|
|
ctx.Flash.Error("DeleteWebhookByOrgID: " + err.Error())
|
2015-08-26 16:45:51 +03:00
|
|
|
} else {
|
|
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
|
|
|
}
|
|
|
|
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{
|
2015-08-26 16:45:51 +03:00
|
|
|
"redirect": ctx.Org.OrgLink + "/settings/hooks",
|
|
|
|
})
|
|
|
|
}
|
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>
2020-04-01 07:14:46 +03:00
|
|
|
|
|
|
|
// Labels render organization labels page
|
|
|
|
func Labels(ctx *context.Context) {
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.labels")
|
2021-11-25 18:15:58 +03:00
|
|
|
ctx.Data["PageIsOrgSettings"] = true
|
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>
2020-04-01 07:14:46 +03:00
|
|
|
ctx.Data["PageIsOrgSettingsLabels"] = true
|
|
|
|
ctx.Data["RequireTribute"] = true
|
2022-03-29 10:23:45 +03:00
|
|
|
ctx.Data["LabelTemplates"] = repo_module.LabelTemplates
|
2021-04-05 18:30:52 +03:00
|
|
|
ctx.HTML(http.StatusOK, tplSettingsLabels)
|
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>
2020-04-01 07:14:46 +03:00
|
|
|
}
|