n8n/packages/editor-ui/src/components/ShortenName.vue
2023-12-28 09:49:58 +01:00

28 lines
595 B
Vue

<template>
<span :title="name" :data-test-id="testId">
<slot :shortened-name="shortenedName"></slot>
</span>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { shorten } from '@/utils/typesUtils';
const DEFAULT_WORKFLOW_NAME_LIMIT = 25;
const WORKFLOW_NAME_END_COUNT_TO_KEEP = 4;
export default defineComponent({
name: 'ShortenName',
props: ['name', 'limit', 'testId'],
computed: {
shortenedName(): string {
return shorten(
this.name,
this.limit || DEFAULT_WORKFLOW_NAME_LIMIT,
WORKFLOW_NAME_END_COUNT_TO_KEEP,
);
},
},
});
</script>