mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
33 lines
726 B
Vue
33 lines
726 B
Vue
|
<template>
|
||
|
<span :title="name">
|
||
|
<slot :shortenedName="shortenedName"></slot>
|
||
|
</span>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts">
|
||
|
import Vue from "vue";
|
||
|
|
||
|
const DEFAULT_WORKFLOW_NAME_LIMIT = 25;
|
||
|
const WORKFLOW_NAME_END_COUNT_TO_KEEP = 4;
|
||
|
|
||
|
export default Vue.extend({
|
||
|
name: "WorkflowNameShort",
|
||
|
props: ["name", "limit"],
|
||
|
computed: {
|
||
|
shortenedName(): string {
|
||
|
const name = this.$props.name;
|
||
|
|
||
|
const limit = this.$props.limit || DEFAULT_WORKFLOW_NAME_LIMIT;
|
||
|
if (name.length <= limit) {
|
||
|
return name;
|
||
|
}
|
||
|
|
||
|
const first = name.slice(0, limit - WORKFLOW_NAME_END_COUNT_TO_KEEP);
|
||
|
const last = name.slice(name.length - WORKFLOW_NAME_END_COUNT_TO_KEEP, name.length);
|
||
|
|
||
|
return `${first}...${last}`;
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
</script>
|