Skip to content

Commit d3b4d7c

Browse files
committed
remove the reduced groups endpoint, revert frontend to use the groups by org endpoint
1 parent 16e95d0 commit d3b4d7c

File tree

15 files changed

+17
-344
lines changed

15 files changed

+17
-344
lines changed

coderd/apidoc/docs.go

Lines changed: 0 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 0 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/db2sdk/db2sdk.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,6 @@ func Group(group database.Group, members []database.GroupMember, totalMemberCoun
222222
}
223223
}
224224

225-
func ReducedGroup(group database.Group, totalMemberCount int) codersdk.ReducedGroup {
226-
return codersdk.ReducedGroup{
227-
ID: group.ID,
228-
Name: group.Name,
229-
DisplayName: group.DisplayName,
230-
OrganizationID: group.OrganizationID,
231-
AvatarURL: group.AvatarURL,
232-
TotalMemberCount: totalMemberCount,
233-
}
234-
}
235-
236225
func TemplateInsightsParameters(parameterRows []database.GetTemplateParameterInsightsRow) ([]codersdk.TemplateParameterUsage, error) {
237226
// Use a stable sort, similarly to how we would sort in the query, note that
238227
// we don't sort in the query because order varies depending on the table

codersdk/groups.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ type Group struct {
3939
Source GroupSource `json:"source"`
4040
}
4141

42-
type ReducedGroup struct {
43-
ID uuid.UUID `json:"id" format:"uuid"`
44-
Name string `json:"name"`
45-
DisplayName string `json:"display_name"`
46-
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
47-
// How many users are in this group. Shows the total count,
48-
// even if the user is not authorized to read group member details.
49-
// May be greater than `len(Group.Members)`.
50-
TotalMemberCount int `json:"total_member_count"`
51-
AvatarURL string `json:"avatar_url"`
52-
}
53-
5442
func (g Group) IsEveryone() bool {
5543
return g.ID == g.OrganizationID
5644
}

docs/api/enterprise.md

Lines changed: 0 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/coderd.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,6 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
288288
r.Get("/", api.groupByOrganization)
289289
})
290290
})
291-
r.Route("/organizations/{organization}/users/{user}/reduced-groups", func(r chi.Router) {
292-
r.Use(
293-
apiKeyMiddleware,
294-
api.templateRBACEnabledMW,
295-
httpmw.ExtractOrganizationParam(api.Database),
296-
httpmw.ExtractUserParam(options.Database),
297-
)
298-
r.Get("/", api.reducedGroupsByUserAndOrganization)
299-
})
300291
r.Route("/organizations/{organization}/provisionerkeys", func(r chi.Router) {
301292
r.Use(
302293
apiKeyMiddleware,

enterprise/coderd/groups.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -437,41 +437,3 @@ func (api *API) groups(rw http.ResponseWriter, r *http.Request) {
437437

438438
httpapi.Write(ctx, rw, http.StatusOK, resp)
439439
}
440-
441-
// @Summary Get reduced groups for a user in an organization
442-
// @ID get-reduced-groups-by-user-and-organization
443-
// @Security CoderSessionToken
444-
// @Produce json
445-
// @Tags Enterprise
446-
// @Param organization path string true "Organization ID"
447-
// @Param user path string true "User ID, name, or me"
448-
// @Success 200 {array} codersdk.ReducedGroup
449-
// @Router /organizations/{organization}/users/{user}/reduced-groups [get]
450-
func (api *API) reducedGroupsByUserAndOrganization(rw http.ResponseWriter, r *http.Request) {
451-
var (
452-
ctx = r.Context()
453-
user = httpmw.UserParam(r)
454-
org = httpmw.OrganizationParam(r)
455-
)
456-
457-
groups, err := api.Database.GetGroupsByOrganizationAndUserID(ctx, database.GetGroupsByOrganizationAndUserIDParams{
458-
OrganizationID: org.ID,
459-
UserID: user.ID,
460-
})
461-
if err != nil && !errors.Is(err, sql.ErrNoRows) {
462-
httpapi.InternalServerError(rw, err)
463-
return
464-
}
465-
resp := make([]codersdk.ReducedGroup, 0, len(groups))
466-
for _, group := range groups {
467-
memberCount, err := api.Database.GetGroupMembersCountByGroupID(ctx, group.ID)
468-
if err != nil {
469-
httpapi.InternalServerError(rw, err)
470-
return
471-
}
472-
473-
resp = append(resp, db2sdk.ReducedGroup(group, int(memberCount.MemberCount)))
474-
}
475-
476-
httpapi.Write(ctx, rw, http.StatusOK, resp)
477-
}

site/src/api/api.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,21 +1619,6 @@ class ApiMethods {
16191619
return response.data;
16201620
};
16211621

1622-
/**
1623-
* @param organization Can be the organization's ID or name
1624-
* @param user Can be the user's ID, username, or "me"
1625-
*/
1626-
getReducedGroupsForUser = async (
1627-
organization: string,
1628-
user: string,
1629-
): Promise<TypesGen.ReducedGroup[]> => {
1630-
const response = await this.axios.get(
1631-
`/api/v2/organizations/${organization}/users/${user}/reduced-groups`,
1632-
);
1633-
1634-
return response.data;
1635-
};
1636-
16371622
addMember = async (groupId: string, userId: string) => {
16381623
return this.patchGroup(groupId, {
16391624
name: "",

site/src/api/queries/groups.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
CreateGroupRequest,
55
Group,
66
PatchGroupRequest,
7-
ReducedGroup,
87
} from "api/typesGenerated";
98

109
type GroupSortOrder = "asc" | "desc";
@@ -126,13 +125,6 @@ export const deleteGroup = (queryClient: QueryClient) => {
126125
};
127126
};
128127

129-
export function reducedGroupsForUser(organization: string, userId: string) {
130-
return {
131-
queryKey: ["organization", organization, "user", userId, "reduced-groups"],
132-
queryFn: () => API.getReducedGroupsForUser(organization, userId),
133-
} as const satisfies UseQueryOptions<ReducedGroup[], unknown, readonly ReducedGroup[]>;
134-
}
135-
136128
export const addMember = (queryClient: QueryClient) => {
137129
return {
138130
mutationFn: ({ groupId, userId }: { groupId: string; userId: string }) =>

0 commit comments

Comments
 (0)