1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: add environments to project created payload (#6901)

This commit adds an `environments` property to the project created
payload. The list contains only the projects that the project has
enabled.

The point of adding it is that it gives you a better overview over
what you have created.
This commit is contained in:
Thomas Heartman 2024-04-22 14:37:45 +02:00 committed by GitHub
parent b6833d92aa
commit 9ba6be6000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -49,6 +49,7 @@ import {
ProjectUserUpdateRoleEvent, ProjectUserUpdateRoleEvent,
RoleName, RoleName,
SYSTEM_USER_ID, SYSTEM_USER_ID,
type ProjectCreated,
} from '../../types'; } from '../../types';
import type { import type {
IProjectAccessModel, IProjectAccessModel,
@ -284,7 +285,7 @@ export default class ProjectService {
user: IUser, user: IUser,
auditUser: IAuditUser, auditUser: IAuditUser,
enableChangeRequestsForSpecifiedEnvironments: () => Promise<void> = async () => {}, enableChangeRequestsForSpecifiedEnvironments: () => Promise<void> = async () => {},
): Promise<IProject> { ): Promise<ProjectCreated> {
await this.validateProjectEnvironments(newProject.environments); await this.validateProjectEnvironments(newProject.environments);
const validatedData = await projectSchema.validateAsync(newProject); const validatedData = await projectSchema.validateAsync(newProject);
@ -321,7 +322,7 @@ export default class ProjectService {
}), }),
); );
return data; return { ...data, environments: envsToEnable };
} }
async updateProject( async updateProject(

View File

@ -474,6 +474,19 @@ export type CreateProject = Pick<IProject, 'id' | 'name'> & {
environments?: string[]; environments?: string[];
}; };
// Create project aligns with #/components/schemas/projectCreatedSchema
export type ProjectCreated = Pick<
IProject,
| 'id'
| 'name'
| 'mode'
| 'defaultStickiness'
| 'description'
| 'featureLimit'
> & {
environments: string[];
};
export interface IProject { export interface IProject {
id: string; id: string;
name: string; name: string;