mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
refactor: clean up dead code after removing deprecated project role access endpoint (#9949)
https://linear.app/unleash/issue/2-3363/remove-post-apiadminprojectsprojectidroleroleidaccess-deprecated-in Cleans up dead code after removing POST `/api/admin/projects/{projectId}/role/{roleId}/access` which was deprecated in v5.5. Should only be merged after the Enterprise PR.
This commit is contained in:
parent
3a37386449
commit
e7da79d974
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type AddRoleAccessToProject400 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type AddRoleAccessToProject401 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type AddRoleAccessToProject403 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type AddRoleAccessToProject404 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type AddRoleAccessToProject415 = {
|
||||
/** The ID of the error instance */
|
||||
id?: string;
|
||||
/** A description of what went wrong. */
|
||||
message?: string;
|
||||
/** The name of the error kind */
|
||||
name?: string;
|
||||
};
|
@ -52,11 +52,6 @@ export * from './addMilestoneToReleasePlanTemplate403';
|
||||
export * from './addMilestoneToReleasePlanTemplate404';
|
||||
export * from './addPublicSignupTokenUser400';
|
||||
export * from './addPublicSignupTokenUser409';
|
||||
export * from './addRoleAccessToProject400';
|
||||
export * from './addRoleAccessToProject401';
|
||||
export * from './addRoleAccessToProject403';
|
||||
export * from './addRoleAccessToProject404';
|
||||
export * from './addRoleAccessToProject415';
|
||||
export * from './addRoleToUser401';
|
||||
export * from './addRoleToUser403';
|
||||
export * from './addRoleToUser404';
|
||||
|
@ -3,7 +3,6 @@ import metricsHelper from '../util/metrics-helper';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
import type { Logger } from '../logger';
|
||||
import type {
|
||||
IAccessInfo,
|
||||
IAccessStore,
|
||||
IProjectRoleUsage,
|
||||
IRole,
|
||||
@ -603,46 +602,6 @@ export class AccessStore implements IAccessStore {
|
||||
.update('role_id', roleId);
|
||||
}
|
||||
|
||||
async addRoleAccessToProject(
|
||||
users: IAccessInfo[],
|
||||
groups: IAccessInfo[],
|
||||
projectId: string,
|
||||
roleId: number,
|
||||
createdBy: string,
|
||||
): Promise<void> {
|
||||
const userRows = users.map((user) => {
|
||||
return {
|
||||
user_id: user.id,
|
||||
project: projectId,
|
||||
role_id: roleId,
|
||||
};
|
||||
});
|
||||
|
||||
const groupRows = groups.map((group) => {
|
||||
return {
|
||||
group_id: group.id,
|
||||
project: projectId,
|
||||
role_id: roleId,
|
||||
created_by: createdBy,
|
||||
};
|
||||
});
|
||||
|
||||
await inTransaction(this.db, async (tx) => {
|
||||
if (userRows.length > 0) {
|
||||
await tx(T.ROLE_USER)
|
||||
.insert(userRows)
|
||||
.onConflict(['project', 'role_id', 'user_id'])
|
||||
.merge();
|
||||
}
|
||||
if (groupRows.length > 0) {
|
||||
await tx(T.GROUP_ROLE)
|
||||
.insert(groupRows)
|
||||
.onConflict(['project', 'role_id', 'group_id'])
|
||||
.merge();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async addAccessToProject(
|
||||
roles: number[],
|
||||
groups: number[],
|
||||
|
@ -56,7 +56,6 @@ import {
|
||||
type IOnboardingReadModel,
|
||||
} from '../../types';
|
||||
import type {
|
||||
IProjectAccessModel,
|
||||
IRoleDescriptor,
|
||||
IRoleWithProject,
|
||||
} from '../../types/stores/access-store';
|
||||
@ -843,38 +842,6 @@ export default class ProjectService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `addAccess` instead
|
||||
*/
|
||||
async addRoleAccess(
|
||||
projectId: string,
|
||||
roleId: number,
|
||||
usersAndGroups: IProjectAccessModel,
|
||||
auditUser: IAuditUser,
|
||||
): Promise<void> {
|
||||
await this.accessService.addRoleAccessToProject(
|
||||
usersAndGroups.users,
|
||||
usersAndGroups.groups,
|
||||
projectId,
|
||||
roleId,
|
||||
auditUser,
|
||||
);
|
||||
|
||||
await this.eventService.storeEvent(
|
||||
new ProjectAccessAddedEvent({
|
||||
project: projectId,
|
||||
auditUser,
|
||||
data: {
|
||||
roles: {
|
||||
roleId,
|
||||
groupIds: usersAndGroups.groups.map(({ id }) => id),
|
||||
userIds: usersAndGroups.users.map(({ id }) => id),
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
private isAdmin(userId: number, roles: IRoleWithProject[]): boolean {
|
||||
return (
|
||||
userId === SYSTEM_USER_ID ||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import * as permissions from '../types/permissions';
|
||||
import type { IAuditUser, IUser } from '../types/user';
|
||||
import type {
|
||||
IAccessInfo,
|
||||
IAccessStore,
|
||||
IGroupWithProjectRoles,
|
||||
IProjectRoleUsage,
|
||||
@ -342,22 +341,6 @@ export class AccessService {
|
||||
return this.store.addGroupToRole(groupId, roleId, createdBy, projectId);
|
||||
}
|
||||
|
||||
async addRoleAccessToProject(
|
||||
users: IAccessInfo[],
|
||||
groups: IAccessInfo[],
|
||||
projectId: string,
|
||||
roleId: number,
|
||||
auditUser: IAuditUser,
|
||||
): Promise<void> {
|
||||
return this.store.addRoleAccessToProject(
|
||||
users,
|
||||
groups,
|
||||
projectId,
|
||||
roleId,
|
||||
auditUser.username,
|
||||
);
|
||||
}
|
||||
|
||||
async addAccessToProject(
|
||||
roles: number[],
|
||||
groups: number[],
|
||||
|
@ -39,15 +39,6 @@ export interface IRoleDescriptor {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface IProjectAccessModel {
|
||||
users: IAccessInfo[];
|
||||
groups: IAccessInfo[];
|
||||
}
|
||||
|
||||
export interface IAccessInfo {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface IUserRole {
|
||||
roleId: number;
|
||||
userId: number;
|
||||
@ -115,14 +106,6 @@ export interface IAccessStore extends Store<IRole, number> {
|
||||
projectId?: string,
|
||||
): Promise<void>;
|
||||
|
||||
addRoleAccessToProject(
|
||||
users: IAccessInfo[],
|
||||
groups: IAccessInfo[],
|
||||
projectId: string,
|
||||
roleId: number,
|
||||
createdBy: string,
|
||||
): Promise<void>;
|
||||
|
||||
addAccessToProject(
|
||||
roles: number[],
|
||||
groups: number[],
|
||||
|
11
src/test/fixtures/fake-access-store.ts
vendored
11
src/test/fixtures/fake-access-store.ts
vendored
@ -1,6 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import type {
|
||||
IAccessInfo,
|
||||
IAccessStore,
|
||||
IProjectRoleUsage,
|
||||
IRole,
|
||||
@ -43,16 +42,6 @@ export class FakeAccessStore implements IAccessStore {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
addRoleAccessToProject(
|
||||
users: IAccessInfo[],
|
||||
groups: IAccessInfo[],
|
||||
projectId: string,
|
||||
roleId: number,
|
||||
createdBy: string,
|
||||
): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
addAccessToProject(
|
||||
roles: number[],
|
||||
groups: number[],
|
||||
|
Loading…
Reference in New Issue
Block a user