-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
DebugRunNavigationRow.vue
103 lines (90 loc) · 2.95 KB
/
DebugRunNavigationRow.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<template>
<li
class="mr-[12px] ml-[6px] "
:data-cy="isCurrentRun ? 'current-run' : 'run'"
>
<component
:is="isCurrentRun ? 'div': 'button'"
:aria-label="t('debugPage.switchToRun', {runNumber: gql.runNumber})"
class="rounded flex w-full p-[10px] pl-[35px] relative hocus:bg-indigo-50 focus:outline focus:outline-indigo-500"
:class="{ 'bg-indigo-50': isCurrentRun }"
@click="$emit('changeRun')"
>
<DebugCurrentRunIcon
v-if="isCurrentRun"
class="top-[18px] left-[12px] absolute"
data-cy="current-run-check"
/>
<div
:data-cy="`run-${props.gql.runNumber}`"
class="flex items-center justify-between w-full"
>
<div class="flex items-center min-w-0">
<DebugRunNumber
v-if="props.gql.status && props.gql.runNumber"
:status="props.gql.status"
:value="props.gql.runNumber"
class="mr-[8px]"
/>
<DebugResults
v-if="props.gql"
:gql="props.gql"
class="bg-white"
/>
<Dot />
<LightText class="truncate">
{{ specsCompleted }}
</LightText>
</div>
<LightText class="shrink-0 ml-[8px]">
{{ totalDuration }} ({{ relativeCreatedAt }})
</LightText>
</div>
</component>
</li>
</template>
<script lang="ts" setup>
import { gql } from '@urql/vue'
import DebugRunNumber from './DebugRunNumber.vue'
import DebugCurrentRunIcon from './DebugCurrentRunIcon.vue'
import type { DebugProgress_DebugTestsFragment } from '../generated/graphql'
import { computed, FunctionalComponent, h } from 'vue'
import DebugResults from './DebugResults.vue'
import { useDebugRunSummary } from './useDebugRunSummary'
import { useRunDateTimeInterval } from './useRunDateTimeInterval'
import { useI18n } from '@cy/i18n'
const { t } = useI18n()
const props = defineProps<{
gql: DebugProgress_DebugTestsFragment
isCurrentRun: boolean
}>()
defineEmits<{
(event: 'changeRun'): void
}>()
gql`
fragment DebugProgress_DebugTests on CloudRun {
id
runNumber
totalDuration
createdAt
status
completedInstanceCount
totalInstanceCount
...DebugResults
}`
const Dot: FunctionalComponent = () => {
return h('span', { class: 'px-[8px] text-gray-300' }, '•')
}
useDebugRunSummary(props.gql)
const LightText: FunctionalComponent = (_props, { slots }) => {
return h('span', { class: 'text-sm text-gray-700' }, slots?.default?.())
}
const run = computed(() => props.gql)
const { relativeCreatedAt, totalDuration } = useRunDateTimeInterval(run)
const specsCompleted = computed(() => {
if (props.gql.status === 'RUNNING') {
return t('debugPage.specCounts.whenRunning', { n: props.gql.totalInstanceCount || 0, completed: props.gql.completedInstanceCount || 0, total: props.gql.totalInstanceCount || 0 })
}
return t('debugPage.specCounts.whenCompleted', { n: props.gql.totalInstanceCount || 0 })
})
</script>