Add more FE hooks (#1772)

*  add FE hook for expressionEdit dialogVisibleChanged

*  update FE hook for expressionEdit dialogVisibleChanged

*  add FE hook for expressionEdit itemSelected

*  add FE hook for nodeSettings valueChanged

*  add FE hook for nodeSettings credentialSelected

* cleanup
This commit is contained in:
Ahsan Virani 2021-05-12 05:12:53 +02:00 committed by GitHub
parent b47de284f5
commit caa55a022b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -30,7 +30,7 @@
<div class="editor-description">
Result
</div>
<expression-input :parameter="parameter" resolvedValue="true" rows="8" :value="value" :path="path"></expression-input>
<expression-input :parameter="parameter" resolvedValue="true" ref="expressionResult" rows="8" :value="value" :path="path"></expression-input>
</div>
</el-col>
@ -52,7 +52,11 @@ import {
Workflow,
} from 'n8n-workflow';
export default Vue.extend({
import { externalHooks } from '@/components/mixins/externalHooks';
import mixins from 'vue-typed-mixins';
export default mixins(externalHooks).extend({
name: 'ExpressionEdit',
props: [
'dialogVisible',
@ -81,7 +85,16 @@ export default Vue.extend({
},
itemSelected (eventData: IVariableItemSelected) {
// User inserted item from Expression Editor variable selector
(this.$refs.inputFieldExpression as any).itemSelected(eventData); // tslint:disable-line:no-any
this.$externalHooks().run('expressionEdit.itemSelected', { parameter: this.parameter, value: this.value, selectedItem: eventData });
},
},
watch: {
dialogVisible (newValue) {
const resolvedExpressionValue = this.$refs.expressionResult && (this.$refs.expressionResult as any).getValue() || undefined; // tslint:disable-line:no-any
this.$externalHooks().run('expressionEdit.dialogVisibleChanged', { dialogVisible: newValue, parameter: this.parameter, value: this.value, resolvedExpressionValue });
},
},
});

View file

@ -59,12 +59,14 @@ import NodeCredentials from '@/components/NodeCredentials.vue';
import NodeWebhooks from '@/components/NodeWebhooks.vue';
import { get, set, unset } from 'lodash';
import { externalHooks } from '@/components/mixins/externalHooks';
import { genericHelpers } from '@/components/mixins/genericHelpers';
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
import mixins from 'vue-typed-mixins';
export default mixins(
externalHooks,
genericHelpers,
nodeHelpers,
)
@ -323,6 +325,8 @@ export default mixins(
// Update the issues
this.updateNodeCredentialIssues(node);
this.$externalHooks().run('nodeSettings.credentialSelected', { updateInformation });
},
valueChanged (parameterData: IUpdateInformation) {
let newValue: NodeParameterValue;
@ -357,6 +361,7 @@ export default mixins(
// Get only the parameters which are different to the defaults
let nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, node.parameters, false, false);
const oldNodeParameters = Object.assign({}, nodeParameters);
// Copy the data because it is the data of vuex so make sure that
// we do not edit it directly
@ -404,7 +409,10 @@ export default mixins(
name: node.name,
value: nodeParameters,
};
this.$store.commit('setNodeParameters', updateInformation);
this.$externalHooks().run('nodeSettings.valueChanged', { parameterPath, newValue, parameters: this.parameters, oldNodeParameters });
this.updateNodeParameterIssues(node, nodeType);
this.updateNodeCredentialIssues(node);