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

112 lines
2.2 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"
>
2022-03-28 04:10:10 -07:00
<div :class="$style.editContainer" @keydown.enter="onRename" @keydown.stop @keydown.esc="editName = false">
2022-03-28 04:27:23 -07:00
<n8n-text :class="$style.renameText" :bold="true" color="text-base" tag="div">Rename node</n8n-text>
2022-03-28 04:10:10 -07:00
<n8n-input ref="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>
2022-03-28 03:55:25 -07:00
</div>
<span :class="$style.title" slot="reference">
2022-03-28 04:36:11 -07:00
<WorkflowNameShort :name="value" :limit="40" />
2022-03-28 03:55:25 -07:00
<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';
2022-03-28 04:36:11 -07:00
import WorkflowNameShort from './WorkflowNameShort.vue';
2022-03-28 01:18:38 -07:00
export default Vue.extend({
2022-03-28 04:36:11 -07:00
components: { WorkflowNameShort },
2022-03-28 01:18:38 -07:00
name: 'NodeTitle',
props: {
2022-03-28 04:10:10 -07:00
value: {
2022-03-28 01:18:38 -07:00
type: String,
},
nodeType: {
},
},
2022-03-28 03:55:25 -07:00
data() {
return {
editName: false,
newName: '',
};
},
methods: {
onEdit() {
2022-03-28 04:10:10 -07:00
this.newName = this.value;
2022-03-28 03:55:25 -07:00
this.editName = true;
2022-03-28 04:10:10 -07:00
this.$nextTick(() => {
const input = this.$refs.input;
if (input) {
(input as HTMLInputElement).focus();
}
});
2022-03-28 03:55:25 -07:00
},
onRename() {
2022-03-28 04:10:10 -07:00
this.$emit('input', this.newName);
2022-03-28 03:55:25 -07:00
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 04:10:10 -07:00
.editContainer {
text-align: left;
2022-03-28 04:27:23 -07:00
> *:first-child {
margin-bottom: var(--spacing-4xs);
}
2022-03-28 04:10:10 -07:00
}
2022-03-28 01:18:38 -07:00
</style>