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): disallow delete of assigned #2545

Merged
merged 2 commits into from
Jan 20, 2023

Conversation

p-fernandez
Copy link
Contributor

What change does this PR introduce?

Avoids that a layout is deleted if it is being used by a message template.

Why was this change needed?

To avoid data corruption by users actions.

Other information (Screenshots)

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

linear bot commented Jan 19, 2023

NV-1540 Feature: disallow delete of assigned layouts

Throw a 409 Conflict

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.

⭐️

} from '../../../message-template/usecases';

@Injectable()
export class CheckLayoutIsUsedUseCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we could quite easily use this for the isUsed in the FE table we were planning to scope out 🤭
Maybe we could just do it as a query in the front or as an extra return field to the get-layout-usecase , instead of actually adding a field to the schema. Which I definitely don't like.

Actually might have some value in also making it external API accessible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do agree that the isUsed calculation should be done on demand and not by DB flags that could go out of sync easily. And with the rest of your comments.

export class FindMessageTemplatesByLayoutUseCase {
constructor(private messageTemplateRepository: MessageTemplateRepository) {}

async execute(command: FindMessageTemplatesByLayoutCommand): Promise<MessageTemplateEntity[]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like all these separations. You think ahead💪🏻

I see multiple possible future uses for this

@p-fernandez p-fernandez merged commit d0c5118 into feat-layouts Jan 20, 2023
@p-fernandez p-fernandez deleted the nv-1540-feature-disallow-delete-of-assigned branch January 20, 2023 08:55
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