mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(teams): migrate teams to react [EE-2273] (#6691)
closes [EE-2273]
This commit is contained in:
parent
9b02f575ef
commit
f9427c8fb2
97 changed files with 1929 additions and 938 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
httperror "github.com/portainer/libhttp/error"
|
||||
"github.com/portainer/libhttp/request"
|
||||
"github.com/portainer/libhttp/response"
|
||||
"github.com/portainer/portainer/api/http/security"
|
||||
)
|
||||
|
@ -13,6 +14,7 @@ import (
|
|||
// @description List teams. For non-administrator users, will only list the teams they are member of.
|
||||
// @description **Access policy**: restricted
|
||||
// @tags teams
|
||||
// @param onlyLedTeams query boolean false "Only list teams that the user is leader of"
|
||||
// @security ApiKeyAuth
|
||||
// @security jwt
|
||||
// @produce json
|
||||
|
@ -22,15 +24,23 @@ import (
|
|||
func (handler *Handler) teamList(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
||||
teams, err := handler.DataStore.Team().Teams()
|
||||
if err != nil {
|
||||
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve teams from the database", err}
|
||||
return httperror.InternalServerError("Unable to retrieve teams from the database", err)
|
||||
}
|
||||
|
||||
securityContext, err := security.RetrieveRestrictedRequestContext(r)
|
||||
if err != nil {
|
||||
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve info from request context", err}
|
||||
return httperror.InternalServerError("Unable to retrieve info from request context", err)
|
||||
}
|
||||
|
||||
filteredTeams := security.FilterUserTeams(teams, securityContext)
|
||||
onlyLedTeams, _ := request.RetrieveBooleanQueryParameter(r, "onlyLedTeams", true)
|
||||
|
||||
filteredTeams := teams
|
||||
|
||||
if onlyLedTeams {
|
||||
filteredTeams = security.FilterLeaderTeams(filteredTeams, securityContext)
|
||||
}
|
||||
|
||||
filteredTeams = security.FilterUserTeams(filteredTeams, securityContext)
|
||||
|
||||
return response.JSON(w, filteredTeams)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue