mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
refactor: Fix node versioning again (#3819)
* 📘 Update state interface * ⚡ Adjust store module to interface * 🔥 Remove excess check * 🐛 Fix filtering * 🐛 Ensure default to latest version * ✨ Add `allLatestNodeTypes` getter * 🔥 Remove excess checks * ⚡ Simplify expression * ⚡ Add check * 🐛 Account for unknown node type name
This commit is contained in:
@@ -44,31 +44,16 @@ export default Vue.extend({
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
allNodeTypes: [],
|
||||
allLatestNodeTypes: [] as INodeTypeDescription[],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('users', ['personalizedNodeTypes']),
|
||||
nodeTypes(): INodeTypeDescription[] {
|
||||
return this.$store.getters['nodeTypes/allNodeTypes'];
|
||||
return this.$store.getters['nodeTypes/allLatestNodeTypes'];
|
||||
},
|
||||
visibleNodeTypes(): INodeTypeDescription[] {
|
||||
return this.allNodeTypes
|
||||
.filter((nodeType: INodeTypeDescription) => {
|
||||
return !HIDDEN_NODES.includes(nodeType.name);
|
||||
}).reduce((accumulator: INodeTypeDescription[], currentValue: INodeTypeDescription) => {
|
||||
// keep only latest version of the nodes
|
||||
// accumulator starts as an empty array.
|
||||
const exists = accumulator.findIndex(nodes => nodes.name === currentValue.name);
|
||||
if (exists >= 0 && accumulator[exists].version < currentValue.version) {
|
||||
// This must be a versioned node and we've found a newer version.
|
||||
// Replace the previous one with this one.
|
||||
accumulator[exists] = currentValue;
|
||||
} else {
|
||||
accumulator.push(currentValue);
|
||||
}
|
||||
return accumulator;
|
||||
}, []);
|
||||
return this.allLatestNodeTypes.filter((nodeType) => !HIDDEN_NODES.includes(nodeType.name));
|
||||
},
|
||||
categoriesWithNodes(): ICategoriesWithNodes {
|
||||
return getCategoriesWithNodes(this.visibleNodeTypes, this.personalizedNodeTypes as string[]);
|
||||
@@ -125,8 +110,8 @@ export default Vue.extend({
|
||||
},
|
||||
watch: {
|
||||
nodeTypes(newList) {
|
||||
if (newList.length !== this.allNodeTypes.length) {
|
||||
this.allNodeTypes = newList;
|
||||
if (newList.length !== this.allLatestNodeTypes.length) {
|
||||
this.allLatestNodeTypes = newList;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user