Skip to content

Commit bd1d820

Browse files
committed
simplify icons architecture
1 parent 89f6a17 commit bd1d820

File tree

6 files changed

+74
-102
lines changed

6 files changed

+74
-102
lines changed

packages/app/src/pages/Runs.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ query Runs {
3838
cloudProject {
3939
id
4040
runs(first: 10){
41-
id
42-
...RunsCard
41+
nodes {
42+
id
43+
...RunCard
44+
}
4345
}
4446
}
4547
}

packages/app/src/runs/RunCard.vue

+22-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
class="block w-full overflow-hidden mb-4 border border-gray-100
44
rounded bg-light-50 hocus-default"
55
>
6-
<ListRowHeader>
7-
<template #icon>
8-
<RunIcon :gql="props.gql" />
9-
</template>
6+
<ListRowHeader :icon="icon">
107
<template #header>
118
{{ run.commitInfo?.summary }}
129
</template>
@@ -48,18 +45,22 @@
4845
</template>
4946

5047
<script lang="ts" setup>
48+
import { computed } from 'vue'
5149
import ListRowHeader from '@cy/components/ListRowHeader.vue'
5250
import { gql } from '@urql/core'
53-
import RunIcon from './RunIcon.vue'
5451
import RunResults from './RunResults.vue'
5552
import type { RunCardFragment } from '../generated/graphql'
56-
import { computed } from 'vue-demi'
53+
import PassedIcon from '~icons/cy/status-passed-solid_x24.svg'
54+
import FailedIcon from '~icons/cy/status-failed-solid_x24.svg'
55+
import ErroredIcon from '~icons/cy/status-errored-solid_x24.svg'
56+
import SkippedIcon from '~icons/cy/status-skipped_x24.svg'
57+
import PendingIcon from '~icons/cy/status-pending_x24.svg'
5758
5859
gql`
5960
fragment RunCard on CloudRun {
6061
id
6162
createdAt
62-
...RunIcon
63+
status
6364
...RunResults
6465
commitInfo {
6566
authorName
@@ -74,6 +75,20 @@ const props = defineProps<{
7475
gql: RunCardFragment
7576
}>()
7677
78+
const icon = computed(() => {
79+
return props.gql.status === 'PASSED'
80+
? PassedIcon
81+
: props.gql.status === 'FAILED'
82+
? FailedIcon
83+
: props.gql.status === 'TIMEDOUT' || props.gql.status === 'ERRORED' || props.gql.status === 'OVERLIMIT'
84+
? ErroredIcon
85+
: props.gql.status === 'CANCELLED' || props.gql.status === 'NOTESTS'
86+
? SkippedIcon
87+
: props.gql.status === 'RUNNING'
88+
? PendingIcon
89+
: undefined
90+
})
91+
7792
const run = computed(() => props.gql)
7893
7994
</script>

packages/app/src/runs/RunIcon.spec.tsx

-19
This file was deleted.

packages/app/src/runs/RunIcon.vue

-49
This file was deleted.

packages/app/src/runs/RunResults.vue

+46-24
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
<template>
22
<div class="flex h-6 text-gray-500 border border-gray-200 rounded text-size-14px leading-20px">
3-
<div class="flex items-center px-2 hover:bg-indigo-50">
4-
<i-cy-status-flaky_x12 class="mr-1 h-12px w-12px icon-dark-gray-400" />
5-
0
6-
<!--
7-
TODO: Is flake even exposed via the API?
8-
{{props.gql.totalFlake}}
9-
-->
10-
</div>
11-
<div class="flex items-center px-2 hover:bg-indigo-50">
12-
<i-cy-status-skipped_x12 class="mr-1 h-12px w-12px icon-dark-gray-400" />
13-
{{ props.gql.totalSkipped }}
14-
</div>
15-
<div class="flex items-center px-2 hover:bg-indigo-50">
16-
<i-cy-status-pending_x12 class="mr-1 h-12px w-12px icon-dark-gray-400 icon-light-white" />
17-
{{ props.gql.totalPending }}
18-
</div>
19-
<div class="flex items-center px-2 hover:bg-indigo-50">
20-
<i-cy-status-passed_x12 class="mr-1 h-12px w-12px icon-dark-jade-400" />
21-
{{ props.gql.totalPassed }}
22-
</div>
23-
<div class="flex items-center px-2 hover:bg-indigo-50">
24-
<i-cy-status-failed_x12 class="mr-1 h-12px w-12px icon-dark-red-400" />
25-
{{ props.gql.totalFailed }}
3+
<div
4+
v-for="(result, i) in results"
5+
:key="i"
6+
class="flex items-center px-2 hover:bg-indigo-50"
7+
>
8+
<component
9+
:is="result.icon"
10+
class="mr-1 h-12px w-12px"
11+
:class="result.color"
12+
/>
13+
{{ result.value }}
2614
</div>
2715
</div>
2816
</template>
2917

3018
<script lang="ts" setup>
3119
import type { RunResultsFragment } from '../generated/graphql'
3220
import { gql } from '@urql/core'
21+
import FlakyIcon from '~icons/cy/status-flaky_x12.svg'
22+
import SkippedIcon from '~icons/cy/status-skipped_x12.svg'
23+
import PassedIcon from '~icons/cy/status-passed_x12.svg'
24+
import FailedIcon from '~icons/cy/status-failed_x12.svg'
25+
import PendingIcon from '~icons/cy/status-pending_x12.svg'
3326
3427
gql`
3528
fragment RunResults on CloudRun {
@@ -38,11 +31,40 @@ fragment RunResults on CloudRun {
3831
totalFailed
3932
totalPending
4033
totalSkipped
41-
totalDuration
4234
}
4335
`
4436
4537
const props = defineProps<{
4638
gql: RunResultsFragment
4739
}>()
40+
41+
const results = [
42+
{
43+
// TODO: Is flake even exposed via the API?
44+
// value: props.gql.totalFlaky,
45+
value: 0,
46+
color: 'icon-dark-gray-400',
47+
icon: FlakyIcon,
48+
},
49+
{
50+
value: props.gql.totalSkipped,
51+
color: 'icon-dark-gray-400',
52+
icon: SkippedIcon,
53+
},
54+
{
55+
value: props.gql.totalPending,
56+
color: 'icon-dark-gray-400 icon-light-white',
57+
icon: PendingIcon,
58+
},
59+
{
60+
value: props.gql.totalPassed,
61+
color: 'icon-dark-jade-400',
62+
icon: PassedIcon,
63+
},
64+
{
65+
value: props.gql.totalFailed,
66+
color: 'icon-dark-red-400',
67+
icon: FailedIcon,
68+
},
69+
]
4870
</script>

packages/app/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"index.d.ts",
1010
"../frontend-shared/src/**/*.vue",
1111
"../frontend-shared/src/**/*.tsx",
12-
"../frontend-shared/cypress/**/*.ts"
12+
"../frontend-shared/cypress/**/*.ts",
13+
"*.d.ts"
1314
],
1415
"compilerOptions": {
1516
"noImplicitThis": true,

0 commit comments

Comments
 (0)