Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix Vue 3 linting issues #6748

Merged
merged 6 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/editor-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ export default defineComponent({
Modals,
},
mixins: [newVersions, userHelpers],
setup(props) {
async setup(props) {
const newVersionsSetup = await newVersions.setup?.(props);

return {
...useGlobalLinkActions(),
...useHistoryHelper(useRoute()),
...useToast(),
externalHooks: useExternalHooks(),
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...newVersions.setup?.(props),
...newVersionsSetup,
};
},
computed: {
Expand Down
1 change: 0 additions & 1 deletion packages/editor-ui/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ISettingsState } from '@/Interface';
import { UserManagementAuthenticationMethod } from '@/Interface';
import { render } from '@testing-library/vue';

export const retry = async (assertion: () => any, { interval = 20, timeout = 1000 } = {}) => {
return new Promise((resolve, reject) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/editor-ui/src/components/BreakpointsObserver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default defineComponent({
onResize() {
void this.callDebounced('onResizeEnd', { debounceTime: 50 });
},
onResizeEnd() {
async onResizeEnd() {
this.width = window.innerWidth;
void this.$nextTick(async () => {
const bannerHeight = await getBannerRowHeight();
useUIStore().updateBannersHeight(bannerHeight);
});
await this.$nextTick();

const bannerHeight = await getBannerRowHeight();
useUIStore().updateBannersHeight(bannerHeight);
},
},
computed: {
Expand Down
21 changes: 10 additions & 11 deletions packages/editor-ui/src/components/CollectionsCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,17 @@ export default defineComponent({
}
},
},
mounted() {
void this.$nextTick(() => {
const sliderRef = this.$refs.slider as SliderRef | undefined;
if (!sliderRef) {
return;
}
async mounted() {
await this.$nextTick();
const sliderRef = this.$refs.slider as SliderRef | undefined;
if (!sliderRef) {
return;
}

this.listElement = sliderRef.$el.querySelector('.agile__list');
if (this.listElement) {
this.listElement.addEventListener('scroll', this.updateCarouselScroll);
}
});
this.listElement = sliderRef.$el.querySelector('.agile__list');
if (this.listElement) {
this.listElement.addEventListener('scroll', this.updateCarouselScroll);
}
},
beforeUnmount() {
const sliderRef = this.$refs.slider as SliderRef | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export default defineComponent({
},
async mounted() {
this.name = await this.workflowsStore.getDuplicateCurrentWorkflowName(this.data.name);
void this.$nextTick(() => this.focusOnNameInput());
await this.$nextTick();
this.focusOnNameInput();
},
computed: {
...mapStores(useCredentialsStore, useUsersStore, useSettingsStore, useWorkflowsStore),
Expand Down
7 changes: 3 additions & 4 deletions packages/editor-ui/src/components/IntersectionObserved.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ export default defineComponent({
default: () => createEventBus(),
},
},
mounted() {
async mounted() {
if (!this.enabled) {
return;
}

void this.$nextTick(() => {
this.eventBus.emit('observe', this.$refs.observed);
});
await this.$nextTick();
this.eventBus.emit('observe', this.$refs.observed);
},
beforeUnmount() {
if (this.enabled) {
Expand Down
11 changes: 6 additions & 5 deletions packages/editor-ui/src/components/MainHeader/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ export default defineComponent({
TabBar,
},
mixins: [pushConnection, workflowHelpers],
setup(props) {
async setup(props) {
const pushConnectionSetup = await pushConnection.setup?.(props);
const workflowHelpersSetup = await workflowHelpers.setup?.(props);

return {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...pushConnection.setup?.(props),
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...workflowHelpers.setup?.(props),
...pushConnectionSetup,
...workflowHelpersSetup,
};
},
data() {
Expand Down
17 changes: 8 additions & 9 deletions packages/editor-ui/src/components/MainSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ export default defineComponent({
MainSidebarSourceControl,
},
mixins: [genericHelpers, workflowHelpers, workflowRun, userHelpers, debounceHelper],
setup(props) {
async setup(props) {
const workflowRunSetup = await workflowRun.setup?.(props);
return {
...useMessage(),
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...workflowRun.setup?.(props),
...workflowRunSetup,
};
},
data() {
Expand Down Expand Up @@ -478,16 +478,15 @@ export default defineComponent({
onResize(event: UIEvent) {
void this.callDebounced('onResizeEnd', { debounceTime: 100 }, event);
},
onResizeEnd(event: UIEvent) {
async onResizeEnd(event: UIEvent) {
const browserWidth = (event.target as Window).outerWidth;
this.checkWidthAndAdjustSidebar(browserWidth);
await this.checkWidthAndAdjustSidebar(browserWidth);
},
checkWidthAndAdjustSidebar(width: number) {
async checkWidthAndAdjustSidebar(width: number) {
if (width < 900) {
this.uiStore.sidebarMenuCollapsed = true;
this.$nextTick(() => {
this.fullyExpanded = !this.isCollapsed;
});
await this.$nextTick();
this.fullyExpanded = !this.isCollapsed;
}
},
},
Expand Down
18 changes: 8 additions & 10 deletions packages/editor-ui/src/components/Node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -569,28 +569,26 @@ export default defineComponent({
workflow_id: this.workflowsStore.workflowId,
});
},
deleteNode() {
async deleteNode() {
this.$telemetry.track('User clicked node hover button', {
node_type: this.data.type,
button_name: 'delete',
workflow_id: this.workflowsStore.workflowId,
});

void this.$nextTick(() => {
// Wait a tick else vue causes problems because the data is gone
this.$emit('removeNode', this.data.name);
});
// Wait a tick else vue causes problems because the data is gone
await this.$nextTick();
this.$emit('removeNode', this.data.name);
},
duplicateNode() {
async duplicateNode() {
this.$telemetry.track('User clicked node hover button', {
node_type: this.data.type,
button_name: 'duplicate',
workflow_id: this.workflowsStore.workflowId,
});
void this.$nextTick(() => {
// Wait a tick else vue causes problems because the data is gone
this.$emit('duplicateNode', this.data.name);
});
// Wait a tick else vue causes problems because the data is gone
await this.$nextTick();
this.$emit('duplicateNode', this.data.name);
},

onClick(event: MouseEvent) {
Expand Down
7 changes: 4 additions & 3 deletions packages/editor-ui/src/components/NodeDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ export default defineComponent({
default: false,
},
},
setup(props) {
async setup(props) {
const workflowActivateSetup = await workflowActivate.setup?.(props);

return {
...useDeviceSupport(),
...useMessage(),
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...workflowActivate.setup?.(props),
...workflowActivateSetup,
};
},
data() {
Expand Down
6 changes: 3 additions & 3 deletions packages/editor-ui/src/components/NodeExecuteButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export default defineComponent({
type: String,
},
},
setup(props) {
async setup(props) {
const workflowRunSetup = await workflowRun.setup?.(props);
return {
...useToast(),
...useMessage(),
// eslint-disable-next-line @typescript-eslint/no-misused-promises
...workflowRun.setup?.(props),
...workflowRunSetup,
};
},
computed: {
Expand Down
13 changes: 6 additions & 7 deletions packages/editor-ui/src/components/NodeTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ export default defineComponent({
},
},
methods: {
onEdit() {
async onEdit() {
this.newName = this.modelValue;
this.editName = true;
void this.$nextTick(() => {
const inputRef = this.$refs.input as HTMLInputElement | undefined;
if (inputRef) {
inputRef.focus();
}
});
await this.$nextTick();
const inputRef = this.$refs.input as HTMLInputElement | undefined;
if (inputRef) {
inputRef.focus();
}
},
onRename() {
if (this.newName.trim() !== '') {
Expand Down
32 changes: 15 additions & 17 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ export default defineComponent({
onResourceLocatorDrop(data: string) {
this.$emit('drop', data);
},
setFocus() {
async setFocus() {
if (['json'].includes(this.parameter.type) && this.getArgument('alwaysOpenEditWindow')) {
this.displayEditDialog();
return;
Expand All @@ -991,14 +991,13 @@ export default defineComponent({
this.nodeName = this.node.name;
}

void this.$nextTick(() => {
await this.$nextTick();
// @ts-ignore
if (this.$refs.inputField?.focus && this.$refs.inputField?.$el) {
// @ts-ignore
if (this.$refs.inputField?.focus && this.$refs.inputField?.$el) {
// @ts-ignore
this.$refs.inputField.focus();
this.isFocused = true;
}
});
this.$refs.inputField.focus();
this.isFocused = true;
}

this.$emit('focus');
},
Expand Down Expand Up @@ -1082,7 +1081,7 @@ export default defineComponent({
});
}
},
optionSelected(command: string) {
async optionSelected(command: string) {
const prevValue = this.modelValue;

if (command === 'resetValue') {
Expand All @@ -1109,7 +1108,7 @@ export default defineComponent({
this.valueChanged(`=${this.modelValue}`);
}

this.setFocus();
await this.setFocus();
} else if (command === 'removeExpression') {
let value: NodeParameterValueType = this.expressionEvaluated;

Expand Down Expand Up @@ -1161,14 +1160,13 @@ export default defineComponent({
}
},
},
updated() {
void this.$nextTick(() => {
const remoteParameterOptions = this.$el.querySelectorAll('.remote-parameter-option');
async updated() {
await this.$nextTick();
const remoteParameterOptions = this.$el.querySelectorAll('.remote-parameter-option');

if (remoteParameterOptions.length > 0) {
void this.$externalHooks().run('parameterInput.updated', { remoteParameterOptions });
}
});
if (remoteParameterOptions.length > 0) {
void this.$externalHooks().run('parameterInput.updated', { remoteParameterOptions });
}
},
mounted() {
this.eventBus.on('optionSelected', this.optionSelected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export default defineComponent({
onTypeSelectInput(destinationType: MessageEventBusDestinationTypeNames) {
this.typeSelectValue = destinationType;
},
onContinueAddClicked() {
async onContinueAddClicked() {
let newDestination;
switch (this.typeSelectValue) {
case MessageEventBusDestinationTypeNames.syslog:
Expand All @@ -378,9 +378,8 @@ export default defineComponent({

if (newDestination) {
this.headerLabel = newDestination?.label ?? this.headerLabel;
void nextTick(() => {
this.setupNode(newDestination);
});
await nextTick();
this.setupNode(newDestination);
}
},
valueChanged(parameterData: IUpdateInformation) {
Expand Down
9 changes: 4 additions & 5 deletions packages/editor-ui/src/components/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@ export default defineComponent({
};
},
methods: {
deleteNode() {
void this.$nextTick(() => {
// Wait a tick else vue causes problems because the data is gone
this.$emit('removeNode', this.data.name);
});
async deleteNode() {
// Wait a tick else vue causes problems because the data is gone
await this.$nextTick();
this.$emit('removeNode', this.data.name);
},
onEdit(edit: boolean) {
if (edit && !this.isActive && this.node) {
Expand Down
7 changes: 3 additions & 4 deletions packages/editor-ui/src/components/TextEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ export default defineComponent({
this.tempValue = this.modelValue as string;
},
watch: {
dialogVisible() {
async dialogVisible() {
if (this.dialogVisible === true) {
void nextTick(() => {
(this.$refs.inputField as HTMLInputElement).focus();
});
await nextTick();
(this.$refs.inputField as HTMLInputElement).focus();
}
},
modelValue(value: string) {
Expand Down
11 changes: 5 additions & 6 deletions packages/editor-ui/src/components/VariablesRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ const valueValidationRules: Array<Rule | RuleGroup> = [

watch(
() => modelValue.value.key,
() => {
void nextTick(() => {
if (formValidationStatus.value.key) {
updateUsageSyntax();
}
});
async () => {
await nextTick();
if (formValidationStatus.value.key) {
updateUsageSyntax();
}
},
);

Expand Down
Loading
Loading