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

fix: Updated event to include project (#2491)

### What
Our EnvironmentVariant needs project name so this PR makes sure our
service accepts the project id as one of the arguments.
This commit is contained in:
Christopher Kolstad 2022-11-22 09:57:12 +01:00 committed by GitHub
parent 3dca3d53f9
commit f937e80272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -221,9 +221,10 @@ export default class VariantsController extends Controller {
req: IAuthRequest<FeatureEnvironmentParams, any, IVariant[], any>, req: IAuthRequest<FeatureEnvironmentParams, any, IVariant[], any>,
res: Response<FeatureVariantsSchema>, res: Response<FeatureVariantsSchema>,
): Promise<void> { ): Promise<void> {
const { featureName, environment } = req.params; const { featureName, environment, projectId } = req.params;
const userName = extractUsername(req); const userName = extractUsername(req);
const variants = await this.featureService.saveVariantsOnEnv( const variants = await this.featureService.saveVariantsOnEnv(
projectId,
featureName, featureName,
environment, environment,
req.body, req.body,

View File

@ -1245,6 +1245,7 @@ class FeatureToggleService {
); );
const { newDocument } = await applyPatch(oldVariants, newVariants); const { newDocument } = await applyPatch(oldVariants, newVariants);
return this.saveVariantsOnEnv( return this.saveVariantsOnEnv(
project,
featureName, featureName,
environment, environment,
newDocument, newDocument,
@ -1283,6 +1284,7 @@ class FeatureToggleService {
} }
async saveVariantsOnEnv( async saveVariantsOnEnv(
projectId: string,
featureName: string, featureName: string,
environment: string, environment: string,
newVariants: IVariant[], newVariants: IVariant[],
@ -1301,6 +1303,7 @@ class FeatureToggleService {
new EnvironmentVariantEvent({ new EnvironmentVariantEvent({
featureName, featureName,
environment, environment,
project: projectId,
createdBy, createdBy,
oldVariants, oldVariants,
newVariants: fixedVariants, newVariants: fixedVariants,

View File

@ -195,6 +195,8 @@ export class FeatureVariantEvent extends BaseEvent {
} }
export class EnvironmentVariantEvent extends BaseEvent { export class EnvironmentVariantEvent extends BaseEvent {
readonly project: string;
readonly environment: string; readonly environment: string;
readonly featureName: string; readonly featureName: string;
@ -206,6 +208,7 @@ export class EnvironmentVariantEvent extends BaseEvent {
constructor(p: { constructor(p: {
featureName: string; featureName: string;
environment: string; environment: string;
project: string;
createdBy: string; createdBy: string;
newVariants: IVariant[]; newVariants: IVariant[];
oldVariants: IVariant[]; oldVariants: IVariant[];
@ -213,6 +216,7 @@ export class EnvironmentVariantEvent extends BaseEvent {
super(FEATURE_ENVIRONMENT_VARIANTS_UPDATED, p.createdBy); super(FEATURE_ENVIRONMENT_VARIANTS_UPDATED, p.createdBy);
this.featureName = p.featureName; this.featureName = p.featureName;
this.environment = p.environment; this.environment = p.environment;
this.project = p.project;
this.data = { variants: p.newVariants }; this.data = { variants: p.newVariants };
this.preData = { variants: p.oldVariants }; this.preData = { variants: p.oldVariants };
} }