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

feat(api): add endpoint to set a layout as default #2514

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

p-fernandez
Copy link
Contributor

What change does this PR introduce?

Adds endpoint and use case to set a layout as default. If there is an existing default layout in the same environment, it will set it to non default while setting as default the chosen one.

Why was this change needed?

The endpoint is probably not going to be used but the use case will be reused in the creation and update endpoints when the isDefault property is sent as true. As we can only have one default template per environment we need this functionality.

Other information (Screenshots)

@p-fernandez p-fernandez self-assigned this Jan 16, 2023
@linear
Copy link

linear bot commented Jan 16, 2023


const BASE_PATH = '/v1/layouts';

export const createLayout = async (session: UserSession, name: LayoutName, isDefault: boolean): Promise<LayoutDto> => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created this helper file as the layout creation functionality is being reused in all the tests.

await this.setIsDefaultForLayout(command.layoutId, command.environmentId, command.organizationId, true);
} catch (error) {
Logger.error(error);
// TODO: Rollback through transactions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have no transactions implementation in the Mongoose adapter repository. Something to do across the stack.

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.

Should you maybe just revert the pnpm-lock changes?

@p-fernandez p-fernandez force-pushed the nv-1416-set-a-layout-as-default branch from 6e3f237 to 2caf6ce Compare January 17, 2023 10:14
@p-fernandez
Copy link
Contributor Author

Should you maybe just revert the pnpm-lock changes?

Done. I had some problems with my environment and had to reinstall dependencies the other day.

@p-fernandez p-fernandez merged commit dc81390 into feat-layouts Jan 17, 2023
@p-fernandez p-fernandez deleted the nv-1416-set-a-layout-as-default branch January 17, 2023 10:40
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

2 participants