mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
fix: type checker happy (#3306)
This commit is contained in:
parent
30a753b93f
commit
3837cceafe
@ -7,18 +7,18 @@ import { nameType } from '../routes/util';
|
||||
import { projectSchema } from './project-schema';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
import {
|
||||
FEATURE_ENVIRONMENT_ENABLED,
|
||||
PROJECT_CREATED,
|
||||
PROJECT_DELETED,
|
||||
PROJECT_UPDATED,
|
||||
ProjectUserAddedEvent,
|
||||
ProjectUserRemovedEvent,
|
||||
ProjectUserUpdateRoleEvent,
|
||||
ProjectGroupAddedEvent,
|
||||
ProjectGroupRemovedEvent,
|
||||
ProjectGroupUpdateRoleEvent,
|
||||
FEATURE_ENVIRONMENT_ENABLED,
|
||||
ProjectUserAddedEvent,
|
||||
ProjectUserRemovedEvent,
|
||||
ProjectUserUpdateRoleEvent,
|
||||
} from '../types/events';
|
||||
import { IUnleashStores, IUnleashConfig, IAccountStore } from '../types';
|
||||
import { IAccountStore, IUnleashConfig, IUnleashStores } from '../types';
|
||||
import {
|
||||
FeatureToggle,
|
||||
IProject,
|
||||
@ -51,7 +51,7 @@ import { FavoritesService } from './favorites-service';
|
||||
import { TimeToProduction } from '../read-models/time-to-production/time-to-production';
|
||||
import { IProjectStatsStore } from 'lib/types/stores/project-stats-store-type';
|
||||
|
||||
const getCreatedBy = (user: IUser) => user.email || user.username;
|
||||
const getCreatedBy = (user: IUser) => user.email || user.username || 'unknown';
|
||||
|
||||
export interface AccessWithRoles {
|
||||
users: IUserWithRole[];
|
||||
@ -412,6 +412,7 @@ export default class ProjectService {
|
||||
const role = await this.accessService.getRole(roleId);
|
||||
const group = await this.groupService.getGroup(groupId);
|
||||
const project = await this.getProject(projectId);
|
||||
if (group.id == null) throw new TypeError('Unexpected empty group id');
|
||||
|
||||
await this.accessService.addGroupToRole(
|
||||
group.id,
|
||||
@ -442,6 +443,7 @@ export default class ProjectService {
|
||||
const group = await this.groupService.getGroup(groupId);
|
||||
const role = await this.accessService.getRole(roleId);
|
||||
const project = await this.getProject(projectId);
|
||||
if (group.id == null) throw new TypeError('Unexpected empty group id');
|
||||
|
||||
await this.accessService.removeGroupFromRole(
|
||||
group.id,
|
||||
@ -530,9 +532,12 @@ export default class ProjectService {
|
||||
): Promise<void> {
|
||||
const usersWithRoles = await this.getAccessToProject(projectId);
|
||||
const user = usersWithRoles.users.find((u) => u.id === userId);
|
||||
if (!user) throw new TypeError('Unexpected empty user');
|
||||
|
||||
const currentRole = usersWithRoles.roles.find(
|
||||
(r) => r.id === user.roleId,
|
||||
);
|
||||
if (!currentRole) throw new TypeError('Unexpected empty current role');
|
||||
|
||||
if (currentRole.id === roleId) {
|
||||
// Nothing to do....
|
||||
@ -576,9 +581,11 @@ export default class ProjectService {
|
||||
): Promise<void> {
|
||||
const usersWithRoles = await this.getAccessToProject(projectId);
|
||||
const user = usersWithRoles.groups.find((u) => u.id === userId);
|
||||
if (!user) throw new TypeError('Unexpected empty user');
|
||||
const currentRole = usersWithRoles.roles.find(
|
||||
(r) => r.id === user.roleId,
|
||||
);
|
||||
if (!currentRole) throw new TypeError('Unexpected empty current role');
|
||||
|
||||
if (currentRole.id === roleId) {
|
||||
// Nothing to do....
|
||||
@ -805,10 +812,12 @@ export default class ProjectService {
|
||||
userId,
|
||||
}),
|
||||
this.store.getMembersCountByProject(projectId),
|
||||
this.favoritesService.isFavoriteProject({
|
||||
project: projectId,
|
||||
userId,
|
||||
}),
|
||||
userId
|
||||
? this.favoritesService.isFavoriteProject({
|
||||
project: projectId,
|
||||
userId,
|
||||
})
|
||||
: Promise.resolve(false),
|
||||
this.projectStatsStore.getProjectStats(projectId),
|
||||
]);
|
||||
|
||||
@ -816,7 +825,7 @@ export default class ProjectService {
|
||||
stats: projectStats,
|
||||
name: project.name,
|
||||
description: project.description,
|
||||
health: project.health,
|
||||
health: project.health || 0,
|
||||
favorite: favorite,
|
||||
updatedAt: project.updatedAt,
|
||||
environments,
|
||||
|
@ -44,7 +44,6 @@ process.nextTick(async () => {
|
||||
projectStatusApi: true,
|
||||
showProjectApiAccess: true,
|
||||
projectScopedSegments: true,
|
||||
bulkOperations: true,
|
||||
projectScopedStickiness: true,
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user