All files / apps/developer-portal/layers/health/app/components HealthIssueRow.vue

100% Statements 17/17
100% Branches 12/12
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  7x 2x 2x       2x       3x                 2x 14x                                             2x                                                                                       4x             4x 4x   4x 4x    
<template>
    <div class="px-4 py-3 transition-colors hover:bg-elevated/50">
        <div class="flex items-start gap-3">
            <span class="mt-0.5 shrink-0 font-mono text-xs text-dimmed tabular-nums"
                >#{{ issue.number }}</span
            >
 
            <div class="min-w-0 flex-1">
                <button
                    type="button"
                    class="w-full text-left text-sm"
                    @click="expanded = !expanded"
                >
                    {{ issue.title }}
                </button>
 
                <p v-if="summary && !expanded" class="mt-0.5 truncate text-xs text-muted">
                    {{ summary }}
                </p>
 
                <div class="mt-1.5 flex flex-wrap items-center gap-1.5">
                    <UBadge
                        v-for="label in issue.labels"
                        :key="label"
                        color="neutral"
                        variant="subtle"
                        size="sm"
                        :label
                    />
 
                    <span v-if="!compact" class="text-xs text-dimmed">
                        {{ $t("healthIssueRow.updated", { age: updated }) }}
                    </span>
                </div>
 
                <div v-if="expanded" class="mt-3 flex flex-col gap-3">
                    <p v-if="issue.body" class="text-sm whitespace-pre-line text-muted">
                        {{ issue.body }}
                    </p>
 
                    <p v-else class="text-sm text-dimmed italic">
                        {{ $t("healthIssueRow.noDescription") }}
                    </p>
 
                    <div class="flex items-center gap-3">
                        <UButton
                            :to="issue.url"
                            target="_blank"
                            external
                            :label="$t('healthIssueRow.open', { number: issue.number })"
                            icon="i-lucide-external-link"
                            color="neutral"
                            variant="subtle"
                            size="xs"
                        />
 
                        <span v-if="issue.assignees.length > 0" class="text-xs text-dimmed">{{
                            assignees
                        }}</span>
                    </div>
                </div>
            </div>
 
            <UButton
                :to="issue.url"
                target="_blank"
                external
                icon="i-lucide-external-link"
                color="neutral"
                variant="ghost"
                size="xs"
                :aria-label="$t('healthIssueRow.openLabel', { number: issue.number })"
            />
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { summarize } from "#layers/github/app/utils/issues.ts";
import type { Issue } from "#layers/github/app/utils/issues.ts";
 
interface Props {
    issue: Issue;
    compact?: boolean;
}
 
const { issue, compact = false } = defineProps<Props>();
 
const expanded = ref(false);
 
/**
 * The row shows a clamped line; opening it shows the whole body as plain text. Rendering the
 * markdown here would mean a second renderer to keep in step with the docs one, for a body that is
 * one click from the place it was written for.
 */
const summary = computed(() => summarize(issue.body, compact ? 100 : 160));
const { t } = useI18n();
 
const updated = computed(() => relativeTime(issue.updatedAt, t));
const assignees = computed(() => issue.assignees.join(", "));
</script>