* ✨ Added pinia support. Migrated community nodes module. * ✨ Added ui pinia store, moved some data from root store to it, updated modals to work with pinia stores * ✨ Added ui pinia store and migrated a part of the root store * ✨ Migrated `settings` store to pinia * ✨ Removing vuex store refs from router * ✨ Migrated `users` module to pinia store * ⚡ Fixing errors after sync with master * ⚡ One more error after merge * ⚡ Created `workflows` pinia store. Moved large part of root store to it. Started updating references. * ✨ Finished migrating workflows store to pinia * ⚡ Renaming some getters and actions to make more sense * ✨ Finished migrating the root store to pinia * ✨ Migrated ndv store to pinia * ⚡ Renaming main panel dimensions getter so it doesn't clash with data prop name * ✔️ Fixing lint errors * ✨ Migrated `templates` store to pinia * ✨ Migrated the `nodeTypes`store * ⚡ Removed unused pieces of code and oold vuex modules * ✨ Adding vuex calls to pinia store, fi xing wrong references * 💄 Removing leftover $store refs * ⚡ Added legacy getters and mutations to store to support webhooks * ⚡ Added missing front-end hooks, updated vuex state subscriptions to pinia * ✔️ Fixing linting errors * ⚡ Removing vue composition api plugin * ⚡ Fixing main sidebar state when loading node view * 🐛 Fixing an error when activating workflows * 🐛 Fixing isses with workflow settings and executions auto-refresh * 🐛 Removing duplicate listeners which cause import error * 🐛 Fixing route authentication * ⚡ Updating freshly pulled $store refs * Adding deleted const * ⚡ Updating store references in ee features. Reseting NodeView credentials update flag when resetting workspace * ⚡ Adding return type to email submission modal * ⚡ Making NodeView only react to paste event when active * 🐛 Fixing signup view errors * 👌 Addressing PR review comments * 👌 Addressing new PR comments * 👌 Updating invite id logic in signup view
181 lines
3.7 KiB
Vue
181 lines
3.7 KiB
Vue
<template>
|
|
<div
|
|
:class="$style.wrapper"
|
|
:style="iconStyleData"
|
|
@click="(e) => $emit('click')"
|
|
@mouseover="showTooltip = true"
|
|
@mouseleave="showTooltip = false"
|
|
>
|
|
<div :class="$style.tooltip">
|
|
<n8n-tooltip placement="top" manual :value="showTooltip">
|
|
<div slot="content" v-text="nodeType.displayName"></div>
|
|
<span />
|
|
</n8n-tooltip>
|
|
</div>
|
|
<div v-if="nodeIconData !== null" :class="$style.icon" title="">
|
|
<div :class="$style.iconWrapper" :style="iconStyleData">
|
|
<div v-if="nodeIconData !== null" :class="$style.icon">
|
|
<img
|
|
v-if="nodeIconData.type === 'file'"
|
|
:src="nodeIconData.fileBuffer || nodeIconData.path"
|
|
:style="imageStyleData"
|
|
/>
|
|
<font-awesome-icon
|
|
v-else
|
|
:icon="nodeIconData.icon || nodeIconData.path"
|
|
:style="fontStyleData"
|
|
/>
|
|
</div>
|
|
<div v-else class="node-icon-placeholder">
|
|
{{ nodeType !== null ? nodeType.displayName.charAt(0) : '?' }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-else :class="$style.placeholder">
|
|
{{ nodeType !== null ? nodeType.displayName.charAt(0) : '?' }}
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import Vue from 'vue';
|
|
|
|
import { ITemplatesNode } from '@/Interface';
|
|
import { INodeTypeDescription } from 'n8n-workflow';
|
|
import { mapStores } from 'pinia';
|
|
import { useRootStore } from '@/stores/n8nRootStore';
|
|
|
|
interface NodeIconData {
|
|
type: string;
|
|
path?: string;
|
|
fileExtension?: string;
|
|
fileBuffer?: string;
|
|
}
|
|
|
|
export default Vue.extend({
|
|
name: 'HoverableNodeIcon',
|
|
props: {
|
|
circle: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
clickButton: {
|
|
type: Function,
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
nodeType: {
|
|
type: Object,
|
|
},
|
|
size: {
|
|
type: Number,
|
|
},
|
|
},
|
|
computed: {
|
|
...mapStores(
|
|
useRootStore,
|
|
),
|
|
fontStyleData(): object {
|
|
return {
|
|
'max-width': this.size + 'px',
|
|
};
|
|
},
|
|
iconStyleData(): object {
|
|
const nodeType = this.nodeType as ITemplatesNode | null;
|
|
const color = nodeType ? nodeType.defaults && nodeType!.defaults.color : '';
|
|
if (!this.size) {
|
|
return { color };
|
|
}
|
|
|
|
return {
|
|
color,
|
|
width: this.size + 'px',
|
|
height: this.size + 'px',
|
|
'font-size': this.size + 'px',
|
|
'line-height': this.size + 'px',
|
|
'border-radius': this.circle ? '50%' : '2px',
|
|
...(this.disabled && {
|
|
color: 'var(--color-text-light)',
|
|
'-webkit-filter': 'contrast(40%) brightness(1.5) grayscale(100%)',
|
|
filter: 'contrast(40%) brightness(1.5) grayscale(100%)',
|
|
}),
|
|
};
|
|
},
|
|
imageStyleData(): object {
|
|
return {
|
|
width: '100%',
|
|
'max-width': '100%',
|
|
'max-height': '100%',
|
|
};
|
|
},
|
|
nodeIconData(): null | NodeIconData {
|
|
const nodeType = this.nodeType as INodeTypeDescription | ITemplatesNode | null;
|
|
if (nodeType === null) {
|
|
return null;
|
|
}
|
|
|
|
if ((nodeType as ITemplatesNode).iconData) {
|
|
return (nodeType as ITemplatesNode).iconData;
|
|
}
|
|
|
|
const restUrl = this.rootStore.getRestUrl;
|
|
|
|
if (nodeType.icon) {
|
|
const [type, path] = nodeType.icon.split(':');
|
|
const returnData: NodeIconData = {
|
|
type,
|
|
path,
|
|
};
|
|
|
|
if (type === 'file') {
|
|
returnData.path = restUrl + '/node-icon/' + nodeType.name;
|
|
returnData.fileExtension = path.split('.').slice(-1).join();
|
|
}
|
|
|
|
return returnData;
|
|
}
|
|
return null;
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
showTooltip: false,
|
|
};
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.wrapper {
|
|
cursor: pointer;
|
|
z-index: 2000;
|
|
}
|
|
|
|
.icon {
|
|
height: 100%;
|
|
width: 100%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.iconWrapper {
|
|
svg {
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
.placeholder {
|
|
text-align: center;
|
|
}
|
|
|
|
.tooltip {
|
|
left: 10px;
|
|
position: relative;
|
|
z-index: 9999;
|
|
}
|
|
</style>
|