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