chore: project cleanup and bugfixes
This commit is contained in:
@ -158,6 +158,38 @@ func (q *Queries) GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) (
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getOwnedTeamProjectsForUserID = `-- name: GetOwnedTeamProjectsForUserID :many
|
||||
SELECT project_id FROM project WHERE owner = $1 AND team_id = $2
|
||||
`
|
||||
|
||||
type GetOwnedTeamProjectsForUserIDParams struct {
|
||||
Owner uuid.UUID `json:"owner"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetOwnedTeamProjectsForUserID(ctx context.Context, arg GetOwnedTeamProjectsForUserIDParams) ([]uuid.UUID, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getOwnedTeamProjectsForUserID, arg.Owner, arg.TeamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []uuid.UUID
|
||||
for rows.Next() {
|
||||
var project_id uuid.UUID
|
||||
if err := rows.Scan(&project_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, project_id)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectByID = `-- name: GetProjectByID :one
|
||||
SELECT project_id, team_id, created_at, name, owner FROM project WHERE project_id = $1
|
||||
`
|
||||
|
@ -51,6 +51,7 @@ type Querier interface {
|
||||
GetAssignedMembersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskAssigned, error)
|
||||
GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error)
|
||||
GetLabelColors(ctx context.Context) ([]LabelColor, error)
|
||||
GetOwnedTeamProjectsForUserID(ctx context.Context, arg GetOwnedTeamProjectsForUserIDParams) ([]uuid.UUID, error)
|
||||
GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error)
|
||||
GetProjectIDForTask(ctx context.Context, taskID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error)
|
||||
@ -87,8 +88,10 @@ type Querier interface {
|
||||
UpdateProjectLabelName(ctx context.Context, arg UpdateProjectLabelNameParams) (ProjectLabel, error)
|
||||
UpdateProjectMemberRole(ctx context.Context, arg UpdateProjectMemberRoleParams) (ProjectMember, error)
|
||||
UpdateProjectNameByID(ctx context.Context, arg UpdateProjectNameByIDParams) (Project, error)
|
||||
UpdateTaskChecklistItemLocation(ctx context.Context, arg UpdateTaskChecklistItemLocationParams) (TaskChecklistItem, error)
|
||||
UpdateTaskChecklistItemName(ctx context.Context, arg UpdateTaskChecklistItemNameParams) (TaskChecklistItem, error)
|
||||
UpdateTaskChecklistName(ctx context.Context, arg UpdateTaskChecklistNameParams) (TaskChecklist, error)
|
||||
UpdateTaskChecklistPosition(ctx context.Context, arg UpdateTaskChecklistPositionParams) (TaskChecklist, error)
|
||||
UpdateTaskDescription(ctx context.Context, arg UpdateTaskDescriptionParams) (Task, error)
|
||||
UpdateTaskDueDate(ctx context.Context, arg UpdateTaskDueDateParams) (Task, error)
|
||||
UpdateTaskGroupLocation(ctx context.Context, arg UpdateTaskGroupLocationParams) (TaskGroup, error)
|
||||
@ -96,6 +99,7 @@ type Querier interface {
|
||||
UpdateTaskName(ctx context.Context, arg UpdateTaskNameParams) (Task, error)
|
||||
UpdateTeamMemberRole(ctx context.Context, arg UpdateTeamMemberRoleParams) (TeamMember, error)
|
||||
UpdateUserAccountProfileAvatarURL(ctx context.Context, arg UpdateUserAccountProfileAvatarURLParams) (UserAccount, error)
|
||||
UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (UserAccount, error)
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
|
@ -37,5 +37,5 @@ DELETE FROM project_member WHERE user_id = $1 AND project_id = $2;
|
||||
UPDATE project_member SET role_code = $3 WHERE project_id = $1 AND user_id = $2
|
||||
RETURNING *;
|
||||
|
||||
|
||||
|
||||
-- name: GetOwnedTeamProjectsForUserID :many
|
||||
SELECT project_id FROM project WHERE owner = $1 AND team_id = $2;
|
||||
|
@ -35,3 +35,9 @@ SELECT * FROM task_checklist_item WHERE task_checklist_item_id = $1;
|
||||
-- name: UpdateTaskChecklistItemName :one
|
||||
UPDATE task_checklist_item SET name = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateTaskChecklistPosition :one
|
||||
UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING *;
|
||||
|
||||
-- name: UpdateTaskChecklistItemLocation :one
|
||||
UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING *;
|
||||
|
@ -22,3 +22,6 @@ DELETE FROM user_account WHERE user_id = $1;
|
||||
SELECT username, role.code, role.name FROM user_account
|
||||
INNER JOIN role ON role.code = user_account.role_code
|
||||
WHERE user_id = $1;
|
||||
|
||||
-- name: UpdateUserRole :one
|
||||
UPDATE user_account SET role_code = $2 WHERE user_id = $1 RETURNING *;
|
||||
|
@ -219,6 +219,31 @@ func (q *Queries) SetTaskChecklistItemComplete(ctx context.Context, arg SetTaskC
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistItemLocation = `-- name: UpdateTaskChecklistItemLocation :one
|
||||
UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistItemLocationParams struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"task_checklist_item_id"`
|
||||
Position float64 `json:"position"`
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistItemLocation(ctx context.Context, arg UpdateTaskChecklistItemLocationParams) (TaskChecklistItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistItemLocation, arg.TaskChecklistItemID, arg.Position, arg.TaskChecklistID)
|
||||
var i TaskChecklistItem
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistItemID,
|
||||
&i.TaskChecklistID,
|
||||
&i.CreatedAt,
|
||||
&i.Complete,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
&i.DueDate,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistItemName = `-- name: UpdateTaskChecklistItemName :one
|
||||
UPDATE task_checklist_item SET name = $2 WHERE task_checklist_item_id = $1
|
||||
RETURNING task_checklist_item_id, task_checklist_id, created_at, complete, name, position, due_date
|
||||
@ -266,3 +291,25 @@ func (q *Queries) UpdateTaskChecklistName(ctx context.Context, arg UpdateTaskChe
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateTaskChecklistPosition = `-- name: UpdateTaskChecklistPosition :one
|
||||
UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING task_checklist_id, task_id, created_at, name, position
|
||||
`
|
||||
|
||||
type UpdateTaskChecklistPositionParams struct {
|
||||
TaskChecklistID uuid.UUID `json:"task_checklist_id"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTaskChecklistPosition(ctx context.Context, arg UpdateTaskChecklistPositionParams) (TaskChecklist, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateTaskChecklistPosition, arg.TaskChecklistID, arg.Position)
|
||||
var i TaskChecklist
|
||||
err := row.Scan(
|
||||
&i.TaskChecklistID,
|
||||
&i.TaskID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Position,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
@ -189,3 +189,30 @@ func (q *Queries) UpdateUserAccountProfileAvatarURL(ctx context.Context, arg Upd
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserRole = `-- name: UpdateUserRole :one
|
||||
UPDATE user_account SET role_code = $2 WHERE user_id = $1 RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code
|
||||
`
|
||||
|
||||
type UpdateUserRoleParams struct {
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams) (UserAccount, error) {
|
||||
row := q.db.QueryRowContext(ctx, updateUserRole, arg.UserID, arg.RoleCode)
|
||||
var i UserAccount
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -124,13 +124,15 @@ type DeleteTeam struct {
|
||||
}
|
||||
|
||||
type DeleteTeamMember struct {
|
||||
TeamID uuid.UUID `json:"teamID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
TeamID uuid.UUID `json:"teamID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
NewOwnerID *uuid.UUID `json:"newOwnerID"`
|
||||
}
|
||||
|
||||
type DeleteTeamMemberPayload struct {
|
||||
TeamID uuid.UUID `json:"teamID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
TeamID uuid.UUID `json:"teamID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
AffectedProjects []db.Project `json:"affectedProjects"`
|
||||
}
|
||||
|
||||
type DeleteTeamPayload struct {
|
||||
@ -174,6 +176,7 @@ type Member struct {
|
||||
FullName string `json:"fullName"`
|
||||
Username string `json:"username"`
|
||||
ProfileIcon *ProfileIcon `json:"profileIcon"`
|
||||
Owned *OwnersList `json:"owned"`
|
||||
}
|
||||
|
||||
type NewProject struct {
|
||||
@ -229,6 +232,11 @@ type NewUserAccount struct {
|
||||
RoleCode string `json:"roleCode"`
|
||||
}
|
||||
|
||||
type OwnersList struct {
|
||||
Projects []uuid.UUID `json:"projects"`
|
||||
Teams []uuid.UUID `json:"teams"`
|
||||
}
|
||||
|
||||
type ProfileIcon struct {
|
||||
URL *string `json:"url"`
|
||||
Initials *string `json:"initials"`
|
||||
@ -326,11 +334,32 @@ type UpdateProjectName struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocation struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
ChecklistItemID uuid.UUID `json:"checklistItemID"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocationPayload struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
PrevChecklistID uuid.UUID `json:"prevChecklistID"`
|
||||
ChecklistItem *db.TaskChecklistItem `json:"checklistItem"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemName struct {
|
||||
TaskChecklistItemID uuid.UUID `json:"taskChecklistItemID"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocation struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocationPayload struct {
|
||||
Checklist *db.TaskChecklist `json:"checklist"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistName struct {
|
||||
TaskChecklistID uuid.UUID `json:"taskChecklistID"`
|
||||
Name string `json:"name"`
|
||||
@ -372,6 +401,15 @@ type UpdateTeamMemberRolePayload struct {
|
||||
Member *Member `json:"member"`
|
||||
}
|
||||
|
||||
type UpdateUserRole struct {
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
RoleCode RoleCode `json:"roleCode"`
|
||||
}
|
||||
|
||||
type UpdateUserRolePayload struct {
|
||||
User *db.UserAccount `json:"user"`
|
||||
}
|
||||
|
||||
type RoleCode string
|
||||
|
||||
const (
|
||||
|
@ -35,12 +35,18 @@ type ProfileIcon {
|
||||
bgColor: String
|
||||
}
|
||||
|
||||
type OwnersList {
|
||||
projects: [UUID!]!
|
||||
teams: [UUID!]!
|
||||
}
|
||||
|
||||
type Member {
|
||||
id: ID!
|
||||
role: Role!
|
||||
fullName: String!
|
||||
username: String!
|
||||
profileIcon: ProfileIcon!
|
||||
owned: OwnersList
|
||||
}
|
||||
|
||||
type RefreshToken {
|
||||
@ -361,6 +367,30 @@ extend type Mutation {
|
||||
updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): TaskChecklistItem!
|
||||
setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): TaskChecklistItem!
|
||||
deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): DeleteTaskChecklistItemPayload!
|
||||
|
||||
updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!): UpdateTaskChecklistLocationPayload!
|
||||
updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!): UpdateTaskChecklistItemLocationPayload!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistItemLocation {
|
||||
checklistID: UUID!
|
||||
checklistItemID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocationPayload {
|
||||
checklistID: UUID!
|
||||
prevChecklistID: UUID!
|
||||
checklistItem: TaskChecklistItem!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistLocation {
|
||||
checklistID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocationPayload {
|
||||
checklist: TaskChecklist!
|
||||
}
|
||||
|
||||
input CreateTaskChecklist {
|
||||
@ -492,11 +522,13 @@ extend type Mutation {
|
||||
input DeleteTeamMember {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
newOwnerID: UUID
|
||||
}
|
||||
|
||||
type DeleteTeamMemberPayload {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
affectedProjects: [Project!]!
|
||||
}
|
||||
|
||||
input CreateTeamMember {
|
||||
@ -537,6 +569,17 @@ extend type Mutation {
|
||||
deleteUserAccount(input: DeleteUserAccount!): DeleteUserAccountPayload!
|
||||
logoutUser(input: LogoutUser!): Boolean!
|
||||
clearProfileAvatar: UserAccount!
|
||||
|
||||
updateUserRole(input: UpdateUserRole!): UpdateUserRolePayload!
|
||||
}
|
||||
|
||||
input UpdateUserRole {
|
||||
userID: UUID!
|
||||
roleCode: RoleCode!
|
||||
}
|
||||
|
||||
type UpdateUserRolePayload {
|
||||
user: UserAccount!
|
||||
}
|
||||
|
||||
input NewRefreshToken {
|
||||
|
@ -426,6 +426,26 @@ func (r *mutationResolver) DeleteTaskChecklistItem(ctx context.Context, input De
|
||||
}, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) {
|
||||
checklist, err := r.Repository.UpdateTaskChecklistPosition(ctx, db.UpdateTaskChecklistPositionParams{Position: input.Position, TaskChecklistID: input.ChecklistID})
|
||||
|
||||
if err != nil {
|
||||
return &UpdateTaskChecklistLocationPayload{}, err
|
||||
}
|
||||
|
||||
return &UpdateTaskChecklistLocationPayload{Checklist: &checklist}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistItemLocation(ctx context.Context, input UpdateTaskChecklistItemLocation) (*UpdateTaskChecklistItemLocationPayload, error) {
|
||||
currentChecklistItem, err := r.Repository.GetTaskChecklistItemByID(ctx, input.ChecklistItemID)
|
||||
|
||||
checklistItem, err := r.Repository.UpdateTaskChecklistItemLocation(ctx, db.UpdateTaskChecklistItemLocationParams{TaskChecklistID: input.ChecklistID, TaskChecklistItemID: input.ChecklistItemID, Position: input.Position})
|
||||
if err != nil {
|
||||
return &UpdateTaskChecklistItemLocationPayload{}, err
|
||||
}
|
||||
return &UpdateTaskChecklistItemLocationPayload{PrevChecklistID: currentChecklistItem.TaskChecklistID, ChecklistID: input.ChecklistID, ChecklistItem: &checklistItem}, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateTaskGroup(ctx context.Context, input NewTaskGroup) (*db.TaskGroup, error) {
|
||||
createdAt := time.Now().UTC()
|
||||
projectID, err := uuid.Parse(input.ProjectID)
|
||||
@ -682,7 +702,11 @@ func (r *mutationResolver) UpdateTeamMemberRole(ctx context.Context, input Updat
|
||||
}
|
||||
|
||||
func (r *mutationResolver) DeleteTeamMember(ctx context.Context, input DeleteTeamMember) (*DeleteTeamMemberPayload, error) {
|
||||
_, err := r.Repository.GetTeamMemberByID(ctx, db.GetTeamMemberByIDParams{TeamID: input.TeamID, UserID: input.UserID})
|
||||
ownedProjects, err := r.Repository.GetOwnedTeamProjectsForUserID(ctx, db.GetOwnedTeamProjectsForUserIDParams{TeamID: input.TeamID, Owner: input.UserID})
|
||||
if err != nil {
|
||||
return &DeleteTeamMemberPayload{}, err
|
||||
}
|
||||
_, err = r.Repository.GetTeamMemberByID(ctx, db.GetTeamMemberByIDParams{TeamID: input.TeamID, UserID: input.UserID})
|
||||
if err != nil {
|
||||
return &DeleteTeamMemberPayload{}, err
|
||||
}
|
||||
@ -690,6 +714,11 @@ func (r *mutationResolver) DeleteTeamMember(ctx context.Context, input DeleteTea
|
||||
if err != nil {
|
||||
return &DeleteTeamMemberPayload{}, err
|
||||
}
|
||||
if input.NewOwnerID != nil {
|
||||
for _, projectID := range ownedProjects {
|
||||
_, err = r.Repository.SetProjectOwner(ctx, db.SetProjectOwnerParams{ProjectID: projectID, Owner: *input.NewOwnerID})
|
||||
}
|
||||
}
|
||||
return &DeleteTeamMemberPayload{TeamID: input.TeamID, UserID: input.UserID}, nil
|
||||
}
|
||||
|
||||
@ -754,6 +783,15 @@ func (r *mutationResolver) ClearProfileAvatar(ctx context.Context) (*db.UserAcco
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateUserRole(ctx context.Context, input UpdateUserRole) (*UpdateUserRolePayload, error) {
|
||||
user, err := r.Repository.UpdateUserRole(ctx, db.UpdateUserRoleParams{RoleCode: input.RoleCode.String(), UserID: input.UserID})
|
||||
if err != nil {
|
||||
return &UpdateUserRolePayload{}, err
|
||||
}
|
||||
return &UpdateUserRolePayload{User: &user}, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *organizationResolver) ID(ctx context.Context, obj *db.Organization) (uuid.UUID, error) {
|
||||
return obj.OrganizationID, nil
|
||||
}
|
||||
@ -1095,6 +1133,7 @@ func (r *teamResolver) ID(ctx context.Context, obj *db.Team) (uuid.UUID, error)
|
||||
func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, error) {
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, obj.Owner)
|
||||
members := []Member{}
|
||||
log.WithFields(log.Fields{"teamID": obj.TeamID}).Info("getting members")
|
||||
if err == sql.ErrNoRows {
|
||||
return members, nil
|
||||
}
|
||||
@ -1102,6 +1141,20 @@ func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, err
|
||||
log.WithError(err).Error("get user account by ID")
|
||||
return members, err
|
||||
}
|
||||
ownedProjects, err := r.Repository.GetOwnedTeamProjectsForUserID(ctx, db.GetOwnedTeamProjectsForUserIDParams{TeamID: obj.TeamID, Owner: user.UserID})
|
||||
log.WithFields(log.Fields{"projects": ownedProjects}).Info("retrieved owned project list")
|
||||
if err == sql.ErrNoRows {
|
||||
ownedProjects = []uuid.UUID{}
|
||||
} else if err != nil {
|
||||
log.WithError(err).Error("get owned team projects for user id")
|
||||
return members, err
|
||||
}
|
||||
ownedTeams := []uuid.UUID{}
|
||||
var ownerList *OwnersList
|
||||
if len(ownedTeams) != 0 || len(ownedProjects) != 0 {
|
||||
log.Info("owned list is not empty")
|
||||
ownerList = &OwnersList{Projects: ownedProjects, Teams: ownedTeams}
|
||||
}
|
||||
var url *string
|
||||
if user.ProfileAvatarUrl.Valid {
|
||||
url = &user.ProfileAvatarUrl.String
|
||||
@ -1109,7 +1162,7 @@ func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, err
|
||||
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
|
||||
members = append(members, Member{
|
||||
ID: obj.Owner, FullName: user.FullName, ProfileIcon: profileIcon, Username: user.Username,
|
||||
Role: &db.Role{Code: "owner", Name: "Owner"},
|
||||
Owned: ownerList, Role: &db.Role{Code: "owner", Name: "Owner"},
|
||||
})
|
||||
teamMembers, err := r.Repository.GetTeamMembersForTeamID(ctx, obj.TeamID)
|
||||
if err != nil {
|
||||
@ -1132,9 +1185,24 @@ func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, err
|
||||
log.WithError(err).Error("get role for projet member by user ID")
|
||||
return members, err
|
||||
}
|
||||
ownedProjects, err := r.Repository.GetOwnedTeamProjectsForUserID(ctx, db.GetOwnedTeamProjectsForUserIDParams{TeamID: obj.TeamID, Owner: user.UserID})
|
||||
log.WithFields(log.Fields{"projects": ownedProjects}).Info("retrieved owned project list")
|
||||
if err == sql.ErrNoRows {
|
||||
ownedProjects = []uuid.UUID{}
|
||||
} else if err != nil {
|
||||
log.WithError(err).Error("get owned team projects for user id")
|
||||
return members, err
|
||||
}
|
||||
ownedTeams := []uuid.UUID{}
|
||||
var ownerList *OwnersList
|
||||
if len(ownedTeams) != 0 || len(ownedProjects) != 0 {
|
||||
log.Info("owned list is not empty")
|
||||
ownerList = &OwnersList{Projects: ownedProjects, Teams: ownedTeams}
|
||||
}
|
||||
|
||||
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
|
||||
members = append(members, Member{ID: user.UserID, FullName: user.FullName, ProfileIcon: profileIcon,
|
||||
Username: user.Username, Role: &db.Role{Code: role.Code, Name: role.Name},
|
||||
Username: user.Username, Owned: ownerList, Role: &db.Role{Code: role.Code, Name: role.Name},
|
||||
})
|
||||
}
|
||||
return members, nil
|
||||
|
@ -35,12 +35,18 @@ type ProfileIcon {
|
||||
bgColor: String
|
||||
}
|
||||
|
||||
type OwnersList {
|
||||
projects: [UUID!]!
|
||||
teams: [UUID!]!
|
||||
}
|
||||
|
||||
type Member {
|
||||
id: ID!
|
||||
role: Role!
|
||||
fullName: String!
|
||||
username: String!
|
||||
profileIcon: ProfileIcon!
|
||||
owned: OwnersList
|
||||
}
|
||||
|
||||
type RefreshToken {
|
||||
|
@ -6,6 +6,30 @@ extend type Mutation {
|
||||
updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): TaskChecklistItem!
|
||||
setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): TaskChecklistItem!
|
||||
deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): DeleteTaskChecklistItemPayload!
|
||||
|
||||
updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!): UpdateTaskChecklistLocationPayload!
|
||||
updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!): UpdateTaskChecklistItemLocationPayload!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistItemLocation {
|
||||
checklistID: UUID!
|
||||
checklistItemID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocationPayload {
|
||||
checklistID: UUID!
|
||||
prevChecklistID: UUID!
|
||||
checklistItem: TaskChecklistItem!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistLocation {
|
||||
checklistID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocationPayload {
|
||||
checklist: TaskChecklist!
|
||||
}
|
||||
|
||||
input CreateTaskChecklist {
|
||||
|
@ -8,11 +8,13 @@ extend type Mutation {
|
||||
input DeleteTeamMember {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
newOwnerID: UUID
|
||||
}
|
||||
|
||||
type DeleteTeamMemberPayload {
|
||||
teamID: UUID!
|
||||
userID: UUID!
|
||||
affectedProjects: [Project!]!
|
||||
}
|
||||
|
||||
input CreateTeamMember {
|
||||
|
@ -4,6 +4,17 @@ extend type Mutation {
|
||||
deleteUserAccount(input: DeleteUserAccount!): DeleteUserAccountPayload!
|
||||
logoutUser(input: LogoutUser!): Boolean!
|
||||
clearProfileAvatar: UserAccount!
|
||||
|
||||
updateUserRole(input: UpdateUserRole!): UpdateUserRolePayload!
|
||||
}
|
||||
|
||||
input UpdateUserRole {
|
||||
userID: UUID!
|
||||
roleCode: RoleCode!
|
||||
}
|
||||
|
||||
type UpdateUserRolePayload {
|
||||
user: UserAccount!
|
||||
}
|
||||
|
||||
input NewRefreshToken {
|
||||
|
Reference in New Issue
Block a user