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