UBERF-8628: Disable run button if there is nothing to run (#7277)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko 2024-12-06 18:00:47 +07:00 committed by GitHub
parent 596185bd5c
commit 34daf3a7f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,10 +13,11 @@
// limitations under the License.
-->
<script lang="ts">
import { Doc, DocumentQuery, Ref, Space } from '@hcengineering/core'
import { Doc, DocumentQuery, Ref, Space, mergeQueries } from '@hcengineering/core'
import { Button } from '@hcengineering/ui'
import { selectionStore } from '@hcengineering/view-resources'
import type { TestCase, TestProject } from '@hcengineering/test-management'
import { createQuery } from '@hcengineering/presentation'
import testManagement from '../../plugin'
import { showCreateTestRunPopup } from '../../utils'
@ -24,6 +25,19 @@
export let query: DocumentQuery<Doc> = {}
export let space: Ref<Space>
const docQuery = createQuery()
let haveTestCases = false
$: resultQuery = mergeQueries(query, { space })
$: docQuery.query(
testManagement.class.TestCase,
resultQuery,
(res) => {
haveTestCases = res.length > 0
},
{ limit: 1 }
)
const project: Ref<TestProject> = space as any
const handleRun = async (): Promise<void> => {
@ -42,5 +56,6 @@
justify={'left'}
kind={'primary'}
label={testManagement.string.RunTestCases}
disabled={!haveTestCases}
on:click={handleRun}
/>