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

feat(ui): add initializing explorer logic #5941

Merged
merged 4 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions packages/ui/client/components/explorer/Explorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ useResizeObserver(testExplorerRef, (entries) => {
</div>
<div class="scrolls" flex-auto py-1 @scroll.passive="hideAllPoppers">
<DetailsPanel>
<template #summary>
<template v-if="initialized" #summary>
<div grid="~ items-center gap-x-1 cols-[auto_min-content_auto] rows-[min-content_min-content]">
<span text-red5>
FAIL ({{ testsTotal.failed }})
Expand All @@ -141,7 +141,7 @@ useResizeObserver(testExplorerRef, (entries) => {
</template>
<!-- empty-state -->
<template v-if="(isFiltered || isFilteredByStatus) && uiEntries.length === 0">
<div v-show="initialized" flex="~ col" items-center p="x4 y4" font-light>
<div v-if="initialized" flex="~ col" items-center p="x4 y4" font-light>
<div op30>
No matched test
</div>
Expand Down Expand Up @@ -186,6 +186,12 @@ useResizeObserver(testExplorerRef, (entries) => {
Clear All
</button>
</div>
<div v-else flex="~ col" items-center p="x4 y4" font-light>
<div class="i-carbon:circle-dash animate-spin" />
<div op30>
Loading...
</div>
</div>
</template>
<template v-else>
<RecycleScroller
Expand Down
19 changes: 16 additions & 3 deletions packages/ui/client/composables/explorer/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
isRunningTestNode,
} from '~/composables/explorer/utils'
import { isSuite } from '~/utils/task'
import { openedTreeItems, treeFilter, uiEntries, uiFiles } from '~/composables/explorer/state'
import {
initialized,
openedTreeItems,
treeFilter,
uiEntries,
uiFiles,
} from '~/composables/explorer/state'
import { explorerTree } from '~/composables/explorer/index'
import { expandNodesOnEndRun } from '~/composables/explorer/expand'

Expand Down Expand Up @@ -161,8 +167,6 @@ function doRunFilter(
filter: Filter,
end = false,
) {
// refresh explorer

const expandAll = treeFilter.value.expandAll
const resetExpandAll = expandAll !== true
const ids = new Set(openedTreeItems.value)
Expand All @@ -173,6 +177,15 @@ function doRunFilter(
refreshExplorer(search, filter, end)
})

// initialize the explorer
if (!initialized.value) {
queueMicrotask(() => {
if (uiEntries.value.length || end) {
initialized.value = true
}
})
}

if (applyExpandNodes) {
// expand all nodes
queueMicrotask(() => {
Expand Down
4 changes: 0 additions & 4 deletions packages/ui/client/composables/explorer/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ export function useSearch(searchBox: Ref<HTMLDivElement | undefined>) {
}
}, { flush: 'post' })

onMounted(() => {
nextTick(() => (initialized.value = true))
})

return {
initialized,
filter,
Expand Down
Loading