mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix ts and eslint errors in various components (no-changelog) (#9592)
This commit is contained in:
parent
09472fb9ee
commit
03f15c49d5
|
@ -48,7 +48,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent, type ComponentInstance } from 'vue';
|
||||||
|
|
||||||
import type { ITag } from '@/Interface';
|
import type { ITag } from '@/Interface';
|
||||||
import IntersectionObserver from './IntersectionObserver.vue';
|
import IntersectionObserver from './IntersectionObserver.vue';
|
||||||
|
@ -70,7 +70,22 @@ interface TagEl extends ITag {
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TagsContainer',
|
name: 'TagsContainer',
|
||||||
components: { IntersectionObserver, IntersectionObserved },
|
components: { IntersectionObserver, IntersectionObserved },
|
||||||
props: ['tagIds', 'limit', 'clickable', 'responsive', 'hoverable'],
|
props: {
|
||||||
|
tagIds: {
|
||||||
|
type: Array as () => string[],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: Number,
|
||||||
|
default: DEFAULT_MAX_TAGS_LIMIT,
|
||||||
|
},
|
||||||
|
clickable: Boolean,
|
||||||
|
responsive: Boolean,
|
||||||
|
hoverable: Boolean,
|
||||||
|
},
|
||||||
|
emits: {
|
||||||
|
click: null,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
maxWidth: 320,
|
maxWidth: 320,
|
||||||
|
@ -79,16 +94,6 @@ export default defineComponent({
|
||||||
debouncedSetMaxWidth: () => {},
|
debouncedSetMaxWidth: () => {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.debouncedSetMaxWidth = debounce(this.setMaxWidth, 100);
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.setMaxWidth();
|
|
||||||
window.addEventListener('resize', this.debouncedSetMaxWidth);
|
|
||||||
},
|
|
||||||
beforeUnmount() {
|
|
||||||
window.removeEventListener('resize', this.debouncedSetMaxWidth);
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useTagsStore),
|
...mapStores(useTagsStore),
|
||||||
style() {
|
style() {
|
||||||
|
@ -101,9 +106,7 @@ export default defineComponent({
|
||||||
.map((tagId: string) => this.tagsStore.getTagById(tagId))
|
.map((tagId: string) => this.tagsStore.getTagById(tagId))
|
||||||
.filter(Boolean); // if tag has been deleted from store
|
.filter(Boolean); // if tag has been deleted from store
|
||||||
|
|
||||||
const limit = this.limit || DEFAULT_MAX_TAGS_LIMIT;
|
let toDisplay: TagEl[] = this.limit ? tags.slice(0, this.limit) : tags;
|
||||||
|
|
||||||
let toDisplay: TagEl[] = limit ? tags.slice(0, limit) : tags;
|
|
||||||
toDisplay = toDisplay.map((tag: ITag) => ({
|
toDisplay = toDisplay.map((tag: ITag) => ({
|
||||||
...tag,
|
...tag,
|
||||||
hidden: this.responsive && !this.visibility[tag.id],
|
hidden: this.responsive && !this.visibility[tag.id],
|
||||||
|
@ -135,9 +138,20 @@ export default defineComponent({
|
||||||
return toDisplay;
|
return toDisplay;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.debouncedSetMaxWidth = debounce(this.setMaxWidth, 100);
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setMaxWidth();
|
||||||
|
window.addEventListener('resize', this.debouncedSetMaxWidth);
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
window.removeEventListener('resize', this.debouncedSetMaxWidth);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setMaxWidth() {
|
setMaxWidth() {
|
||||||
const container = this.$refs.tagsContainer.$el as HTMLElement;
|
const containerEl = this.$refs.tagsContainer as ComponentInstance<IntersectionObserver>;
|
||||||
|
const container = containerEl.$el as HTMLElement;
|
||||||
const parent = container.parentNode as HTMLElement;
|
const parent = container.parentNode as HTMLElement;
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
|
|
@ -96,8 +96,14 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
eventBus: {
|
eventBus: {
|
||||||
type: Object as PropType<EventBus>,
|
type: Object as PropType<EventBus>,
|
||||||
|
default: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
emits: {
|
||||||
|
'update:modelValue': null,
|
||||||
|
esc: null,
|
||||||
|
blur: null,
|
||||||
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const { showError } = useToast();
|
const { showError } = useToast();
|
||||||
|
@ -119,10 +125,6 @@ export default defineComponent({
|
||||||
return tagsStore.allTags;
|
return tagsStore.allTags;
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasTags = computed<boolean>(() => {
|
|
||||||
return tagsStore.hasTags;
|
|
||||||
});
|
|
||||||
|
|
||||||
const options = computed<ITag[]>(() => {
|
const options = computed<ITag[]>(() => {
|
||||||
return allTags.value.filter((tag: ITag) => tag && tag.name.includes(filter.value));
|
return allTags.value.filter((tag: ITag) => tag && tag.name.includes(filter.value));
|
||||||
});
|
});
|
||||||
|
@ -142,7 +144,9 @@ export default defineComponent({
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const select = selectRef.value?.$refs?.innerSelect;
|
const select = selectRef.value?.$refs?.innerSelect as
|
||||||
|
| { $refs: { input: Element } }
|
||||||
|
| undefined;
|
||||||
if (select) {
|
if (select) {
|
||||||
const input = select.$refs.input as Element | undefined;
|
const input = select.$refs.input as Element | undefined;
|
||||||
if (input) {
|
if (input) {
|
||||||
|
@ -190,8 +194,6 @@ export default defineComponent({
|
||||||
const newTag = await tagsStore.create(name);
|
const newTag = await tagsStore.create(name);
|
||||||
emit('update:modelValue', [...props.modelValue, newTag.id]);
|
emit('update:modelValue', [...props.modelValue, newTag.id]);
|
||||||
|
|
||||||
void nextTick(() => focusOnTag(newTag.id));
|
|
||||||
|
|
||||||
filter.value = '';
|
filter.value = '';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showError(
|
showError(
|
||||||
|
@ -233,13 +235,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusOnTag(tagId: string) {
|
|
||||||
const tagOptions = tagRefs.value || [];
|
|
||||||
if (tagOptions && tagOptions.length) {
|
|
||||||
const added = tagOptions.find((ref) => ref.value === tagId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function focusOnInput() {
|
function focusOnInput() {
|
||||||
if (selectRef.value) {
|
if (selectRef.value) {
|
||||||
selectRef.value.focusOnInput();
|
selectRef.value.focusOnInput();
|
||||||
|
@ -267,8 +262,8 @@ export default defineComponent({
|
||||||
const tagsModal = document.querySelector('#tags-manager-modal');
|
const tagsModal = document.querySelector('#tags-manager-modal');
|
||||||
|
|
||||||
const clickInsideTagsDropdowns =
|
const clickInsideTagsDropdowns =
|
||||||
tagsDropdown?.contains(e.target as Node) || tagsDropdown === e.target;
|
tagsDropdown?.contains(e.target as Node) ?? tagsDropdown === e.target;
|
||||||
const clickInsideTagsModal = tagsModal?.contains(e.target as Node) || tagsModal === e.target;
|
const clickInsideTagsModal = tagsModal?.contains(e.target as Node) ?? tagsModal === e.target;
|
||||||
|
|
||||||
if (!clickInsideTagsDropdowns && !clickInsideTagsModal && e.type === 'click') {
|
if (!clickInsideTagsDropdowns && !clickInsideTagsModal && e.type === 'click') {
|
||||||
emit('blur');
|
emit('blur');
|
||||||
|
|
|
@ -38,7 +38,22 @@ const matches = (name: string, filter: string) =>
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TagsView',
|
name: 'TagsView',
|
||||||
components: { TagsTableHeader, TagsTable },
|
components: { TagsTableHeader, TagsTable },
|
||||||
props: ['tags', 'isLoading'],
|
props: {
|
||||||
|
tags: {
|
||||||
|
type: Array as () => ITag[],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
isLoading: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
emits: {
|
||||||
|
update: null,
|
||||||
|
delete: null,
|
||||||
|
create: null,
|
||||||
|
disableCreate: null,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
createEnabled: false,
|
createEnabled: false,
|
||||||
|
@ -61,11 +76,11 @@ export default defineComponent({
|
||||||
? this.$locale.baseText('tagsView.inUse', { adjustToNumber: count })
|
? this.$locale.baseText('tagsView.inUse', { adjustToNumber: count })
|
||||||
: this.$locale.baseText('tagsView.notBeingUsed');
|
: this.$locale.baseText('tagsView.notBeingUsed');
|
||||||
|
|
||||||
const disabled = this.isCreateEnabled || this.updateId || this.deleteId;
|
const disabled = this.isCreateEnabled || !!this.updateId || !!this.deleteId;
|
||||||
const tagRows = (this.tags || [])
|
const tagRows = (this.tags ?? [])
|
||||||
.filter((tag: ITag) => this.stickyIds.has(tag.id) || matches(tag.name, this.search))
|
.filter((tag) => this.stickyIds.has(tag.id) || matches(tag.name, this.search))
|
||||||
.map(
|
.map(
|
||||||
(tag: ITag): ITagRow => ({
|
(tag): ITagRow => ({
|
||||||
tag,
|
tag,
|
||||||
usage: getUsage(tag.usageCount),
|
usage: getUsage(tag.usageCount),
|
||||||
disable: disabled && tag.id !== this.deleteId && tag.id !== this.updateId,
|
disable: disabled && tag.id !== this.deleteId && tag.id !== this.updateId,
|
||||||
|
@ -140,7 +155,7 @@ export default defineComponent({
|
||||||
createTag(): void {
|
createTag(): void {
|
||||||
this.isSaving = true;
|
this.isSaving = true;
|
||||||
const name = this.newName.trim();
|
const name = this.newName.trim();
|
||||||
const onCreate = (created: ITag | null, error?: Error) => {
|
const onCreate = (created: ITag | null) => {
|
||||||
if (created) {
|
if (created) {
|
||||||
this.stickyIds.add(created.id);
|
this.stickyIds.add(created.id);
|
||||||
this.disableCreate();
|
this.disableCreate();
|
||||||
|
|
|
@ -21,10 +21,11 @@ export default defineComponent({
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore, useSettingsStore, useUsersStore, useProjectsStore),
|
...mapStores(useRootStore, useSettingsStore, useUsersStore, useProjectsStore),
|
||||||
currentUserId(): string {
|
currentUserId(): string {
|
||||||
return this.usersStore.currentUserId || '';
|
return this.usersStore.currentUserId ?? '';
|
||||||
},
|
},
|
||||||
isTelemetryEnabledOnRoute(): boolean {
|
isTelemetryEnabledOnRoute(): boolean {
|
||||||
return this.$route.meta?.telemetry ? !this.$route.meta.telemetry.disabled : true;
|
const routeMeta = this.$route.meta as { telemetry?: { disabled?: boolean } } | undefined;
|
||||||
|
return routeMeta?.telemetry ? !routeMeta.telemetry.disabled : true;
|
||||||
},
|
},
|
||||||
telemetry(): ITelemetrySettings {
|
telemetry(): ITelemetrySettings {
|
||||||
return this.settingsStore.telemetry;
|
return this.settingsStore.telemetry;
|
||||||
|
|
|
@ -17,41 +17,13 @@ export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
date: {
|
date: {
|
||||||
type: String,
|
type: String,
|
||||||
|
required: true,
|
||||||
},
|
},
|
||||||
capitalize: {
|
capitalize: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeMount() {
|
|
||||||
register(this.defaultLocale, this.localeFunc as LocaleFunc);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
localeFunc(num: number, index: number, totalSec: number): [string, string] {
|
|
||||||
// number: the timeago / timein number;
|
|
||||||
// index: the index of array below;
|
|
||||||
// totalSec: total seconds between date to be formatted and today's date;
|
|
||||||
return [
|
|
||||||
[this.$locale.baseText('timeAgo.justNow'), this.$locale.baseText('timeAgo.rightNow')],
|
|
||||||
[this.$locale.baseText('timeAgo.justNow'), this.$locale.baseText('timeAgo.rightNow')], // ['%s seconds ago', 'in %s seconds'],
|
|
||||||
[
|
|
||||||
this.$locale.baseText('timeAgo.oneMinuteAgo'),
|
|
||||||
this.$locale.baseText('timeAgo.inOneMinute'),
|
|
||||||
],
|
|
||||||
[this.$locale.baseText('timeAgo.minutesAgo'), this.$locale.baseText('timeAgo.inMinutes')],
|
|
||||||
[this.$locale.baseText('timeAgo.oneHourAgo'), this.$locale.baseText('timeAgo.inOneHour')],
|
|
||||||
[this.$locale.baseText('timeAgo.hoursAgo'), this.$locale.baseText('timeAgo.inHours')],
|
|
||||||
[this.$locale.baseText('timeAgo.oneDayAgo'), this.$locale.baseText('timeAgo.inOneDay')],
|
|
||||||
[this.$locale.baseText('timeAgo.daysAgo'), this.$locale.baseText('timeAgo.inDays')],
|
|
||||||
[this.$locale.baseText('timeAgo.oneWeekAgo'), this.$locale.baseText('timeAgo.inOneWeek')],
|
|
||||||
[this.$locale.baseText('timeAgo.weeksAgo'), this.$locale.baseText('timeAgo.inWeeks')],
|
|
||||||
[this.$locale.baseText('timeAgo.oneMonthAgo'), this.$locale.baseText('timeAgo.inOneMonth')],
|
|
||||||
[this.$locale.baseText('timeAgo.monthsAgo'), this.$locale.baseText('timeAgo.inMonths')],
|
|
||||||
[this.$locale.baseText('timeAgo.oneYearAgo'), this.$locale.baseText('timeAgo.inOneYear')],
|
|
||||||
[this.$locale.baseText('timeAgo.yearsAgo'), this.$locale.baseText('timeAgo.inYears')],
|
|
||||||
][index] as [string, string];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore),
|
...mapStores(useRootStore),
|
||||||
defaultLocale(): string {
|
defaultLocale(): string {
|
||||||
|
@ -72,5 +44,33 @@ export default defineComponent({
|
||||||
return convertToHumanReadableDate(epoch);
|
return convertToHumanReadableDate(epoch);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
beforeMount() {
|
||||||
|
register(this.defaultLocale, this.localeFunc as LocaleFunc);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
localeFunc(_: number, index: number): [string, string] {
|
||||||
|
// number: the timeago / timein number;
|
||||||
|
// index: the index of array below;
|
||||||
|
return [
|
||||||
|
[this.$locale.baseText('timeAgo.justNow'), this.$locale.baseText('timeAgo.rightNow')],
|
||||||
|
[this.$locale.baseText('timeAgo.justNow'), this.$locale.baseText('timeAgo.rightNow')], // ['%s seconds ago', 'in %s seconds'],
|
||||||
|
[
|
||||||
|
this.$locale.baseText('timeAgo.oneMinuteAgo'),
|
||||||
|
this.$locale.baseText('timeAgo.inOneMinute'),
|
||||||
|
],
|
||||||
|
[this.$locale.baseText('timeAgo.minutesAgo'), this.$locale.baseText('timeAgo.inMinutes')],
|
||||||
|
[this.$locale.baseText('timeAgo.oneHourAgo'), this.$locale.baseText('timeAgo.inOneHour')],
|
||||||
|
[this.$locale.baseText('timeAgo.hoursAgo'), this.$locale.baseText('timeAgo.inHours')],
|
||||||
|
[this.$locale.baseText('timeAgo.oneDayAgo'), this.$locale.baseText('timeAgo.inOneDay')],
|
||||||
|
[this.$locale.baseText('timeAgo.daysAgo'), this.$locale.baseText('timeAgo.inDays')],
|
||||||
|
[this.$locale.baseText('timeAgo.oneWeekAgo'), this.$locale.baseText('timeAgo.inOneWeek')],
|
||||||
|
[this.$locale.baseText('timeAgo.weeksAgo'), this.$locale.baseText('timeAgo.inWeeks')],
|
||||||
|
[this.$locale.baseText('timeAgo.oneMonthAgo'), this.$locale.baseText('timeAgo.inOneMonth')],
|
||||||
|
[this.$locale.baseText('timeAgo.monthsAgo'), this.$locale.baseText('timeAgo.inMonths')],
|
||||||
|
[this.$locale.baseText('timeAgo.oneYearAgo'), this.$locale.baseText('timeAgo.inOneYear')],
|
||||||
|
[this.$locale.baseText('timeAgo.yearsAgo'), this.$locale.baseText('timeAgo.inYears')],
|
||||||
|
][index] as [string, string];
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -8,16 +8,17 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { type PropType, defineComponent } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TitledList',
|
name: 'TitledList',
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
|
required: true,
|
||||||
},
|
},
|
||||||
items: {
|
items: {
|
||||||
type: Array,
|
type: Array as PropType<string[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue