-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: support layout elements in smart action form hooks #1037
Conversation
@@ -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 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
} | ||
|
||
static parseLayout( |
There was a problem hiding this comment.
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.
Co-authored-by: Morgan PERRE <morganperre@gmail.com>
@@ -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 () => { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { ...field }; | |
return field; |
Code Climate has analyzed commit 142f245 and detected 5 issues on this pull request. Here's the issue category breakdown:
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. |
There was a problem hiding this 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
# [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))
🎉 This PR is included in version 10.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Definition of Done
#86c097a97
General
Security