Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nv 1576 make default layout changes dependent #2711

Merged
merged 6 commits into from
Feb 20, 2023

Conversation

BiswaViraj
Copy link
Contributor

@BiswaViraj BiswaViraj commented Feb 9, 2023

What change does this PR introduce?

  • Makes default layout changes dependent
  • Created a new change type: DefaultLayout

Why was this change needed?

Other information (Screenshots)

image

@linear
Copy link

linear bot commented Feb 9, 2023

NV-1576 Make default layout changes dependent

When changing a layout to be default, 2 changes are created (layout se to default and prev layout to be not default)

But, they are promoted separately, so could create a situation where there are 2 default layouts in prod.

Copy link
Contributor

@ainouzgali ainouzgali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job😍 Wrote a few questions.

@@ -93,4 +109,27 @@ export class SetDefaultLayoutUseCase {
): Promise<void> {
await this.layoutRepository.updateIsDefault(layoutId, environmentId, organizationId, isDefault);
}

private async createDefaultChange(command: CreateDefaultLayoutChangeCommand) {
const createLayoutChangeCommand = CreateDefaultLayoutChangeCommand.create({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be creating this command twice :) here and in line 55

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 Removing them

Comment on lines 27 to 31

if (!existingDefaultLayoutId) {
await this.createDefaultChange(
CreateDefaultLayoutChangeCommand.create({
environmentId: command.environmentId,
layoutId: command.layoutId,
organizationId: command.organizationId,
userId: command.userId,
})
);

return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand here !existingDefaultLayoutId will be true when the set default is called for the already default layout. So no change should be created here. Wdyt? Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the very first layout, the existingDefaultId will be false,
This will handle that scenario

@@ -39,10 +39,10 @@ export class CreateLayoutUseCase {
userId: dto._creatorId,
});
await this.setDefaultLayout.execute(setDefaultLayoutCommand);
} else {
await this.createChange(command, dto._id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what would happen if there is an update/create of layout(name,content) + setting to default. Would it create 2 changes? One for default layout change and one for layout change? If so, are we sure they are also dependent on promote?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, It will create a single(1) change under DefaultLayout,
This way it maintains the dependency between other layout changes too.

@ainouzgali
Copy link
Contributor

Looks good! Then my only concern is the message in the changes table. It shows it only as one row with Default Layout Change and just one of the layouts (I think the one that used to be default) with all the fields changes, not only the default change. Also, it will include changes made in between to another template - I just worry it will be a bit confusing for users to understand what they are promoting.

Comment on lines +73 to +75
{type === ChangeEntityTypeEnum.DEFAULT_LAYOUT && (
<Text color={colorScheme === 'dark' ? colors.B40 : colors.B70}>Default Layout Change</Text>
)}
Copy link
Contributor

@LetItRock LetItRock Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the line above

@BiswaViraj BiswaViraj force-pushed the nv-1576-make-default-layout-changes-dependent branch from dab47c1 to 08a5b73 Compare February 17, 2023 10:25
@BiswaViraj BiswaViraj force-pushed the nv-1576-make-default-layout-changes-dependent branch from bf78ec5 to 2cddfa4 Compare February 20, 2023 10:20
@BiswaViraj BiswaViraj added this pull request to the merge queue Feb 20, 2023
Merged via the queue into next with commit 7f8e2e2 Feb 20, 2023
@BiswaViraj BiswaViraj deleted the nv-1576-make-default-layout-changes-dependent branch February 20, 2023 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants