mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Make sure auto loading and auto scrolling works in executions tab (#9505)
This commit is contained in:
parent
8164ca2398
commit
3a2e5455a9
|
@ -71,6 +71,45 @@ describe('Current Workflow Executions', () => {
|
||||||
cy.wait(executionsRefreshInterval);
|
cy.wait(executionsRefreshInterval);
|
||||||
cy.url().should('not.include', '/executions');
|
cy.url().should('not.include', '/executions');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('should auto load more items if there is space and auto scroll', () => {
|
||||||
|
cy.viewport(1280, 960);
|
||||||
|
executionsTab.actions.createManualExecutions(24);
|
||||||
|
|
||||||
|
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
|
||||||
|
cy.intercept('GET', '/rest/executions/*').as('getExecution');
|
||||||
|
executionsTab.actions.switchToExecutionsTab();
|
||||||
|
|
||||||
|
cy.wait(['@getExecutions']);
|
||||||
|
executionsTab.getters.executionListItems().its('length').should('be.gte', 10);
|
||||||
|
|
||||||
|
cy.getByTestId('current-executions-list').scrollTo('bottom');
|
||||||
|
cy.wait(['@getExecutions']);
|
||||||
|
executionsTab.getters.executionListItems().should('have.length', 24);
|
||||||
|
|
||||||
|
executionsTab.getters.executionListItems().eq(14).click();
|
||||||
|
cy.wait(['@getExecution']);
|
||||||
|
cy.reload();
|
||||||
|
|
||||||
|
cy.wait(['@getExecutions']);
|
||||||
|
executionsTab.getters.executionListItems().eq(14).should('not.be.visible');
|
||||||
|
executionsTab.getters.executionListItems().should('have.length', 24);
|
||||||
|
executionsTab.getters.executionListItems().first().should('not.be.visible');
|
||||||
|
cy.getByTestId('current-executions-list').scrollTo(0, 0);
|
||||||
|
executionsTab.getters.executionListItems().first().should('be.visible');
|
||||||
|
executionsTab.getters.executionListItems().eq(14).should('not.be.visible');
|
||||||
|
|
||||||
|
executionsTab.actions.switchToEditorTab();
|
||||||
|
executionsTab.actions.switchToExecutionsTab();
|
||||||
|
|
||||||
|
cy.wait(['@getExecutions']);
|
||||||
|
executionsTab.getters.executionListItems().eq(14).should('not.be.visible');
|
||||||
|
executionsTab.getters.executionListItems().should('have.length', 24);
|
||||||
|
executionsTab.getters.executionListItems().first().should('not.be.visible');
|
||||||
|
cy.getByTestId('current-executions-list').scrollTo(0, 0);
|
||||||
|
executionsTab.getters.executionListItems().first().should('be.visible');
|
||||||
|
executionsTab.getters.executionListItems().eq(14).should('not.be.visible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const createMockExecutions = () => {
|
const createMockExecutions = () => {
|
||||||
|
|
|
@ -110,6 +110,7 @@ export default defineComponent({
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
emits: ['retryExecution', 'mounted'],
|
||||||
setup() {
|
setup() {
|
||||||
const executionHelpers = useExecutionHelpers();
|
const executionHelpers = useExecutionHelpers();
|
||||||
|
|
||||||
|
@ -147,6 +148,9 @@ export default defineComponent({
|
||||||
return VIEWS.EXECUTION_PREVIEW;
|
return VIEWS.EXECUTION_PREVIEW;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$emit('mounted', this.execution.id);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onRetryMenuItemSelect(action: string): void {
|
onRetryMenuItemSelect(action: string): void {
|
||||||
this.$emit('retryExecution', { execution: this.execution, command: action });
|
this.$emit('retryExecution', { execution: this.execution, command: action });
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
:execution="execution"
|
:execution="execution"
|
||||||
:data-test-id="`execution-details-${execution.id}`"
|
:data-test-id="`execution-details-${execution.id}`"
|
||||||
@retry-execution="onRetryExecution"
|
@retry-execution="onRetryExecution"
|
||||||
|
@mounted="onItemMounted"
|
||||||
/>
|
/>
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
<div v-if="loadingMore" class="mr-m">
|
<div v-if="loadingMore" class="mr-m">
|
||||||
|
@ -80,6 +81,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
import type { ExecutionFilterType } from '@/Interface';
|
import type { ExecutionFilterType } from '@/Interface';
|
||||||
|
|
||||||
type WorkflowExecutionsCardRef = InstanceType<typeof WorkflowExecutionsCard>;
|
type WorkflowExecutionsCardRef = InstanceType<typeof WorkflowExecutionsCard>;
|
||||||
|
type AutoScrollDeps = { activeExecutionSet: boolean; cardsMounted: boolean; scroll: boolean };
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'WorkflowExecutionsSidebar',
|
name: 'WorkflowExecutionsSidebar',
|
||||||
|
@ -117,6 +119,12 @@ export default defineComponent({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
filter: {} as ExecutionFilterType,
|
filter: {} as ExecutionFilterType,
|
||||||
|
mountedItems: [] as string[],
|
||||||
|
autoScrollDeps: {
|
||||||
|
activeExecutionSet: false,
|
||||||
|
cardsMounted: false,
|
||||||
|
scroll: true,
|
||||||
|
} as AutoScrollDeps,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -129,16 +137,35 @@ export default defineComponent({
|
||||||
this.$router.go(-1);
|
this.$router.go(-1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'executionsStore.activeExecution'(
|
||||||
|
newValue: ExecutionSummary | null,
|
||||||
|
oldValue: ExecutionSummary | null,
|
||||||
|
) {
|
||||||
|
if (newValue && newValue.id !== oldValue?.id) {
|
||||||
|
this.autoScrollDeps.activeExecutionSet = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
autoScrollDeps: {
|
||||||
// On larger screens, we need to load more then first page of executions
|
handler(updatedDeps: AutoScrollDeps) {
|
||||||
// for the scroll bar to appear and infinite scrolling is enabled
|
if (Object.values(updatedDeps).every(Boolean)) {
|
||||||
this.checkListSize();
|
|
||||||
setTimeout(() => {
|
|
||||||
this.scrollToActiveCard();
|
this.scrollToActiveCard();
|
||||||
}, 1000);
|
}
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onItemMounted(id: string): void {
|
||||||
|
this.mountedItems.push(id);
|
||||||
|
if (this.mountedItems.length === this.executions.length) {
|
||||||
|
this.autoScrollDeps.cardsMounted = true;
|
||||||
|
this.checkListSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.executionsStore.activeExecution?.id === id) {
|
||||||
|
this.autoScrollDeps.activeExecutionSet = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
loadMore(limit = 20): void {
|
loadMore(limit = 20): void {
|
||||||
if (!this.loading) {
|
if (!this.loading) {
|
||||||
const executionsListRef = this.$refs.executionList as HTMLElement | undefined;
|
const executionsListRef = this.$refs.executionList as HTMLElement | undefined;
|
||||||
|
@ -167,7 +194,7 @@ export default defineComponent({
|
||||||
checkListSize(): void {
|
checkListSize(): void {
|
||||||
const sidebarContainerRef = this.$refs.container as HTMLElement | undefined;
|
const sidebarContainerRef = this.$refs.container as HTMLElement | undefined;
|
||||||
const currentWorkflowExecutionsCardRefs = this.$refs[
|
const currentWorkflowExecutionsCardRefs = this.$refs[
|
||||||
`execution-${this.executionsStore.activeExecution?.id}`
|
`execution-${this.mountedItems[this.mountedItems.length - 1]}`
|
||||||
] as WorkflowExecutionsCardRef[] | undefined;
|
] as WorkflowExecutionsCardRef[] | undefined;
|
||||||
|
|
||||||
// Find out how many execution card can fit into list
|
// Find out how many execution card can fit into list
|
||||||
|
@ -196,7 +223,11 @@ export default defineComponent({
|
||||||
const cardRect = cardElement.getBoundingClientRect();
|
const cardRect = cardElement.getBoundingClientRect();
|
||||||
const LIST_HEADER_OFFSET = 200;
|
const LIST_HEADER_OFFSET = 200;
|
||||||
if (cardRect.top > executionsListRef.offsetHeight) {
|
if (cardRect.top > executionsListRef.offsetHeight) {
|
||||||
executionsListRef.scrollTo({ top: cardRect.top - LIST_HEADER_OFFSET });
|
this.autoScrollDeps.scroll = false;
|
||||||
|
executionsListRef.scrollTo({
|
||||||
|
top: cardRect.top - LIST_HEADER_OFFSET,
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue