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: support layout elements in smart action form hooks #1037

Merged
merged 14 commits into from
Oct 16, 2024

Conversation

realSpok
Copy link
Contributor

Definition of Done

#86c097a97

General

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Test manually the implemented changes
  • Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • Consider the security impact of the changes made

@forest-bot
Copy link
Member

@@ -32,13 +33,16 @@ class SmartActionHookService {
if (typeof hook !== 'function') throw new Error('hook must be a function');

// Call the user-defined load hook.
const result = await hook({ request, fields: fieldsForUser, changedField });
const hookResult = await hook({ request, fields: fieldsForUser, changedField });
Copy link
Member

Choose a reason for hiding this comment

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

👀

Copy link
Member

Choose a reason for hiding this comment

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

What is the hookResult json form ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the result looks like that:
{field: [...], layout: [...]}

it('should extract out the layout and fields from the hook result', async () => {
const { smartActionFormLayoutService } = setup();

const form = [
Copy link
Member

Choose a reason for hiding this comment

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

This is the type that the client will need to provide ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It is the same kind of syntax as v2.
We agreed on it with agent team this morning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could ease the transition to v2 if the syntax is roughly similar

Copy link
Member

Choose a reason for hiding this comment

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

Could you add some example without type: 'Layout',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}

static parseLayout(
Copy link
Member

Choose a reason for hiding this comment

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

This code is kinda a duplicate from Agent Node.js ? Maybe it could be good to add a link to the code in the Node.js agent.

Nicolas Moreau and others added 3 commits October 15, 2024 17:26
@@ -26,7 +28,7 @@ describe('services > smart-action-hook', () => {
.rejects.toThrow('hook must return an array');
});

it('should return an array of fields', async () => {
it('should return an object containing an array of fields and a layout', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

can you add some layout elements in the test just to ensure the layout is correctly returned ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

not really, If smart-action-hook-service is modified to return only empty arrays for the layout, no test will break. But yeah, maybe a bit useless to test, you can leave it like that

@@ -59,9 +63,9 @@ class SmartActionHookService {
return { ...field, value: null };
}
}

return field;
return { ...field };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return { ...field };
return field;

Copy link

codeclimate bot commented Oct 16, 2024

Code Climate has analyzed commit 142f245 and detected 5 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3
Duplication 2

The test coverage on the diff in this pull request is 100.0% (70% is the threshold).

This pull request will bring the total coverage in the repository to 62.4%.

View more on Code Climate.

Copy link
Member

@Thenkei Thenkei left a comment

Choose a reason for hiding this comment

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

  • ✅ Code review
    • ✅  Use pure functions when possible
    • ✅  The PR tackle one subject only
  • ✅ Automatic tests
    • ✅  Unit tests
    • ✅  Integration tests
  • ✅ Manual tests
  • ✅ PR title
  • ✅ PR linked to the clickup task

@realSpok realSpok merged commit 20635ab into main Oct 16, 2024
5 of 6 checks passed
@realSpok realSpok deleted the feat/support-layout-elements-in-smart-action-form-hooks branch October 16, 2024 08:59
forest-bot added a commit that referenced this pull request Oct 16, 2024
# [10.3.0](v10.2.26...v10.3.0) (2024-10-16)

### Features

* support layout elements in smart action form hooks ([#1037](#1037)) ([20635ab](20635ab))
@forest-bot
Copy link
Member

🎉 This PR is included in version 10.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants