-
Notifications
You must be signed in to change notification settings - Fork 9k
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): Make sure auto loading and auto scrolling works in executions tab #9505
Merged
cstuncsik
merged 3 commits into
master
from
pay-1584-executions-view-on-single-workflow-limited-to-10
May 27, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
:execution="execution" | ||
:data-test-id="`execution-details-${execution.id}`" | ||
@retry-execution="onRetryExecution" | ||
@mounted="onItemMounted" | ||
/> | ||
</TransitionGroup> | ||
<div v-if="loadingMore" class="mr-m"> | ||
|
@@ -80,6 +81,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store'; | |
import type { ExecutionFilterType } from '@/Interface'; | ||
|
||
type WorkflowExecutionsCardRef = InstanceType<typeof WorkflowExecutionsCard>; | ||
type AutoScrollDeps = { activeExecutionSet: boolean; cardsMounted: boolean; scroll: boolean }; | ||
|
||
export default defineComponent({ | ||
name: 'WorkflowExecutionsSidebar', | ||
|
@@ -117,6 +119,12 @@ export default defineComponent({ | |
data() { | ||
return { | ||
filter: {} as ExecutionFilterType, | ||
mountedItems: [] as string[], | ||
autoScrollDeps: { | ||
activeExecutionSet: false, | ||
cardsMounted: false, | ||
scroll: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I find this name to be a bit unclear. Can we elaborate a bit more what this flag is doing (better name, or just a comment)? |
||
} as AutoScrollDeps, | ||
}; | ||
}, | ||
computed: { | ||
|
@@ -129,16 +137,35 @@ export default defineComponent({ | |
this.$router.go(-1); | ||
} | ||
}, | ||
}, | ||
mounted() { | ||
// On larger screens, we need to load more then first page of executions | ||
// for the scroll bar to appear and infinite scrolling is enabled | ||
this.checkListSize(); | ||
setTimeout(() => { | ||
this.scrollToActiveCard(); | ||
}, 1000); | ||
'executionsStore.activeExecution'( | ||
newValue: ExecutionSummary | null, | ||
oldValue: ExecutionSummary | null, | ||
) { | ||
if (newValue && newValue.id !== oldValue?.id) { | ||
this.autoScrollDeps.activeExecutionSet = true; | ||
} | ||
}, | ||
autoScrollDeps: { | ||
handler(updatedDeps: AutoScrollDeps) { | ||
if (Object.values(updatedDeps).every(Boolean)) { | ||
this.scrollToActiveCard(); | ||
} | ||
}, | ||
deep: true, | ||
}, | ||
}, | ||
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 { | ||
if (!this.loading) { | ||
const executionsListRef = this.$refs.executionList as HTMLElement | undefined; | ||
|
@@ -167,7 +194,7 @@ export default defineComponent({ | |
checkListSize(): void { | ||
const sidebarContainerRef = this.$refs.container as HTMLElement | undefined; | ||
const currentWorkflowExecutionsCardRefs = this.$refs[ | ||
`execution-${this.executionsStore.activeExecution?.id}` | ||
`execution-${this.mountedItems[this.mountedItems.length - 1]}` | ||
] as WorkflowExecutionsCardRef[] | undefined; | ||
|
||
// Find out how many execution card can fit into list | ||
|
@@ -196,7 +223,11 @@ export default defineComponent({ | |
const cardRect = cardElement.getBoundingClientRect(); | ||
const LIST_HEADER_OFFSET = 200; | ||
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', | ||
}); | ||
} | ||
} | ||
}, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we only care about number of mounted cards here, so can we just track that instead of keeping the list of ids (I guess it will be a bit more performant for longer lists)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it could be just a counter but I need to get a workflow card ref by its ID and since it is used in other places (it is needed for the auto scroll) I didn't want to change the ref so it seemed better to collect the IDs
I don't think it will cause a performance issue, you would have to have like 100K (or a million) of IDs stored in the array, I don't think we will ever have that