mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
Show that repo is disabled (#2340)
And allow to show badges for disabled repos Fixes 3rd checkbox from https://github.com/woodpecker-ci/woodpecker/discussions/2162#discussion-5498655 ![Screenshot 2023-08-28 at 11-13-23 Woodpecker](https://github.com/woodpecker-ci/woodpecker/assets/80460567/d881f0c5-6225-4921-9d05-a26f27ad5365)
This commit is contained in:
parent
25225d4902
commit
5bd12aa646
4 changed files with 28 additions and 18 deletions
|
@ -61,8 +61,8 @@ func GetBadge(c *gin.Context) {
|
|||
repo, err = _store.GetRepo(repoID)
|
||||
}
|
||||
|
||||
if err != nil || !repo.IsActive {
|
||||
if err == nil || errors.Is(err, types.RecordNotExist) {
|
||||
if err != nil {
|
||||
if errors.Is(err, types.RecordNotExist) {
|
||||
c.AbortWithStatus(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/securecookie"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
||||
|
@ -90,15 +91,15 @@ func GetRepos(c *gin.Context) {
|
|||
user := session.User(c)
|
||||
all, _ := strconv.ParseBool(c.Query("all"))
|
||||
|
||||
activeRepos, err := _store.RepoList(user, true, true)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "Error fetching repository list. %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
if all {
|
||||
dbRepos, err := _store.RepoList(user, true, false)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "Error fetching repository list. %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
active := map[model.ForgeRemoteID]*model.Repo{}
|
||||
for _, r := range activeRepos {
|
||||
for _, r := range dbRepos {
|
||||
active[r.ForgeRemoteID] = r
|
||||
}
|
||||
|
||||
|
@ -111,10 +112,10 @@ func GetRepos(c *gin.Context) {
|
|||
var repos []*model.Repo
|
||||
for _, r := range _repos {
|
||||
if r.Perm.Push {
|
||||
if active[r.ForgeRemoteID] != nil && active[r.ForgeRemoteID].IsActive {
|
||||
if active[r.ForgeRemoteID] != nil {
|
||||
existingRepo := active[r.ForgeRemoteID]
|
||||
existingRepo.Update(r)
|
||||
existingRepo.IsActive = true
|
||||
existingRepo.IsActive = active[r.ForgeRemoteID].IsActive
|
||||
repos = append(repos, existingRepo)
|
||||
} else {
|
||||
repos = append(repos, r)
|
||||
|
@ -126,6 +127,12 @@ func GetRepos(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
activeRepos, err := _store.RepoList(user, true, true)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "Error fetching repository list. %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, activeRepos)
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
"reload": "Reload repositories",
|
||||
"enable": "Enable",
|
||||
"enabled": "Already enabled",
|
||||
"disabled": "Disabled",
|
||||
"success": "Repository enabled",
|
||||
"list_reloaded": "Repository list reloaded"
|
||||
},
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
>
|
||||
<span class="text-wp-text-100">{{ repo.full_name }}</span>
|
||||
<span v-if="repo.active" class="ml-auto text-wp-text-alt-100">{{ $t('repo.enable.enabled') }}</span>
|
||||
<Button
|
||||
v-if="!repo.active"
|
||||
class="ml-auto"
|
||||
:text="$t('repo.enable.enable')"
|
||||
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
|
||||
@click="activateRepo(repo)"
|
||||
/>
|
||||
<div v-else class="ml-auto flex items-center">
|
||||
<Badge v-if="repo.id" class="<md:hidden mr-2" :label="$t('repo.enable.disabled')" />
|
||||
<Button
|
||||
:text="$t('repo.enable.enable')"
|
||||
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
|
||||
@click="activateRepo(repo)"
|
||||
/>
|
||||
</div>
|
||||
</ListItem>
|
||||
</div>
|
||||
</Scaffold>
|
||||
|
@ -30,6 +31,7 @@ import { onMounted, ref } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import Badge from '~/components/atomic/Badge.vue';
|
||||
import Button from '~/components/atomic/Button.vue';
|
||||
import ListItem from '~/components/atomic/ListItem.vue';
|
||||
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
|
||||
|
|
Loading…
Reference in a new issue