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

100% Statements 18/18
100% Branches 7/7
100% Functions 5/5
100% Lines 17/17

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  8x           4x 8x   2x       2x 2x     2x 2x     2x           4x 2x           2x 2x 2x 2x                                                   8x 4x      
<template>
    <WidgetPanel
        :title="$t('healthOutdated.title')"
        :meta="$t('healthOutdated.meta')"
        :count="rows.length"
    >
        <EmptyState v-if="rows.length === 0">
            {{ outdated ? $t("healthOutdated.upToDate") : $t("healthOutdated.notCollected") }}
        </EmptyState>
        <div v-else data-scroll-x class="overflow-x-auto">
            <table class="data-table">
                <thead>
                    <tr>
                        <th>{{ $t("healthOutdated.columns.package") }}</th>
                        <th class="numeric">{{ $t("healthOutdated.columns.current") }}</th>
                        <th class="numeric hidden sm:table-cell">
                            {{ $t("healthOutdated.columns.wanted") }}
                        </th>
                        <th class="numeric">{{ $t("healthOutdated.columns.latest") }}</th>
                        <th class="numeric hidden sm:table-cell">
                            {{ $t("healthOutdated.columns.projects") }}
                        </th>
                        <th class="hidden lg:table-cell">
                            {{ $t("healthOutdated.columns.usedBy") }}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in rows" :key="item.name">
                        <td class="font-mono">
                            {{ item.name }}
                            <span v-if="item.isDeprecated" class="tone-bad">
                                {{ $t("healthOutdated.deprecated") }}
                            </span>
                        </td>
                        <td class="numeric font-mono">{{ item.current }}</td>
                        <td class="numeric hidden font-mono sm:table-cell">{{ item.wanted }}</td>
                        <td class="numeric font-mono text-highlighted">{{ item.latest }}</td>
                        <td class="numeric hidden font-mono sm:table-cell">
                            {{ item.dependents.length }}
                        </td>
                        <td
                            class="hidden max-w-64 truncate font-mono text-xs text-muted lg:table-cell"
                            :title="item.usedBy"
                        >
                            {{ item.usedBy }}
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </WidgetPanel>
</template>
 
<script setup lang="ts">
import type { OutdatedPackage } from "#layers/snapshot/shared/types/OutdatedPackage.ts";
 
interface Props {
    /** Null when `pnpm outdated` never ran, which is not the same as nothing being outdated. */
    outdated: OutdatedPackage[] | null;
}
 
const { outdated } = defineProps<Props>();
 
const rows = computed(() =>
    (outdated ?? []).map((item) => ({ ...item, usedBy: item.dependents.join(", ") })),
);
</script>