mirror of
https://github.com/harness/drone.git
synced 2025-05-12 06:59:54 +08:00
feat: [CDE-481]: for the plugin, only show self gitspaces (#2997)
* feat: [CDE-481]: for the plugin, only show self gitspaces * feat: [CDE-481]: for the plugin, only show self gitspaces
This commit is contained in:
parent
a63e2ca2a0
commit
d9d00e9e06
@ -31,15 +31,8 @@ const spaceIsDeleted = "Failed to find space: resource not found"
|
|||||||
func (c *Controller) ListAllGitspaces( // nolint:gocognit
|
func (c *Controller) ListAllGitspaces( // nolint:gocognit
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
session *auth.Session,
|
session *auth.Session,
|
||||||
|
filter *types.GitspaceFilter,
|
||||||
) ([]*types.GitspaceConfig, error) {
|
) ([]*types.GitspaceConfig, error) {
|
||||||
deleted := false
|
|
||||||
markedForDeletion := false
|
|
||||||
filter := &types.GitspaceFilter{
|
|
||||||
GitspaceInstanceFilter: types.GitspaceInstanceFilter{UserIdentifier: session.Principal.UID},
|
|
||||||
Deleted: &deleted,
|
|
||||||
MarkedForDeletion: &markedForDeletion,
|
|
||||||
}
|
|
||||||
|
|
||||||
var result []*types.GitspaceConfig
|
var result []*types.GitspaceConfig
|
||||||
err := c.tx.WithTx(ctx, func(ctx context.Context) (err error) {
|
err := c.tx.WithTx(ctx, func(ctx context.Context) (err error) {
|
||||||
allGitspaceConfigs, err := c.gitspaceConfigStore.ListWithLatestInstance(ctx, filter)
|
allGitspaceConfigs, err := c.gitspaceConfigStore.ListWithLatestInstance(ctx, filter)
|
||||||
|
@ -20,13 +20,23 @@ import (
|
|||||||
"github.com/harness/gitness/app/api/controller/gitspace"
|
"github.com/harness/gitness/app/api/controller/gitspace"
|
||||||
"github.com/harness/gitness/app/api/render"
|
"github.com/harness/gitness/app/api/render"
|
||||||
"github.com/harness/gitness/app/api/request"
|
"github.com/harness/gitness/app/api/request"
|
||||||
|
"github.com/harness/gitness/types"
|
||||||
|
"github.com/harness/gitness/types/enum"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HandleListAllGitspaces(gitspaceCtrl *gitspace.Controller) http.HandlerFunc {
|
func HandleListAllGitspaces(gitspaceCtrl *gitspace.Controller) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
session, _ := request.AuthSessionFrom(ctx)
|
session, _ := request.AuthSessionFrom(ctx)
|
||||||
gitspaces, err := gitspaceCtrl.ListAllGitspaces(ctx, session)
|
deleted := false
|
||||||
|
markedForDeletion := false
|
||||||
|
filter := &types.GitspaceFilter{
|
||||||
|
GitspaceInstanceFilter: types.GitspaceInstanceFilter{UserIdentifier: session.Principal.UID},
|
||||||
|
Deleted: &deleted,
|
||||||
|
MarkedForDeletion: &markedForDeletion,
|
||||||
|
}
|
||||||
|
filter.Owner = enum.GitspaceOwnerSelf
|
||||||
|
gitspaces, err := gitspaceCtrl.ListAllGitspaces(ctx, session, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
render.TranslatedUserError(ctx, w, err)
|
render.TranslatedUserError(ctx, w, err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user