fix(frontend): move version-info out of backendData json so that it can't be stale

This commit is contained in:
MiniDigger | Martin 2022-12-23 16:03:17 +01:00
parent 4fbe9f2e8b
commit 798c1990bc
6 changed files with 47 additions and 44 deletions

View File

@ -1,4 +1,4 @@
import { PaginatedResult, Project, ProjectCompact, User, Version } from "hangar-api";
import { PaginatedResult, Project, ProjectCompact, User, Version, VersionInfo } from "hangar-api";
import {
Flag,
HangarNotification,
@ -15,6 +15,7 @@ import {
ReviewQueueEntry,
RoleTable,
} from "hangar-internal";
import { Ref } from "vue";
import { useApi, useInternalApi } from "~/composables/useApi";
import { useAsyncData } from "#imports";
@ -144,6 +145,10 @@ export async function useOrgVisibility(user: string) {
.data;
}
export async function useVersionInfo(): Promise<Ref<VersionInfo | undefined>> {
return (await useAsyncData("useVersionInfo", () => useInternalApi<VersionInfo>(`data/version-info`))).data;
}
export async function useUserData(user: string) {
return (
await useAsyncData("useUserData:" + user, async () => {

@ -1 +1 @@
Subproject commit 88452f3663de20b8db6d7a87dfcecf8f6600fa07
Subproject commit 9bd784fac1c77e461c4137b819ea8e555b85b50d

View File

@ -92,7 +92,6 @@ async function loadData(state: BackendData, axiosInstance: AxiosInstance) {
globalRoles,
channelColors,
flagReasons,
versionInfo,
] = (
await Promise.all([
axiosInstance.get<typeof state.projectCategories>("/categories"),
@ -108,7 +107,6 @@ async function loadData(state: BackendData, axiosInstance: AxiosInstance) {
axiosInstance.get<typeof state.globalRoles>("/globalRoles"),
axiosInstance.get<typeof state.channelColors>("/channelColors"),
axiosInstance.get<typeof state.flagReasons>("/flagReasons"),
axiosInstance.get<typeof state.versionInfo>("/version-info"),
])
).map((it) => it.data);
@ -129,5 +127,4 @@ async function loadData(state: BackendData, axiosInstance: AxiosInstance) {
state.globalRoles = globalRoles as typeof state.globalRoles;
state.channelColors = channelColors as typeof state.channelColors;
state.flagReasons = flagReasons as typeof state.flagReasons;
state.versionInfo = versionInfo as typeof state.versionInfo;
}

View File

@ -118,7 +118,6 @@ watch(startDate, updateDate);
watch(endDate, updateDate);
async function updateDate() {
console.log("update", startDate, endDate);
data = (await useInternalApi<DayStats[]>("admin/stats", "get", {
from: startDate.value,
to: endDate.value,

View File

@ -2,12 +2,12 @@
import { useHead } from "@vueuse/head";
import { useRoute } from "vue-router";
import PageTitle from "~/lib/components/design/PageTitle.vue";
import { useBackendData } from "~/store/backendData";
import Link from "~/lib/components/design/Link.vue";
import Alert from "~/lib/components/design/Alert.vue";
import { useSeo } from "~/composables/useSeo";
import { useVersionInfo } from "~/composables/useApiHelper";
const version = useBackendData.versionInfo;
const version = await useVersionInfo();
const route = useRoute();
useHead(useSeo("Hangar Version", null, route, null));
</script>
@ -15,40 +15,43 @@ useHead(useSeo("Hangar Version", null, route, null));
<template>
<div>
<PageTitle>Hangar Version</PageTitle>
<p mb="2">This instance is running <Link href="https://github.com/HangarMC/Hangar">Hangar</Link> {{ version.version }}</p>
<p mb="2">
The last commit was <Link :href="'https://github.com/HangarMC/Hangar/commit/' + version.commit">{{ version.commitShort }}</Link> by
<Link :href="'https://github.com/' + version.committer">{{ version.committer }}</Link> at {{ version.time }} with message: <br />
{{ version.message }}
</p>
<p mb="4">Last Tag: {{ version.tag }} ({{ version.behind || 0 }} commits since tag)</p>
<h2 class="text-xl mb-4 font-bold">Milestones</h2>
<p mb="2">The next development steps of Hangar have been set to the following milestones</p>
<ul class="list-disc list-inside">
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/10">Before Alpha</Link>: <br />
Once this is done, we will look for Alpha Testers on our Staging Instance on <Link href="https://hangar.papermc.dev">hangar.papermc.dev</Link>.<br />
At this point, DB resets are unlikely, but not impossible.
</li>
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/12">Before Beta</Link>: <br />
Once this is done, we will look for Beta Testers on our Prod Instance on <Link href="https://hangar.papermc.io">hangar.papermc.io</Link>.<br />
At this point we promise to no longer reset the DB, so you can upload all your plugins! Stuff might still be rough around the edges, so expect breakage,
please report any findings to our <Link href="https://github.com/HangarMC/Hangar/issues/new/choose">issue tracker</Link>!
</li>
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/14">During Beta</Link> we aim to fix all bugs and introduce a few new exciting features.
Hangar might be in this period for a while.
</li>
<li mb="2">
The <Link href="https://github.com/orgs/HangarMC/projects/1/views/16">Future</Link> is looking bright for Hangar, so this milestone captures all tasks
that we are interested in, but might be out of reach for a while for various reasons. But that should not stop you from suggesting new stuff!
</li>
</ul>
<p mt="2">You can see a graphical display of those milestones <Link href="https://github.com/orgs/HangarMC/projects/1/insights/2">here</Link>.</p>
<Alert mt="4">
Please remember, these are estimates, not promises, they can change at any time as the team shifts focus. Although you can always speed up a particular
task by contributing!
</Alert>
<template v-if="version">
<p mb="2">This instance is running <Link href="https://github.com/HangarMC/Hangar">Hangar</Link> {{ version.version }}</p>
<p mb="2">
The last commit was <Link :href="'https://github.com/HangarMC/Hangar/commit/' + version.commit">{{ version.commitShort }}</Link> by
<Link :href="'https://github.com/' + version.committer">{{ version.committer }}</Link> at {{ version.time }} with message: <br />
{{ version.message }}
</p>
<p v-if="version.tag" mb="4">Last Tag: {{ version.tag }} ({{ version.behind || 0 }} commits since tag)</p>
<h2 class="text-xl mb-4 font-bold">Milestones</h2>
<p mb="2">The next development steps of Hangar have been set to the following milestones</p>
<ul class="list-disc list-inside">
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/10">Before Alpha</Link>: <br />
Once this is done, we will look for Alpha Testers on our Staging Instance on <Link href="https://hangar.papermc.dev">hangar.papermc.dev</Link>.<br />
At this point, DB resets are unlikely, but not impossible.
</li>
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/12">Before Beta</Link>: <br />
Once this is done, we will look for Beta Testers on our Prod Instance on <Link href="https://hangar.papermc.io">hangar.papermc.io</Link>.<br />
At this point we promise to no longer reset the DB, so you can upload all your plugins! Stuff might still be rough around the edges, so expect
breakage, please report any findings to our <Link href="https://github.com/HangarMC/Hangar/issues/new/choose">issue tracker</Link>!
</li>
<li mb="2">
<Link href="https://github.com/orgs/HangarMC/projects/1/views/14">During Beta</Link> we aim to fix all bugs and introduce a few new exciting features.
Hangar might be in this period for a while.
</li>
<li mb="2">
The <Link href="https://github.com/orgs/HangarMC/projects/1/views/16">Future</Link> is looking bright for Hangar, so this milestone captures all tasks
that we are interested in, but might be out of reach for a while for various reasons. But that should not stop you from suggesting new stuff!
</li>
</ul>
<p mt="2">You can see a graphical display of those milestones <Link href="https://github.com/orgs/HangarMC/projects/1/insights/2">here</Link>.</p>
<Alert mt="4">
Please remember, these are estimates, not promises, they can change at any time as the team shifts focus. Although you can always speed up a particular
task by contributing!
</Alert>
</template>
<Alert v-else mt="4" type="danger"> Version info couldn't be loaded! </Alert>
</div>
</template>

View File

@ -78,6 +78,5 @@ declare module "hangar-api" {
globalRoles: Role[];
channelColors: Color[];
flagReasons: FlagReason[];
versionInfo: VersionInfo;
}
}