mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-20 01:21:55 +03:00
Fix test suite and test run default selection (#7250)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
parent
163c8ec373
commit
e0f2c87ed3
@ -107,7 +107,7 @@
|
||||
throw new Error('Failed to create test run')
|
||||
} else {
|
||||
Analytics.handleEvent(TestManagementEvents.TestRunCreated, { id })
|
||||
navigate(getTestRunsLink(id))
|
||||
navigate(getTestRunsLink(space, id))
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error(err)
|
||||
|
@ -79,10 +79,12 @@ export function getTestSuiteIdFromLocation (): Ref<TestSuite> {
|
||||
return (location?.query?.[SUITE_KEY] as Ref<TestSuite>) ?? testManagement.ids.NoParent
|
||||
}
|
||||
|
||||
export function getTestRunsLink (parentDoc: Ref<Doc>): Location {
|
||||
export function getTestRunsLink (space: Ref<TestProject>, parentDoc: Ref<Doc>): Location {
|
||||
const loc = getCurrentResolvedLocation()
|
||||
loc.path.length = 4
|
||||
loc.path[3] = 'testRuns'
|
||||
loc.path.length = 5
|
||||
loc.path[2] = testManagementId
|
||||
loc.path[3] = space
|
||||
loc.path[4] = 'testRuns'
|
||||
loc.fragment = undefined
|
||||
loc.query = parentDoc === undefined ? undefined : { attachedTo: parentDoc }
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
<script lang="ts">
|
||||
import { Class, Doc, DocumentQuery, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Action, IconEdit, navigate, type Location, Scroller } from '@hcengineering/ui'
|
||||
import { Action, IconEdit, navigate, type Location, Scroller, location, getLocation } from '@hcengineering/ui'
|
||||
import { getResource, type Resource } from '@hcengineering/platform'
|
||||
import { IntlString, Asset } from '@hcengineering/platform'
|
||||
|
||||
@ -34,6 +34,10 @@
|
||||
export let allObjectsLabel: IntlString
|
||||
export let plainList: boolean = false
|
||||
|
||||
const getFolderId = (): Ref<Doc> => {
|
||||
return (getLocation()?.query?.attachedTo as Ref<Doc>) ?? noParentId
|
||||
}
|
||||
|
||||
export let forciblyСollapsed: boolean = false
|
||||
|
||||
const client = getClient()
|
||||
@ -46,17 +50,23 @@
|
||||
foldersState = newState
|
||||
})
|
||||
|
||||
let selected: Ref<Doc> = noParentId
|
||||
let visibleItem: Doc | undefined
|
||||
let selected: Ref<Doc> = getFolderId()
|
||||
let visibleItem: Doc | undefined = foldersState.folderById.get(selected)
|
||||
location.subscribe(() => {
|
||||
selected = getFolderId()
|
||||
visibleItem = foldersState.folderById.get(selected)
|
||||
})
|
||||
|
||||
const q = createQuery()
|
||||
q.query(
|
||||
_class,
|
||||
query ?? {},
|
||||
(result) => {
|
||||
async (result) => {
|
||||
foldersManager.setFolders(result)
|
||||
if (plainList && foldersState.folders?.length > 0) {
|
||||
handleFolderSelected(foldersState.folders[0])
|
||||
if (selected === undefined) {
|
||||
await handleFolderSelected(foldersState.folders[0])
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -67,17 +77,12 @@
|
||||
)
|
||||
|
||||
async function handleFolderSelected (_id: Ref<Doc>): Promise<void> {
|
||||
selected = _id
|
||||
visibleItem = selected !== undefined ? foldersState.folderById.get(selected) : undefined
|
||||
const getFolderLinkFunction = await getResource(getFolderLink)
|
||||
navigate(getFolderLinkFunction(_id))
|
||||
}
|
||||
|
||||
async function handleAllItemsSelected (): Promise<void> {
|
||||
selected = noParentId
|
||||
visibleItem = undefined
|
||||
const getFolderLinkFunction = await getResource(getFolderLink)
|
||||
navigate(getFolderLinkFunction(undefined))
|
||||
await handleFolderSelected(noParentId)
|
||||
}
|
||||
|
||||
async function getFolderActions (obj: Doc): Promise<Action[]> {
|
||||
@ -119,8 +124,8 @@
|
||||
descendants={foldersState.descendants}
|
||||
folderById={foldersState.folderById}
|
||||
{selected}
|
||||
on:selected={(ev) => {
|
||||
handleFolderSelected(ev.detail)
|
||||
on:selected={async (ev) => {
|
||||
await handleFolderSelected(ev.detail)
|
||||
}}
|
||||
/>
|
||||
<svelte:fragment slot="visible">
|
||||
@ -147,8 +152,8 @@
|
||||
descendants={foldersState.descendants}
|
||||
folderById={foldersState.folderById}
|
||||
{selected}
|
||||
on:selected={(ev) => {
|
||||
handleFolderSelected(ev.detail)
|
||||
on:selected={async (ev) => {
|
||||
await handleFolderSelected(ev.detail)
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
Loading…
Reference in New Issue
Block a user