From 8e4f828606ce08d81b8f25eca416b5d048cc9508 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 26 Aug 2023 15:16:25 +1000 Subject: [PATCH] Fix channel and platform filter on versions page --- .../[user]/[project]/settings/[...slug].vue | 8 +++--- .../pages/[user]/[project]/versions/index.vue | 26 +++++-------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/frontend/src/pages/[user]/[project]/settings/[...slug].vue b/frontend/src/pages/[user]/[project]/settings/[...slug].vue index df6ef05b..4179ea1e 100644 --- a/frontend/src/pages/[user]/[project]/settings/[...slug].vue +++ b/frontend/src/pages/[user]/[project]/settings/[...slug].vue @@ -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(`projects/project/${route.params.user}/${route.params.project}/rename`, "post", { + const newSlug = await useInternalApi(`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(`projects/project/${route.params.user}/${route.params.project}/saveIcon`, "post", data); + const response = await useInternalApi(`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(`projects/project/${route.params.user}/${route.params.project}/resetIcon`, "post"); + const response = await useInternalApi(`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"))); diff --git a/frontend/src/pages/[user]/[project]/versions/index.vue b/frontend/src/pages/[user]/[project]/versions/index.vue index 8f01d4c0..341a80c7 100644 --- a/frontend/src/pages/[user]/[project]/versions/index.vue +++ b/frontend/src/pages/[user]/[project]/versions/index.vue @@ -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 = 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>( - `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" >