Skip to content

Commit d61c1af

Browse files
committed
feat: update MutationListItem styling and enhance mutation details display
1 parent a2aa6e5 commit d61c1af

File tree

4 files changed

+87
-19
lines changed

4 files changed

+87
-19
lines changed

client/app/components/MutationListItem.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ defineEmits(['click'])
1010

1111
<template>
1212
<div
13-
class="flex flex-col p-2 overflow-hidden hover-bg-active cursor-pointer border-b border-gray-100 dark:border-gray-800"
13+
class="grid gap-2 px-2 text-secondary hover:n-bg-hover cursor-pointer truncate max-w-full"
14+
:style="{
15+
'grid-template-columns': '1em 1fr',
16+
}"
1417
@click="$emit('click')"
1518
>
16-
<div class="flex items-center gap-2">
17-
<span
18-
class="rounded whitespace-nowrap select-none mx-0.5 px-1.5 py-0.5"
19-
:style="{
20-
'background-color': `${getMutationBackgroundColor(item)}`,
21-
}"
22-
>
23-
{{ getMutationStatusLabel(item) }}
24-
</span>
25-
<div class="truncate font-mono text-sm opacity-75">
26-
{{ item.options.mutationKey || 'Anonymous' }}
27-
</div>
19+
<div
20+
:style="{
21+
'width': '1em',
22+
'height': '1em',
23+
'border-radius': '10%',
24+
'align-self': 'center',
25+
'background-color': getMutationBackgroundColor(item),
26+
}"
27+
/>
28+
<div>
29+
{{ item.options.mutationKey || 'No mutation key provided' }}
2830
</div>
2931
</div>
3032
</template>

client/app/pages/vue-query.vue

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ function handleRestoreTriggerLoading(query: Query) {
466466
class="w-full"
467467
>
468468
<NSectionBlock
469-
icon="carbon-mutation"
469+
icon="carbon-status-change"
470470
text="Mutation Overview"
471471
:padding="true"
472472
>
@@ -490,6 +490,71 @@ function handleRestoreTriggerLoading(query: Query) {
490490
{{ getMutationStatusLabel(selectedMutation as Mutation) }}
491491
</span>
492492
</div>
493+
<div>
494+
<strong>Submitted:</strong>
495+
</div>
496+
<div>
497+
{{ new Date(selectedMutation.state.submittedAt).toLocaleString() }}
498+
</div>
499+
</div>
500+
</NSectionBlock>
501+
<NSectionBlock
502+
icon="carbon-cube"
503+
text="Data Explorer"
504+
:padding="true"
505+
:open="false"
506+
>
507+
<VueJsonPretty
508+
:data="selectedMutation.state.data"
509+
:deep="2"
510+
:virtual="true"
511+
:height="150"
512+
/>
513+
</NSectionBlock>
514+
<NSectionBlock
515+
icon="carbon-query-queue"
516+
text="Mutation Details"
517+
:padding="true"
518+
>
519+
<div class="grid grid-cols-[auto_1fr] gap-1 px-2 py-2">
520+
<div><strong>Status:</strong></div>
521+
<div>
522+
{{ selectedMutation.state.status }}
523+
</div>
524+
<div><strong>Mutation Id:</strong></div>
525+
<div>
526+
{{ selectedMutation.mutationId }}
527+
</div>
528+
<div><strong>IsPaused:</strong></div>
529+
<div>
530+
{{ selectedMutation.state.isPaused }}
531+
</div>
532+
<div><strong>Failure Count:</strong></div>
533+
<div>
534+
{{ selectedMutation.state.failureCount }}
535+
</div>
536+
<div><strong>Failure Reason:</strong></div>
537+
<div>
538+
{{ selectedMutation.state.failureReason }}
539+
</div>
540+
<div><strong>GCTime:</strong></div>
541+
<div>
542+
{{ selectedMutation.gcTime }}
543+
</div>
544+
<div><strong>Variables:</strong></div>
545+
<VueJsonPretty
546+
:data="toRaw(selectedMutation)?.state?.variables"
547+
:deep="2"
548+
:virtual="true"
549+
:height="150"
550+
/>
551+
<div><strong>Meta:</strong></div>
552+
<VueJsonPretty
553+
:data="toRaw(selectedMutation)?.meta"
554+
:deep="2"
555+
:virtual="true"
556+
:height="150"
557+
/>
493558
</div>
494559
</NSectionBlock>
495560
</div>

client/app/utils/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export function getMutationStatusLabel(mutation: Mutation) {
3535

3636
export function getMutationBackgroundColor(mutation: Mutation) {
3737
const { status } = mutation.state
38-
if (mutation.state.isPaused) return 'Paused'
39-
if (status === 'error') return 'rgba(255, 0, 0, 0.2)'
40-
if (status === 'pending') return 'rgba(255, 161, 0, 0.2)'
41-
if (status === 'success') return 'rgba(0, 255, 0, 0.2)'
42-
return 'rgba(0, 0, 0, 0.1)'
38+
if (mutation.state.isPaused) return 'purple'
39+
if (status === 'error') return 'red'
40+
if (status === 'pending') return 'yellow'
41+
if (status === 'success') return 'green'
42+
return 'gray'
4343
}

playground/app/app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const { isPending, isFetching, isError, data: posts, error } = useQuery({
3333
})
3434
3535
const { mutate: addPost, isPending: isMutationPending } = useMutation({
36+
mutationKey: ['addPost'],
3637
mutationFn: async (post) => {
3738
const url = 'https://jsonplaceholder.typicode.com/posts'
3839
return await $fetch(url, { method: 'POST', body: post })

0 commit comments

Comments
 (0)