Fix channel and platform filter on versions page

This commit is contained in:
Nassim Jahnke 2023-08-26 15:16:25 +10:00
parent 5f5a33db2e
commit 8e4f828606
2 changed files with 10 additions and 24 deletions

View File

@ -138,7 +138,7 @@ async function save() {
form.settings.license.url = null;
}
await useInternalApi(`projects/project/${route.params.user}/${route.params.project}/settings`, "post", {
await useInternalApi(`projects/project/${route.params.project}/settings`, "post", {
...form,
});
await router.go(0);
@ -164,7 +164,7 @@ async function transfer() {
async function rename() {
loading.rename = true;
try {
const newSlug = await useInternalApi<string>(`projects/project/${route.params.user}/${route.params.project}/rename`, "post", {
const newSlug = await useInternalApi<string>(`projects/project/${route.params.project}/rename`, "post", {
content: newName.value,
});
await notificationStore.success(i18n.t("project.settings.success.rename", [newName.value]));
@ -212,7 +212,7 @@ async function uploadIcon() {
data.append("projectIcon", cropperResult.value);
loading.uploadIcon = true;
try {
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/saveIcon`, "post", data);
const response = await useInternalApi<string | null>(`projects/project/${route.params.project}/saveIcon`, "post", data);
imgSrc.value = URL.createObjectURL(cropperResult.value); // set temporary source so it changes right away
projectIcon.value = null;
cropperInput.value = null;
@ -229,7 +229,7 @@ async function uploadIcon() {
async function resetIcon() {
loading.resetIcon = true;
try {
const response = await useInternalApi<string | null>(`projects/project/${route.params.user}/${route.params.project}/resetIcon`, "post");
const response = await useInternalApi<string | null>(`projects/project/${route.params.project}/resetIcon`, "post");
await (response
? notificationStore.success(i18n.t("project.settings.success.resetIconWarn", [response]))
: notificationStore.success(i18n.t("project.settings.success.resetIcon")));

View File

@ -38,17 +38,7 @@ const props = defineProps<{
project: HangarProject;
}>();
const options = reactive({ page: 1, itemsPerPage: 10 });
const platforms = computed(() => [...(useBackendData.platforms?.values() || [])]);
const requestOptions = computed(() => {
return {
limit: options.itemsPerPage,
offset: (options.page - 1) * options.itemsPerPage,
channel: filter.channels,
platform: filter.platforms,
};
});
const pagination = ref();
const page = ref(0);
const requestParams = computed(() => {
@ -56,6 +46,8 @@ const requestParams = computed(() => {
return {
limit,
offset: page.value * limit,
channel: filter.channels,
platform: filter.platforms,
};
});
@ -72,7 +64,7 @@ useHead(useSeo("Versions | " + props.project.name, props.project.description, ro
const pageChangeScrollAnchor: Ref<Element | null> = ref(null);
async function emitPageUpdate(newPage: number) {
async function update(newPage: number) {
page.value = newPage;
versions.value = (await useProjectVersions(route.params.project as string, requestParams.value))?.value;
}
@ -87,14 +79,8 @@ watch(
versions.value.result = [];
return;
}
const newVersions = await useApi<PaginatedResult<Version>>(
`projects/${route.params.user}/${route.params.project}/versions`,
"get",
requestOptions.value
).catch((e) => handleRequestError(e));
if (newVersions) {
versions.value = newVersions;
}
await update(0);
},
{ deep: true }
);
@ -139,7 +125,7 @@ function getVisibilityTitle(visibility: Visibility) {
:items="versions.result"
:server-pagination="versions.pagination"
:reset-anchor="pageChangeScrollAnchor"
@update:page="emitPageUpdate"
@update:page="update"
>
<template #default="{ item }">
<li class="mb-2">