more type fixes

This commit is contained in:
Jake Potrebic 2022-11-19 21:41:44 -08:00
parent 866e15a6b5
commit 6ba7d98079
No known key found for this signature in database
GPG Key ID: 27CC63F7CBC866C7
15 changed files with 33 additions and 34 deletions

@ -1 +1 @@
Subproject commit c2123c3864c21913c85b6080720aca542d34d754
Subproject commit 8cb6c314f9b31473d71b8499d8548a71cbec850c

View File

@ -18,10 +18,7 @@ import { useHead } from "@vueuse/head";
import { useSeo } from "~/composables/useSeo";
import { projectIconUrl } from "~/composables/useUrlHelper";
import { useRoute } from "vue-router";
import Tooltip from "~/lib/components/design/Tooltip.vue";
import { useNotificationStore } from "~/lib/store/notification";
import InputRadio from "~/lib/components/ui/InputRadio.vue";
import { ref } from "vue";
const props = defineProps<{
user: User;
@ -90,7 +87,7 @@ async function editChannel(channel: ProjectChannel) {
<template #header>{{ i18n.t("channel.manage.title") }}</template>
<p class="mb-2">{{ i18n.t("channel.manage.subtitle") }}</p>
<Table class="w-full">
<Table v-if="channels" class="w-full">
<thead>
<tr>
<th><IconMdiTag />{{ i18n.t("channel.manage.channelName") }}</th>

View File

@ -43,7 +43,7 @@ useHead(useSeo("Flags | " + props.project.name, props.project.description, route
</Link>
</template>
<SortableTable :headers="headers" :items="flags">
<SortableTable v-if="flags" :items="flags" :headers="headers">
<template #empty>
<Alert type="info">
{{ i18n.t("flags.noFlags") }}

View File

@ -71,7 +71,7 @@ async function addNote() {
<h2 class="text-lg font-bold mb-1 mt-2">
{{ i18n.t("notes.notes") }}
</h2>
<SortableTable :items="notes" :headers="headers">
<SortableTable v-if="notes" :items="notes" :headers="headers">
<template #empty>
<Alert type="warning">{{ i18n.t("notes.noNotes") }}</Alert>
</template>

View File

@ -6,9 +6,6 @@ import { useRoute, useRouter } from "vue-router";
import { handleRequestError } from "~/composables/useErrorHandling";
import { HangarProject } from "hangar-internal";
import { useErrorRedirect } from "~/lib/composables/useErrorRedirect";
import { useHead } from "@vueuse/head";
import { useSeo } from "~/composables/useSeo";
import { projectIconUrl } from "~/composables/useUrlHelper";
import { Platform } from "~/types/enums";
const ctx = useContext();

View File

@ -120,8 +120,8 @@ function getVisibilityTitle(visibility: Visibility) {
<div class="flex flex-wrap md:flex-nowrap gap-4">
<section class="basis-full md:basis-9/12 flex-grow">
<ul>
<Alert v-if="!versions.result || versions.result.length === 0" type="info"> {{ i18n.t("version.page.noVersions") }} </Alert>
<Pagination v-else :items="versions.result">
<Alert v-if="!versions || !versions.result || versions.result.length === 0" type="info"> {{ i18n.t("version.page.noVersions") }} </Alert>
<Pagination v-else-if="versions" :items="versions.result">
<template #default="{ item }">
<li class="mb-2">
<Card :class="getBorderClasses(item)" class="pb-1">

View File

@ -28,6 +28,7 @@ import InputTag from "~/lib/components/ui/InputTag.vue";
import Tabs, { Tab } from "~/lib/components/design/Tabs.vue";
import PlatformLogo from "~/components/logos/platforms/PlatformLogo.vue";
import { useProjectChannels } from "~/composables/useApiHelper";
import { ValidationRule } from "@vuelidate/core";
const route = useRoute();
const router = useRouter();
@ -170,15 +171,18 @@ const platforms = computed<IPlatform[]>(() => {
const selectedPlatformsData = computed<IPlatform[]>(() => {
const result: IPlatform[] = [];
for (const platformName of selectedPlatforms.value) {
result.push(backendData.platforms.get(platformName as Platform)!);
const iPlatform = backendData.platforms.get(platformName);
if (iPlatform) {
result.push(iPlatform);
}
}
return result;
});
const artifactURLRules = [validUrl()];
const versionRules = [required()];
const platformVersionRules = computed(() => {
return [(v: string[]) => !!v.length || "Error"];
const platformVersionRules = computed<ValidationRule<string[] | undefined>[]>(() => {
return [(v) => !!v && !!v.length];
});
const changelogRules = [required(t("version.new.form.release.bulletin"))];
@ -356,7 +360,7 @@ useHead(
<InputText :model-value="pendingFile.fileInfo.name" :label="t('version.new.form.fileName')" disabled />
</div>
<div v-if="pendingFile.fileInfo" class="basis-full <md:mt-4 md:(basis-2/12)">
<InputText :model-value="formatSize(pendingFile.fileInfo.sizeBytes)" :label="t('version.new.form.fileSize')" disabled />
<InputText :model-value="String(formatSize(pendingFile.fileInfo.sizeBytes))" :label="t('version.new.form.fileSize')" disabled />
</div>
<div v-else class="basis-full <md:mt-4 md:basis-6/12">
<InputText v-model="pendingFile.externalUrl" :label="t('version.new.form.externalUrl')" disabled />

View File

@ -6,7 +6,7 @@ import Button from "~/lib/components/design/Button.vue";
import { reactive, ref } from "vue";
import { useContext } from "vite-ssr/vue";
import { useInternalApi } from "~/composables/useApi";
import { ApiKey, IPermission, User } from "hangar-api";
import { ApiKey, User } from "hangar-api";
import { useRoute } from "vue-router";
import { handleRequestError } from "~/composables/useErrorHandling";
import InputCheckbox from "~/lib/components/ui/InputCheckbox.vue";

View File

@ -37,7 +37,7 @@ function getRouteParams(activity: ReviewActivity) {
<Card>
<template #header>{{ i18n.t("userActivity.reviews") }}</template>
<Table v-if="reviewActivities.length">
<Table v-if="reviewActivities && reviewActivities.length">
<tbody>
<tr v-for="(activity, idx) in reviewActivities" :key="`review-${idx}`">
<td>{{ i18n.t("userActivity.reviewApproved") }}</td>
@ -66,7 +66,7 @@ function getRouteParams(activity: ReviewActivity) {
<Card>
<template #header>{{ i18n.t("userActivity.flags") }}</template>
<Table v-if="flagActivities.length">
<Table v-if="flagActivities && flagActivities.length">
<tbody>
<tr v-for="(activity, idx) in flagActivities" :key="`flag-${idx}`">
<td>{{ i18n.t("userActivity.flagResolved") }}</td>

View File

@ -91,7 +91,7 @@ function getCount(entry: ReviewQueueEntry, ..._actions: ReviewAction[]) {
<Card>
<template #header>{{ i18n.t("versionApproval.approvalQueue") }}</template>
<SortableTable :headers="notStartedHeaders" :items="data?.notStarted">
<SortableTable v-if="data" :headers="notStartedHeaders" :items="data.notStarted">
<template #item_project="{ item }">
<Link :to="`/${item.namespace.owner}/${item.namespace.slug}`">
{{ `${item.namespace.owner}/${item.namespace.slug}` }}
@ -124,7 +124,7 @@ function getCount(entry: ReviewQueueEntry, ..._actions: ReviewAction[]) {
<Card class="mt-4">
<template #header>{{ i18n.t("versionApproval.inReview") }}</template>
<SortableTable :headers="underReviewHeaders" :items="data?.underReview" expandable>
<SortableTable v-if="data" :headers="underReviewHeaders" :items="data.underReview" expandable>
<template #item_project="{ item }">
<Link :to="`/${item.namespace.owner}/${item.namespace.slug}`">
{{ `${item.namespace.owner}/${item.namespace.slug}` }}

View File

@ -21,7 +21,7 @@ useHead(useSeo(i18n.t("health.title"), null, route, null));
<template>
<PageTitle>{{ i18n.t("health.title") }}</PageTitle>
<div class="grid gap-8 grid-cols-1 md:grid-cols-2">
<Card>
<Card v-if="healthReport">
<template #header> {{ i18n.t("health.noTopicProject") }}</template>
<ul class="max-h-xs overflow-auto">
@ -35,7 +35,7 @@ useHead(useSeo(i18n.t("health.title"), null, route, null));
</li>
</ul>
</Card>
<Card>
<Card v-if="healthReport">
<template #header> {{ i18n.t("health.erroredJobs") }}</template>
<ul class="max-h-xs overflow-auto">
@ -47,7 +47,7 @@ useHead(useSeo(i18n.t("health.title"), null, route, null));
</li>
</ul>
</Card>
<Card>
<Card v-if="healthReport">
<template #header> {{ i18n.t("health.staleProjects") }}</template>
<ul class="max-h-xs overflow-auto">
@ -61,7 +61,7 @@ useHead(useSeo(i18n.t("health.title"), null, route, null));
</li>
</ul>
</Card>
<Card>
<Card v-if="healthReport">
<template #header> {{ i18n.t("health.notPublicProjects") }}</template>
<ul class="max-h-xs overflow-auto">
@ -85,7 +85,7 @@ useHead(useSeo(i18n.t("health.title"), null, route, null));
<!--<li v-if="!healthReport.noPlatform || healthReport.noPlatform.length === 0">{{ i18n.t('health.empty') }}</li>-->
</ul>
</Card>
<Card>
<Card v-if="healthReport">
<template #header> {{ i18n.t("health.missingFileProjects") }}</template>
<ul class="max-h-xs overflow-auto">

View File

@ -144,7 +144,7 @@ useHead(useSeo(i18n.t("userAdmin.title") + " " + route.params.user, null, route,
<Card md="col-start-1">
<template #header>{{ i18n.t("userAdmin.projects") }}</template>
<SortableTable :items="projects.result" :headers="projectsConfig">
<SortableTable v-if="projects" :items="projects.result" :headers="projectsConfig">
<template #item_name="{ item }">
<Link :to="'/' + item.namespace.owner + '/' + item.name">
{{ item.name }}

View File

@ -20,7 +20,7 @@ const ctx = useContext();
const i18n = useI18n();
const route = useRoute();
const router = useRouter();
const notifcation = useNotificationStore();
const notification = useNotificationStore();
const platformMap = useBackendDataStore().platforms;
const originalPlatforms = platformMap ? [...platformMap.values()] : [];
@ -35,12 +35,13 @@ async function save() {
for (const pl of platforms.value || []) {
data[pl.enumName] = pl.possibleVersions;
}
const result = await useInternalApi("admin/platformVersions", true, "post", data).catch((e) => handleRequestError(e, ctx, i18n));
if (result) {
notifcation.success(i18n.t("platformVersions.success"));
try {
await useInternalApi("admin/platformVersions", true, "post", data);
notification.success(i18n.t("platformVersions.success"));
router.go(0);
} else {
} catch (e: any) {
loading.value = false;
handleRequestError(e, ctx, i18n);
}
}

View File

@ -10,7 +10,7 @@ import { useLocalStorage } from "@vueuse/core";
import { computed } from "vue";
const route = useRoute();
const remoteUrl = route.query.remoteUrl;
const remoteUrl = Array.isArray(route.query.remoteUrl) ? route.query.remoteUrl[0] : route.query.remoteUrl;
const i18n = useI18n();
const trustedHosts = useLocalStorage("trustedHosts", [] as string[]);

View File

@ -38,7 +38,7 @@ async function create() {
name: name.value,
});
await router.push("/" + name.value);
} catch (e) {
} catch (e: any) {
handleRequestError(e, ctx, i18n);
}
}