Fix some annoying warnings

This commit is contained in:
Nassim Jahnke 2022-07-22 15:48:05 +02:00
parent 082d3d974a
commit 4fc8bae9ec
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
10 changed files with 78 additions and 57 deletions

View File

@ -1,8 +1,7 @@
<script lang="ts" setup>
import { hasSlotContent } from "~/lib/composables/useSlot";
import Table from "~/lib/components/design/Table.vue";
import { computed, reactive, ref } from "vue";
import Button from "~/lib/components/design/Button.vue";
import { reactive, ref } from "vue";
import PaginationButtons from "~/lib/components/design/PaginationButtons.vue";
import Pagination from "~/lib/components/design/Pagination.vue";
@ -65,7 +64,7 @@ function click(header: Header) {
</tr>
</thead>
<tbody>
<Pagination :items="sorted">
<Pagination v-if="sorted.length !== 0" :items="sorted">
<template #default="{ item, idx }">
<tr>
<td v-for="header in headers" :key="header.name" :style="header.width ? 'width: ' + header.width : ''" @click="expanded[idx] = !expanded[idx]">
@ -82,10 +81,10 @@ function click(header: Header) {
<slot name="expanded-item" :item="item" :headers="headers"></slot>
</tr>
</template>
<template #pagination="{ page, pages, updatePage }">
<template #pagination="{ p, pages, updatePage }">
<tr>
<td :colspan="headers.length">
<PaginationButtons :page="page" :pages="pages" @update:page="updatePage" />
<PaginationButtons :page="p" :pages="pages" @update:page="updatePage" />
</td>
</tr>
</template>

View File

@ -205,7 +205,7 @@ defineExpose({ results, newDepResults, newDeps, deletedDeps, reset: reset });
:rules="!!newDep.externalUrl ? [] : [required(t('version.new.form.hangarProject'))]"
@search="onNewDepSearch($event, index)"
@change="newDep.externalUrl = null"
@update:modelValue="newDep.namespace = fromString($event)"
@update:model-value="newDep.namespace = fromString($event)"
/>
</template>
<template #url>

View File

@ -31,6 +31,9 @@ const props = withDefaults(
{
small: false,
showVersions: true,
platform: undefined,
version: undefined,
pinnedVersion: undefined,
}
);
@ -57,14 +60,14 @@ const external = computed(() => false);
</span>
</template>
<DropdownItem
v-for="(v, platform) in pinnedVersion.platformDependencies"
:key="platform"
v-for="(v, p) in pinnedVersion.platformDependencies"
:key="p"
class="flex items-center"
:href="downloadLink(platform, pinnedVersion)"
:href="downloadLink(p, pinnedVersion)"
target="_blank"
rel="noopener noreferrer"
>
<PlatformLogo :platform="platform" :size="24" class="mr-1" />
<PlatformLogo :platform="p" :size="24" class="mr-1" />
{{ backendData.platforms?.get(platform).name }}
<span v-if="showVersions" class="ml-1">({{ formatVersionNumbers(v) }})</span>
</DropdownItem>

View File

@ -7,7 +7,7 @@ export function create(request: Context["request"], response: Context["response"
domainLog("enter");
const d = domain.create();
d.add(request);
d.add(response!);
d.add(response);
d.on("error", (err) => {
domainLog("domain error!", err);
});

View File

@ -52,8 +52,8 @@ export function formatVersionNumbers(versionNumbers: string[]): string {
}
const previousWholeVersion = splitVersionNumber(prevVersionMatcher[0]);
if (previousWholeVersion.length == versionArr.length) {
if (versionArr.at(-1)! - 1 == prevVersion) {
if (previousWholeVersion.length === versionArr.length) {
if (versionArr.at(-1)! - 1 === prevVersion) {
verString = verString.replace(new RegExp("-[0-9.]+$"), "-" + version);
} else {
verString += ", " + version;
@ -63,8 +63,8 @@ export function formatVersionNumbers(versionNumbers: string[]): string {
}
} else if (comma && comma.length !== 0) {
const prevVersion = splitVersionNumber(comma[0]);
if (prevVersion.length == versionArr.length) {
verString += versionArr.at(-1)! - 1 == prevVersion.at(-1) ? "-" + version : ", " + version;
if (prevVersion.length === versionArr.length) {
verString += versionArr.at(-1)! - 1 === prevVersion.at(-1) ? "-" + version : ", " + version;
} else {
verString += ", " + version;
}

@ -1 +1 @@
Subproject commit 2f73597a2097677465b7ceee6c6982ac4325cb7b
Subproject commit c2748faf83085da4c2dac00469601a2ec16a38b9

View File

@ -8,7 +8,7 @@ import Alert from "~/lib/components/design/Alert.vue";
import { useContext } from "vite-ssr/vue";
import { useProjectFlags } from "~/composables/useApiHelper";
import { handleRequestError } from "~/composables/useErrorHandling";
import { HangarProject } from "hangar-internal";
import { Flag, HangarProject } from "hangar-internal";
import { useHead } from "@vueuse/head";
import { useSeo } from "~/composables/useSeo";
import { projectIconUrl } from "~/composables/useUrlHelper";

View File

@ -96,8 +96,11 @@ async function refresh() {
function getReviewStateString(review: HangarReview): string {
if (!review.messages) return "error";
const lastMsg = review.messages.at(-1);
switch (lastMsg!.action) {
if (!lastMsg) return "error";
switch (lastMsg.action) {
case ReviewAction.START:
case ReviewAction.MESSAGE:
case ReviewAction.REOPEN:
@ -114,8 +117,11 @@ function getReviewStateString(review: HangarReview): string {
function getReviewStateColor(review: HangarReview): string {
if (!review.messages) return "#D50000";
const lastMsg = review.messages.at(-1);
switch (lastMsg!.action) {
if (!lastMsg) return "#D50000";
switch (lastMsg.action) {
case ReviewAction.START:
case ReviewAction.MESSAGE:
case ReviewAction.REOPEN:
@ -149,8 +155,11 @@ function getReviewMessageColor(msg: HangarReviewMessage): string {
function getLastUpdateDate(review: HangarReview): string {
if (!review.messages) return "error";
const lastMsg = review.messages.at(-1);
return prettyDateTime(lastMsg!.createdAt);
if (!lastMsg) return "error";
return prettyDateTime(lastMsg.createdAt);
}
function startReview() {
@ -212,57 +221,67 @@ function stopReview(userMsg: string) {
return;
}
const review = currentUserReview.value;
const args = {
name: currentUserReview.value.userName,
msg: userMsg,
};
return sendReviewRequest("stop", args, ReviewAction.STOP, () => {
currentUserReview.value!.endedAt = new Date().toISOString();
});
return sendReviewRequest("stop", args, ReviewAction.STOP, () => (review.endedAt = new Date().toISOString()));
}
function reopenReview() {
if (isCurrentReviewOpen.value) return;
if (isCurrentReviewOpen.value || !currentUserReview.value) {
return;
}
const review = currentUserReview.value;
loadingValues.reopen = true;
sendReviewRequest(
"reopen",
{ name: currentUserReview.value!.userName },
{ name: review.userName },
ReviewAction.REOPEN,
() => {
currentUserReview.value!.endedAt = null;
},
() => {
loadingValues.reopen = false;
}
() => (review.endedAt = null),
() => (loadingValues.reopen = false)
);
}
function approve() {
if (!isCurrentReviewOpen.value) return;
if (!isCurrentReviewOpen.value || !currentUserReview.value) {
return;
}
const review = currentUserReview.value;
loadingValues.approve = true;
sendReviewRequest(
"approve",
{ name: currentUserReview.value!.userName },
{ name: review.userName },
ReviewAction.APPROVE,
() => (currentUserReview.value!.endedAt = new Date().toISOString()),
() => (review.endedAt = new Date().toISOString()),
() => (loadingValues.approve = false)
);
}
function approvePartial() {
if (!isCurrentReviewOpen.value) return;
if (!isCurrentReviewOpen.value || !currentUserReview.value) {
return;
}
const review = currentUserReview.value;
loadingValues.approvePartial = true;
sendReviewRequest(
"approvePartial",
{ name: currentUserReview.value!.userName },
{ name: review.userName },
ReviewAction.PARTIALLY_APPROVE,
() => (currentUserReview.value!.endedAt = new Date().toISOString()),
() => (review.endedAt = new Date().toISOString()),
() => (loadingValues.approvePartial = false)
);
}
function undoApproval() {
if (isCurrentReviewOpen.value) return;
if (isCurrentReviewOpen.value) {
return;
}
loadingValues.undoApproval = true;
sendReviewRequest(
"undoApproval",

View File

@ -112,12 +112,12 @@ const isFile = computed(() => pendingVersion.value?.isFile);
const currentChannel = computed(() => channels.value.find((c) => c.name === pendingVersion.value?.channelName));
const platforms = computed<IPlatform[]>(() => {
return [...backendData.platforms!.values()];
return [...backendData.platforms.values()];
});
const selectedPlatformsData = computed<IPlatform[]>(() => {
const result: IPlatform[] = [];
for (const platformName of selectedPlatforms.value) {
result.push(backendData.platforms!.get(platformName as Platform)!);
result.push(backendData.platforms.get(platformName as Platform)!);
}
return result;
});
@ -134,7 +134,7 @@ async function preload() {
return;
}
for (const platform in pendingVersion.value!.platformDependencies) {
for (const platform in pendingVersion.value.platformDependencies) {
// Get last platform and plugin dependency data for the last version of the same channel/any other channel if not found
useInternalApi<LastDependencies>(`versions/version/${props.project.namespace.owner}/${props.project.namespace.slug}/lastdependencies`, true, "get", {
channel: pendingVersion.value?.channelName,
@ -145,8 +145,8 @@ async function preload() {
return;
}
pendingVersion.value!.platformDependencies[platform as Platform] = v.platformDependencies;
pendingVersion.value!.pluginDependencies[platform as Platform] = v.pluginDependencies;
pendingVersion.value.platformDependencies[platform as Platform] = v.platformDependencies;
pendingVersion.value.pluginDependencies[platform as Platform] = v.pluginDependencies;
})
.catch<any>((e) => handleRequestError(e, ctx, i18n));
}
@ -178,24 +178,24 @@ async function createPendingVersion() {
}
async function createVersion() {
if (!pendingVersion.value) {
if (!pendingVersion.value || !currentChannel.value) {
return;
}
loading.submit = true;
pendingVersion.value!.description = descriptionEditor.value.rawEdited;
pendingVersion.value!.channelColor = currentChannel.value!.color;
pendingVersion.value!.channelFlags = currentChannel.value!.flags;
pendingVersion.value.description = descriptionEditor.value.rawEdited;
pendingVersion.value.channelColor = currentChannel.value.color;
pendingVersion.value.channelFlags = currentChannel.value.flags;
// played around trying to get this to happen in jackson's deserialization, but couldn't figure it out.
for (const platform in pendingVersion.value.platformDependencies) {
if (pendingVersion.value!.platformDependencies[platform as Platform].length < 1) {
delete pendingVersion.value!.platformDependencies[platform as Platform];
if (pendingVersion.value.platformDependencies[platform as Platform].length < 1) {
delete pendingVersion.value.platformDependencies[platform as Platform];
}
}
for (const platform in pendingVersion.value.pluginDependencies) {
if (pendingVersion.value!.pluginDependencies[platform as Platform].length < 1) {
delete pendingVersion.value!.pluginDependencies[platform as Platform];
if (pendingVersion.value.pluginDependencies[platform as Platform].length < 1) {
delete pendingVersion.value.pluginDependencies[platform as Platform];
}
}
@ -264,7 +264,7 @@ useHead(
</Tabs>
</template>
<template #basic>
<div class="flex flex-wrap gap-x-2">
<div class="flex flex-wrap">
<!-- TODO validate version string against existing versions. complex because they only have to be unique per-platform -->
<div class="basis-full mt-2 md:basis-4/12">
<InputText
@ -286,7 +286,7 @@ useHead(
<InputText v-model="pendingVersion.externalUrl" :label="t('version.new.form.externalUrl')" />
</div>
</div>
<div class="flex flex-wrap space-x-2 items-center mt-4">
<div class="flex flex-wrap items-center mt-4">
<div class="basis-4/12">
<InputSelect v-model="pendingVersion.channelName" :values="channels" item-text="name" item-value="name" :label="t('version.new.form.channel')" />
</div>

View File

@ -34,11 +34,11 @@ interface Validations {
}
export const useBackendDataStore = defineStore("backendData", () => {
const projectCategories = ref<Map<ProjectCategory, IProjectCategory> | null>(null);
const permissions = ref<Map<NamedPermission, IPermission> | null>(null);
const platforms = ref<Map<Platform, IPlatform> | null>(null);
const projectCategories = ref<Map<ProjectCategory, IProjectCategory>>(new Map());
const permissions = ref<Map<NamedPermission, IPermission>>(new Map());
const platforms = ref<Map<Platform, IPlatform>>(new Map());
const validations = ref<Validations | null>(null);
const prompts = ref<Map<Prompt, IPrompt> | null>(null);
const prompts = ref<Map<Prompt, IPrompt>>(new Map());
const announcements = ref<Announcement[]>([]);
const visibilities = ref<IVisibility[]>([]);
const licenses = ref<string[]>([]);