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

pass array of methods to before and after hooks #426

Closed
wojtek-krysiak opened this issue Apr 25, 2020 · 2 comments
Closed

pass array of methods to before and after hooks #426

wojtek-krysiak opened this issue Apr 25, 2020 · 2 comments
Assignees
Milestone

Comments

@wojtek-krysiak
Copy link
Contributor

wojtek-krysiak commented Apr 25, 2020

Right now to pass multiple hooks we have to run them manually and pass response between the calls of each hook.

which looks lie this:

before: async (req, context) => {
  const modifiedRequest = await hook1EncryptPassword(req, context),
  return hook2PrefillSomeData(modifiedRequest, context)
}

In this task we will have to allow people to pass hooks as an array, so the example above will be simplified to:

before: [hook1EncryptPassword, hook2PrefillSomeData]

The task will come down to changing this line: and this line

so when this.action.before (or after) is an array simply invoke them one by one and carry the modifyRequest.

Acceptance criteria

  • allow passing an array as a before and after hooks
  • make sure to update the type definitions (Before | Arran etc)
  • write unit tests
  • update one resource in the example-app so it takes 2 hooks as an array and write super simple e2e test for that. These hooks could preset default values in 2 different fields (one hook each field) and e2e test will check if they were set
@wojtek-krysiak wojtek-krysiak added this to the v3.0 milestone Jul 30, 2020
@wojtek-krysiak wojtek-krysiak self-assigned this Jul 30, 2020
wojtek-krysiak added a commit that referenced this issue Aug 1, 2020
github-actions bot pushed a commit that referenced this issue Aug 1, 2020
# [3.0.0-beta.5](v3.0.0-beta.4...v3.0.0-beta.5) (2020-08-01)

### Features

* hooks can be passed as an array ([7e23ce0](7e23ce0)), closes [#426](#426)
@github-actions
Copy link

github-actions bot commented Aug 1, 2020

🎉 This issue has been resolved in version 3.0.0-beta.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Aug 22, 2020
# [3.0.0](v2.9.0...v3.0.0) (2020-08-22)

### Bug Fixes

* add missing ParamsType type export ([a704350](a704350))
* bring back old package name ([dd03f15](dd03f15))
* bump design-system ([dfe5996](dfe5996))
* design system types ([f96170c](f96170c))
* empty payload error happend in hapi plugin ([f5775dd](f5775dd))
* error when use AdminBro.bundle form an another package ([2ada007](2ada007))
* error when xxxProperties were empty in merge ([1db1235](1db1235))
* errors with mergin resource options ([65be2a6](65be2a6))
* fix ts exports ([4ad29f3](4ad29f3))
* make components backward compatible ([773341e](773341e))
* move npmrc to the root ([c295bd2](c295bd2))
* move RegisteredAdapters to globak scope ([0325a2a](0325a2a))
* populate record after editfixes [#452](#452) ([0ce3e63](0ce3e63))
* remove babel from rollup ([335c6b6](335c6b6))
* remove design-system from typings ([4fab567](4fab567))
* use latest design system ([7bbb2f3](7bbb2f3))

### Code Refactoring

* ⚡ rename package to @admin-bro/core ([b988edb](b988edb))

### Features

* 🔥 extract design-system to a separate package ([3da18e6](3da18e6))
* admin-bro features ([fcd13e4](fcd13e4)), closes [#431](#431)
* allow to setup theme base on the user ([baa28f5](baa28f5)), closes [#511](#511)
* get bundled design-system to the head ([d20aa49](d20aa49))
* hooks can be passed as an array ([7e23ce0](7e23ce0)), closes [#426](#426)
* improve performance of text inputs ([82f6db4](82f6db4))

### improvement

* remove name from property options ([69b342a](69b342a)), closes [#448](#448)
* remove not needed BaseResource#name ([4848a2d](4848a2d))

### BREAKING CHANGES

* name in propery options doesn't affect property anymore
* now base resource does not have a name() property
* all imports should be changes to @admin-bro/core
* now users should use @admin-bro/design-system
@github-actions
Copy link

🎉 This issue has been resolved in version 3.0.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
Projects
None yet
Development

No branches or pull requests

1 participant