mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 02:11:01 +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)
|
repo, err = _store.GetRepo(repoID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil || !repo.IsActive {
|
if err != nil {
|
||||||
if err == nil || errors.Is(err, types.RecordNotExist) {
|
if errors.Is(err, types.RecordNotExist) {
|
||||||
c.AbortWithStatus(http.StatusNotFound)
|
c.AbortWithStatus(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/server"
|
"github.com/woodpecker-ci/woodpecker/server"
|
||||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||||
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
||||||
|
@ -90,15 +91,15 @@ func GetRepos(c *gin.Context) {
|
||||||
user := session.User(c)
|
user := session.User(c)
|
||||||
all, _ := strconv.ParseBool(c.Query("all"))
|
all, _ := strconv.ParseBool(c.Query("all"))
|
||||||
|
|
||||||
activeRepos, err := _store.RepoList(user, true, true)
|
if all {
|
||||||
|
dbRepos, err := _store.RepoList(user, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusInternalServerError, "Error fetching repository list. %s", err)
|
c.String(http.StatusInternalServerError, "Error fetching repository list. %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if all {
|
|
||||||
active := map[model.ForgeRemoteID]*model.Repo{}
|
active := map[model.ForgeRemoteID]*model.Repo{}
|
||||||
for _, r := range activeRepos {
|
for _, r := range dbRepos {
|
||||||
active[r.ForgeRemoteID] = r
|
active[r.ForgeRemoteID] = r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +112,10 @@ func GetRepos(c *gin.Context) {
|
||||||
var repos []*model.Repo
|
var repos []*model.Repo
|
||||||
for _, r := range _repos {
|
for _, r := range _repos {
|
||||||
if r.Perm.Push {
|
if r.Perm.Push {
|
||||||
if active[r.ForgeRemoteID] != nil && active[r.ForgeRemoteID].IsActive {
|
if active[r.ForgeRemoteID] != nil {
|
||||||
existingRepo := active[r.ForgeRemoteID]
|
existingRepo := active[r.ForgeRemoteID]
|
||||||
existingRepo.Update(r)
|
existingRepo.Update(r)
|
||||||
existingRepo.IsActive = true
|
existingRepo.IsActive = active[r.ForgeRemoteID].IsActive
|
||||||
repos = append(repos, existingRepo)
|
repos = append(repos, existingRepo)
|
||||||
} else {
|
} else {
|
||||||
repos = append(repos, r)
|
repos = append(repos, r)
|
||||||
|
@ -126,6 +127,12 @@ func GetRepos(c *gin.Context) {
|
||||||
return
|
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)
|
c.JSON(http.StatusOK, activeRepos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
"reload": "Reload repositories",
|
"reload": "Reload repositories",
|
||||||
"enable": "Enable",
|
"enable": "Enable",
|
||||||
"enabled": "Already enabled",
|
"enabled": "Already enabled",
|
||||||
|
"disabled": "Disabled",
|
||||||
"success": "Repository enabled",
|
"success": "Repository enabled",
|
||||||
"list_reloaded": "Repository list reloaded"
|
"list_reloaded": "Repository list reloaded"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,13 +13,14 @@
|
||||||
>
|
>
|
||||||
<span class="text-wp-text-100">{{ repo.full_name }}</span>
|
<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>
|
<span v-if="repo.active" class="ml-auto text-wp-text-alt-100">{{ $t('repo.enable.enabled') }}</span>
|
||||||
|
<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
|
<Button
|
||||||
v-if="!repo.active"
|
|
||||||
class="ml-auto"
|
|
||||||
:text="$t('repo.enable.enable')"
|
:text="$t('repo.enable.enable')"
|
||||||
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
|
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
|
||||||
@click="activateRepo(repo)"
|
@click="activateRepo(repo)"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</div>
|
</div>
|
||||||
</Scaffold>
|
</Scaffold>
|
||||||
|
@ -30,6 +31,7 @@ import { onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import Badge from '~/components/atomic/Badge.vue';
|
||||||
import Button from '~/components/atomic/Button.vue';
|
import Button from '~/components/atomic/Button.vue';
|
||||||
import ListItem from '~/components/atomic/ListItem.vue';
|
import ListItem from '~/components/atomic/ListItem.vue';
|
||||||
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
|
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
|
||||||
|
|
Loading…
Reference in a new issue