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

Most of system collection filter hooks aren't implemented #9575

Closed
3 tasks done
t7tran opened this issue Nov 7, 2021 · 2 comments
Closed
3 tasks done

Most of system collection filter hooks aren't implemented #9575

t7tran opened this issue Nov 7, 2021 · 2 comments

Comments

@t7tran
Copy link
Contributor

t7tran commented Nov 7, 2021

Preflight Checklist

Describe the Bug

I just tried to refactor the hooks and noticed that collections.delete no longer works. It seems from the source code that only fields.delete is invoked via emitter.emitFilter.

image

To Reproduce

const registerHook: HookConfig = (
  { filter, action },
) => {
  filter("collections.delete", async function (data: any) {
    // this doesn't get fired when a collection is being deleted
  });
  filter("fields.delete", async function (data: any) {
    // this DOES get fired when a field is being deleted
  });
};
export default registerHook;

Errors Shown

NA

What version of Directus are you using?

9.0.0

What version of Node.js are you using?

16.13.0

What database are you using?

MySQL

What browser are you using?

Chrome

What operating system are you using?

Ubuntu

How are you deploying Directus?

Docker

@Oreilles
Copy link
Contributor

Oreilles commented Nov 9, 2021

Just tried in a docker setup, cloned from this example from the docs, create the hook file at ./extensions/test/index.js with:

module.exports = function registerHook({ filter , action }) {
  filter("collections.create" , (_) => console.log("collections.create"));
  filter("collections.delete" , (_) => console.log("collections.delete"));
  filter("fields.create"      , (_) => console.log("fields.create"));
  filter("fields.delete"      , (_) => console.log("fields.delete"));
};

and all events triggers just fine.

@t7tran
Copy link
Contributor Author

t7tran commented Nov 9, 2021

It is indeed working. Must have been my mistake. Thanks for checking @Oreilles.

@t7tran t7tran closed this as completed Nov 9, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants