n8n/packages/editor-ui/src/components/NodeTitle.vue

94 lines
1.7 KiB
Vue
Raw Normal View History

2022-03-28 01:18:38 -07:00
<template>
2022-03-28 03:55:25 -07:00
<span :class="$style.container" @click="onEdit">
2022-03-28 01:18:38 -07:00
<span :class="$style.iconWrapper"><NodeIcon :nodeType="nodeType" :size="18" /></span>
2022-03-28 03:55:25 -07:00
<el-popover
placement="right"
width="200"
:value="editName"
>
<p>Rename node</p>
<n8n-input size="small" v-model="newName" />
<div :class="$style.editButtons">
<n8n-button type="outline" size="small" @click="editName = false" label="Cancel" />
<n8n-button type="primary" size="small" @click="onRename" label="Rename" />
</div>
<span :class="$style.title" slot="reference">
{{name}}
<font-awesome-icon :class="$style.editIcon" icon="pencil-alt" />
</span>
</el-popover>
2022-03-28 01:18:38 -07:00
</span>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
name: 'NodeTitle',
props: {
name: {
type: String,
},
nodeType: {
},
},
2022-03-28 03:55:25 -07:00
data() {
return {
editName: false,
newName: '',
};
},
methods: {
onEdit() {
this.newName = this.name;
this.editName = true;
},
onRename() {
this.$emit('update', this.newName);
this.editName = false;
},
},
2022-03-28 01:18:38 -07:00
});
</script>
<style lang="scss" module>
.container {
font-weight: var(--font-weight-bold);
display: flex;
font-size: var(--font-size-m);
line-height: var(--font-line-height-compact);
2022-03-28 03:55:25 -07:00
overflow-wrap: anywhere;
height: 60px;
overflow: hidden;
}
.title {
text-overflow: ellipsis;
&:hover {
.editIcon {
display: inline-block;
}
}
2022-03-28 01:18:38 -07:00
}
.iconWrapper {
display: inline-flex;
margin-right: var(--spacing-2xs);
}
2022-03-28 03:55:25 -07:00
.editIcon {
display: none;
font-size: var(--font-size-2xs);
}
.editButtons {
text-align: right;
margin-top: var(--spacing-s);
> * {
margin-left: var(--spacing-4xs);
}
}
2022-03-28 01:18:38 -07:00
</style>