1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-02 01:17:58 +02:00

chore!: remove deprecated put project groups roles endpoint (#10059)

https://linear.app/unleash/issue/2-3361/remove-put-apiadminprojectsprojectidgroupsgroupidrolesroleid

Removes PUT
`/api/admin/projects/{projectId}/groups/{groupId}/roles/{roleId}` which
was deprecated in v5.5.
Also cleans up related code.
This commit is contained in:
Nuno Góis 2025-05-29 14:03:59 +01:00 committed by GitHub
parent 016d82a797
commit eef32b7cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 0 additions and 142 deletions

View File

@ -571,23 +571,6 @@ export class AccessStore implements IAccessStore {
.update('role_id', roleId); .update('role_id', roleId);
} }
updateGroupProjectRole(
groupId: number,
roleId: number,
projectId: string,
): Promise<void> {
return this.db(T.GROUP_ROLE)
.where({
group_id: groupId,
project: projectId,
})
.whereNotIn(
'role_id',
this.db(T.ROLES).select('id as role_id').where('type', 'root'),
)
.update('role_id', roleId);
}
async addAccessToProject( async addAccessToProject(
roles: number[], roles: number[],
groups: number[], groups: number[],

View File

@ -79,7 +79,6 @@ export const PROJECT_USER_ADDED = 'project-user-added' as const;
export const PROJECT_USER_REMOVED = 'project-user-removed' as const; export const PROJECT_USER_REMOVED = 'project-user-removed' as const;
export const PROJECT_USER_ROLE_CHANGED = 'project-user-role-changed' as const; export const PROJECT_USER_ROLE_CHANGED = 'project-user-role-changed' as const;
export const PROJECT_GROUP_ADDED = 'project-group-added' as const; export const PROJECT_GROUP_ADDED = 'project-group-added' as const;
export const PROJECT_GROUP_ROLE_CHANGED = 'project-group-role-changed' as const;
export const DROP_PROJECTS = 'drop-projects' as const; export const DROP_PROJECTS = 'drop-projects' as const;
export const TAG_CREATED = 'tag-created' as const; export const TAG_CREATED = 'tag-created' as const;
export const TAG_DELETED = 'tag-deleted' as const; export const TAG_DELETED = 'tag-deleted' as const;
@ -270,7 +269,6 @@ export const IEventTypes = [
PROJECT_USER_ADDED, PROJECT_USER_ADDED,
PROJECT_USER_REMOVED, PROJECT_USER_REMOVED,
PROJECT_USER_ROLE_CHANGED, PROJECT_USER_ROLE_CHANGED,
PROJECT_GROUP_ROLE_CHANGED,
PROJECT_GROUP_ADDED, PROJECT_GROUP_ADDED,
ROLE_CREATED, ROLE_CREATED,
ROLE_UPDATED, ROLE_UPDATED,

View File

@ -45,7 +45,6 @@ import {
ProjectCreatedEvent, ProjectCreatedEvent,
ProjectDeletedEvent, ProjectDeletedEvent,
ProjectGroupAddedEvent, ProjectGroupAddedEvent,
ProjectGroupUpdateRoleEvent,
ProjectRevivedEvent, ProjectRevivedEvent,
ProjectUpdatedEvent, ProjectUpdatedEvent,
ProjectUserRemovedEvent, ProjectUserRemovedEvent,
@ -63,7 +62,6 @@ import type { FeatureToggleService } from '../feature-toggle/feature-toggle-serv
import IncompatibleProjectError from '../../error/incompatible-project-error.js'; import IncompatibleProjectError from '../../error/incompatible-project-error.js';
import { arraysHaveSameItems } from '../../util/index.js'; import { arraysHaveSameItems } from '../../util/index.js';
import type { GroupService } from '../../services/group-service.js'; import type { GroupService } from '../../services/group-service.js';
import type { IGroupRole } from '../../types/group.js';
import type { FavoritesService } from '../../services/favorites-service.js'; import type { FavoritesService } from '../../services/favorites-service.js';
import { calculateAverageTimeToProd } from '../feature-toggle/time-to-production/time-to-production.js'; import { calculateAverageTimeToProd } from '../feature-toggle/time-to-production/time-to-production.js';
import type { IProjectStatsStore } from '../../types/stores/project-stats-store-type.js'; import type { IProjectStatsStore } from '../../types/stores/project-stats-store-type.js';
@ -111,17 +109,6 @@ interface ICalculateStatus {
updates: IProjectStats; updates: IProjectStats;
} }
function includes(
list: number[],
{
id,
}: {
id: number;
},
): boolean {
return list.some((l) => l === id);
}
export default class ProjectService { export default class ProjectService {
private projectStore: IProjectStore; private projectStore: IProjectStore;
@ -993,20 +980,6 @@ export default class ProjectService {
} }
} }
async findProjectGroupRole(
projectId: string,
roleId: number,
): Promise<IGroupRole> {
const roles = await this.groupService.getRolesForProject(projectId);
const role = roles.find((r) => r.roleId === roleId);
if (!role) {
throw new NotFoundError(
`Couldn't find roleId=${roleId} on project=${projectId}`,
);
}
return role;
}
async findProjectRole( async findProjectRole(
projectId: string, projectId: string,
roleId: number, roleId: number,
@ -1122,56 +1095,6 @@ export default class ProjectService {
); );
} }
async changeGroupRole(
projectId: string,
roleId: number,
userId: number,
auditUser: IAuditUser,
): Promise<void> {
const usersWithRoles = await this.getAccessToProject(projectId);
const userGroup = usersWithRoles.groups.find((u) => u.id === userId);
if (!userGroup)
throw new ValidationError('Unexpected empty user', [], undefined);
const currentRole = usersWithRoles.roles.find((r) =>
userGroup.roles?.includes(r.id),
);
if (!currentRole)
throw new ValidationError(
'Unexpected empty current role',
[],
undefined,
);
if (currentRole.id === roleId) {
// Nothing to do....
return;
}
await this.accessService.updateGroupProjectRole(
userId,
roleId,
projectId,
);
const role = await this.findProjectGroupRole(projectId, roleId);
await this.eventService.storeEvent(
new ProjectGroupUpdateRoleEvent({
project: projectId,
auditUser,
preData: {
userId,
roleId: currentRole.id,
roleName: currentRole.name,
},
data: {
userId,
roleId,
roleName: role.name,
},
}),
);
}
async getMembers(projectId: string): Promise<number> { async getMembers(projectId: string): Promise<number> {
return this.projectStore.getMembersCountByProject(projectId); return this.projectStore.getMembersCountByProject(projectId);
} }

View File

@ -463,14 +463,6 @@ export class AccessService {
return this.store.updateUserProjectRole(userId, roleId, projectId); return this.store.updateUserProjectRole(userId, roleId, projectId);
} }
async updateGroupProjectRole(
userId: number,
roleId: number,
projectId: string,
): Promise<void> {
return this.store.updateGroupProjectRole(userId, roleId, projectId);
}
//This actually only exists for testing purposes //This actually only exists for testing purposes
async addPermissionToRole( async addPermissionToRole(
roleId: number, roleId: number,

View File

@ -77,7 +77,6 @@ import {
PROJECT_ENVIRONMENT_REMOVED, PROJECT_ENVIRONMENT_REMOVED,
PROJECT_FAVORITED, PROJECT_FAVORITED,
PROJECT_GROUP_ADDED, PROJECT_GROUP_ADDED,
PROJECT_GROUP_ROLE_CHANGED,
PROJECT_IMPORT, PROJECT_IMPORT,
PROJECT_REVIVED, PROJECT_REVIVED,
PROJECT_UNFAVORITED, PROJECT_UNFAVORITED,
@ -1037,29 +1036,6 @@ export class ProjectGroupAddedEvent extends BaseEvent {
} }
} }
export class ProjectGroupUpdateRoleEvent extends BaseEvent {
readonly project: string;
readonly data: any;
readonly preData: any;
/**
*/
constructor(eventData: {
project: string;
data: any;
preData: any;
auditUser: IAuditUser;
}) {
super(PROJECT_GROUP_ROLE_CHANGED, eventData.auditUser);
const { project, data, preData } = eventData;
this.project = project;
this.data = data;
this.preData = preData;
}
}
export class ProjectAccessAddedEvent extends BaseEvent { export class ProjectAccessAddedEvent extends BaseEvent {
readonly project: string; readonly project: string;

View File

@ -137,12 +137,6 @@ export interface IAccessStore extends Store<IRole, number> {
projectId: string, projectId: string,
): Promise<void>; ): Promise<void>;
updateGroupProjectRole(
userId: number,
roleId: number,
projectId: string,
): Promise<void>;
removeRolesOfTypeForUser( removeRolesOfTypeForUser(
userId: number, userId: number,
roleTypes: string[], roleTypes: string[],

View File

@ -52,14 +52,6 @@ export class FakeAccessStore implements IAccessStore {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
updateGroupProjectRole(
userId: number,
roleId: number,
projectId: string,
): Promise<void> {
throw new Error('Method not implemented.');
}
addGroupToRole( addGroupToRole(
groupId: number, groupId: number,
roleId: number, roleId: number,