Skip to content

[FND-209] Build service & job to generate project specific variants for form configs - #24658

Merged
klaustopher merged 4 commits into
devfrom
fnd-209-build-variant-from-project
Aug 11, 2026
Merged

[FND-209] Build service & job to generate project specific variants for form configs#24658
klaustopher merged 4 commits into
devfrom
fnd-209-build-variant-from-project

Conversation

@klaustopher

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/projects/FND/work_packages/FND-209/activity

What are you trying to accomplish?

Screenshots

What approach did you choose and why?

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@dfriquet
dfriquet force-pushed the feature/fnd-109-changing-the-active-type-variant-in-a-project branch from d855722 to 20e7e57 Compare August 7, 2026 10:04
Base automatically changed from feature/fnd-109-changing-the-active-type-variant-in-a-project to dev August 7, 2026 10:07
@dfriquet
dfriquet self-requested a review August 11, 2026 10:44

@dfriquet dfriquet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Easy to read 👍

One edge case to solve, and some spec SRP.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This spec is overlapping a lot on the service one. Some assertions rely on service internals, like created data structures for example.

In my opinion, the job spec should be mostly spy-based, asserting service calls and stubbing the result. All that in order to check its responsibilities: handing the service the right arguments and counting outcomes to report.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see the job spec more as an integration of the entire feature.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don’t see what under-the-radar moving parts that integration exercises. I read already covered cases by the service’s specs, and no assertion on the @built/@unchanged/@failed trio for example, or the transaction-in-transaction outcome.

But this is a spec file for a one-time job, I can live with that 👌

Comment on lines +81 to +83
result = Projects::Types::SwitchVariantService
.new(user:, model: project)
.call(source: type, target: variant)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will fail on every archived project: SwitchVariantService validates Projects::ManageTypesContract, ending up with unless project.active? || project.being_archived? in UserPermissibleService#allowed_in_single_project?.

As the BuildVariantFromProjectService and Projects::Types::SwitchVariantService are not in the same transaction, the failure of the latter will leave the creation of the former orphan.

I don’t know how we should handle this case. We cannot narrow the ProjectType query to handle only active (and being archived) projects, leaving archived project without customized form configuration, can we?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Usually we pass the EmptyContract in cases like this. I think this should also be the correct pattern here. Adding a spec and putting everything in one transaction

@dfriquet

dfriquet commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

One follow-up question: the effective removal of custom field configuration screen is expected in another PR?

@klaustopher

Copy link
Copy Markdown
Contributor Author

One follow-up question: the effective removal of custom field configuration screen is expected in another PR?

Yes, this is only the service logic

@klaustopher
klaustopher requested a review from dfriquet August 11, 2026 14:37

@dfriquet dfriquet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TIL about the EmptyContractUser.system 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don’t see what under-the-radar moving parts that integration exercises. I read already covered cases by the service’s specs, and no assertion on the @built/@unchanged/@failed trio for example, or the transaction-in-transaction outcome.

But this is a spec file for a one-time job, I can live with that 👌

@klaustopher
klaustopher merged commit d12a9e5 into dev Aug 11, 2026
14 checks passed
@klaustopher
klaustopher deleted the fnd-209-build-variant-from-project branch August 11, 2026 15:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants