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

⚡️ Introduce FE external hooks #1332

Merged
merged 11 commits into from
Jan 19, 2021
Merged

⚡️ Introduce FE external hooks #1332

merged 11 commits into from
Jan 19, 2021

Conversation

ahsanv
Copy link
Member

@ahsanv ahsanv commented Jan 12, 2021

No description provided.

@ahsanv ahsanv requested a review from janober January 12, 2021 17:56
@ahsanv ahsanv force-pushed the av/external-hooks-fe branch 2 times, most recently from 996436f to 679bd11 Compare January 14, 2021 13:28
@@ -24,6 +24,7 @@

import { genericHelpers } from '@/components/mixins/genericHelpers';
import { restApi } from '@/components/mixins/restApi';
import { externalHooks } from '@/components/mixins/externalHooks';
Copy link
Member

Choose a reason for hiding this comment

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

Is not in alphabetical order.

@@ -37,6 +38,7 @@ export default mixins(
restApi,
showMessage,
workflowHelpers,
externalHooks,
Copy link
Member

Choose a reason for hiding this comment

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

Is not in alphabetical order.

@@ -0,0 +1,38 @@
import Vue from "vue";
import { IExternalHooks } from "@/Interface";
import { IDataObject } from "n8n-workflow";
Copy link
Member

Choose a reason for hiding this comment

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

Uses double instead of single quotes here and multiple other locations.

metadata?: IDataObject,
) {
// @ts-ignore
if (!window.externalHooks) {
Copy link
Member

Choose a reason for hiding this comment

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

Lets maybe use a more specific name like n8nExternalHooks.

@@ -117,6 +117,10 @@ export interface INodeTypesMaxCount {
};
}

export interface IExternalHooks {
onExternalHookEvent(eventName: string, metadata?: IDataObject): void;
Copy link
Member

Choose a reason for hiding this comment

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

The name is misleading. It sounds like it would execute something when an external hook event gets called but it does actually the opposite.

externalHooks(): IExternalHooks {
return {
onExternalHookEvent: (eventName: string, metadata?: IDataObject): void => {
runExternalHook(eventName, this.$store.state, metadata);
Copy link
Member

Choose a reason for hiding this comment

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

Should have "await".

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why we provide the store.state? Should it not rather be the store itself to be able to use getters and commit? Or is it not simply better to use .call(this, ... to stay flexible?

@@ -118,6 +118,7 @@ import { genericHelpers } from '@/components/mixins/genericHelpers';
import { mouseSelect } from '@/components/mixins/mouseSelect';
import { moveNodeWorkflow } from '@/components/mixins/moveNodeWorkflow';
import { restApi } from '@/components/mixins/restApi';
import { externalHooks } from '@/components/mixins/externalHooks';
Copy link
Member

Choose a reason for hiding this comment

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

Is not in alphabetical order.

@@ -172,6 +173,7 @@ export default mixins(
titleChange,
workflowHelpers,
workflowRun,
externalHooks,
Copy link
Member

Choose a reason for hiding this comment

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

Is not in alphabetical order.

Choose a reason for hiding this comment

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

@janober could probably setup husky pre-commit hooks to handle sorting imports and possibly failing commits until things that cannot be auto fixed (like using camelCase) are fixed manually by the committer

Copy link
Member

Choose a reason for hiding this comment

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

For the backend modules, the rules are already in place and everything got cleaned up and is fine. On the frontend, however, we did not look into that yet. So agree we probably should do that soon.

@@ -129,6 +131,7 @@ export default mixins(

if (newActiveState === true) {
this.$store.commit('setWorkflowActive', this.workflowId);
this.externalHooks().onExternalHookEvent('workflow.onWorkflowActivated', { workflow_id: this.workflowId, workflow_name: this.$store.getters.workflowName });
Copy link
Member

Choose a reason for hiding this comment

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

We use everywhere camelCase in n8n, so should also be the case here.

@@ -2033,6 +2039,8 @@ export default mixins(
}
this.stopLoading();
});

this.externalHooks().onExternalHookEvent('nodeView.mounted', this.$store.state);
Copy link
Member

Choose a reason for hiding this comment

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

Providing store.state should not be needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

leftover 🤦

@ahsanv ahsanv marked this pull request as ready for review January 19, 2021 16:23
@ahsanv ahsanv requested a review from janober January 19, 2021 16:24
@janober janober merged commit 4d44622 into master Jan 19, 2021
@janober janober deleted the av/external-hooks-fe branch January 19, 2021 22:48
@janober
Copy link
Member

janober commented Jan 19, 2021

Thanks a lot. Got merged.

@janober
Copy link
Member

janober commented Jan 21, 2021

Got released with n8n@0.103.1

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

Successfully merging this pull request may close these issues.

3 participants