Skip to content

Commit

Permalink
chore: 馃Ы update visibility of hidden beta items
Browse files Browse the repository at this point in the history
  • Loading branch information
realashleybailey committed Nov 21, 2023
1 parent 3a26ead commit f44ea0b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
6 changes: 4 additions & 2 deletions apps/wizarr-frontend/src/modules/settings/pages/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<template v-for="(section, index) in settingsSections">
<div :id="`settingsContainer${index}`">
<!-- Sections Title -->
<div class="settings-section" v-if="!(sectionDisabled(section) && env.NODE_ENV === 'production')">
<div class="settings-section" v-if="!(sectionDisabled(section) && !is_beta)">
<div class="flex flex-col">
<div class="text-lg font-bold leading-tight tracking-tight text-gray-900 md:text-xl dark:text-white">
{{ __(section.title) }}
Expand All @@ -18,7 +18,7 @@
<!-- Settings Grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mt-4">
<template v-for="page in section.pages">
<template v-if="!(page.disabled && env.NODE_ENV === 'production')">
<template v-if="!(page.disabled && !is_beta)">
<SettingsButton :title="page.title" :description="page.description" :icon="page.icon" :url="page.url" :disabled="page.disabled" :modal="page.modal" />
</template>
</template>
Expand All @@ -38,6 +38,7 @@ import { defineComponent } from "vue";
import { useUserStore } from "@/stores/user";
import { mapState } from "pinia";
import { useSettingsStore } from "@/stores/settings";
import { useServerStore } from "@/stores/server";
import SettingsTemplate from "@/templates/SettingsTemplate.vue";
import SettingsButton from "@/components/Buttons/SettingsButton.vue";
Expand Down Expand Up @@ -84,6 +85,7 @@ export default defineComponent({
computed: {
...mapState(useUserStore, ["user"]),
...mapState(useSettingsStore, ["search"]),
...mapState(useServerStore, ["is_beta"]),
settingsSections() {
const filteredSettingsSearch = this.search ? this.settings.map(this.mapSections).filter(this.filterSections) : this.settings;
const filteredSettingsRole = filteredSettingsSearch.map(this.mapRoles as any).filter(this.filterSections as any);
Expand Down
58 changes: 24 additions & 34 deletions apps/wizarr-frontend/src/stores/changeLog.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import toasts from '@/ts/utils/toasts';
import CacheStorage from '@/ts/utils/cacheStorage';
import type { ChangeLog, ChangeLogs } from "@/types/ChangeLog";
import { buildWebStorage, setupCache } from "axios-cache-interceptor";

import type { AxiosInstance } from 'axios';
import type { ChangeLog, ChangeLogs } from '@/types/ChangeLog';

import { defineStore } from 'pinia';
import { useAxios } from '@/plugins/axios';
import { buildWebStorage, setupCache } from 'axios-cache-interceptor';
import type { AxiosInstance } from "axios";
import CacheStorage from "@/ts/utils/cacheStorage";
import { defineStore } from "pinia";
import toasts from "@/ts/utils/toasts";
import { useAxios } from "@/plugins/axios";

const axios = useAxios();
const cachedAxios = setupCache(axios as AxiosInstance);

export const useChangeLogStore = defineStore('changeLog', {
export const useChangeLogStore = defineStore("changeLog", {
state: () => ({
cache: {} as any,
changeLogs: [] as ChangeLogs,
Expand All @@ -25,42 +24,33 @@ export const useChangeLogStore = defineStore('changeLog', {
this.fixCachedAxios(this);

// Get the change logs from the API
const reponse = await cachedAxios.get(
'https://api.github.com/repos/wizarrrr/wizarr/releases',
{
params: { per_page, page },
transformRequest: [
(data, headers) => {
delete headers['X-CSRF-TOKEN'];
delete headers['pragma'];
delete headers['expires'];
delete headers['cache-control'];
delete headers['Authorization'];
return data;
},
],
},
);
const reponse = await cachedAxios.get("https://api.github.com/repos/wizarrrr/wizarr/releases", {
params: { per_page, page },
transformRequest: [
(data, headers) => {
delete headers["X-CSRF-TOKEN"];
delete headers["pragma"];
delete headers["expires"];
delete headers["cache-control"];
delete headers["Authorization"];
return data;
},
],
});

// If we didn't get a 200, raise an error
if (reponse.status !== 200) {
toasts.error('Could not get Change Logs');
toasts.error("Could not get Change Logs");
return;
}

// Add the new change logs and update existing ones
reponse.data.forEach((changeLog: ChangeLog) => {
const index = this.changeLogs.findIndex(
(c) => c.id === changeLog.id,
);
const index = this.changeLogs.findIndex((c) => c.id === changeLog.id);
if (index === -1) {
this.changeLogs = [...this.changeLogs, changeLog];
} else {
this.changeLogs = [
...this.changeLogs.slice(0, index),
changeLog,
...this.changeLogs.slice(index + 1),
];
this.changeLogs = [...this.changeLogs.slice(0, index), changeLog, ...this.changeLogs.slice(index + 1)];
}
});
},
Expand Down
1 change: 1 addition & 0 deletions apps/wizarr-frontend/src/stores/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useServerStore = defineStore("server", {
update_available: false as boolean,
debug: false as boolean,
setup_required: false as boolean,
is_beta: false as boolean,
latest_version: "" as string,
latest_beta_version: "" as string,
}),
Expand Down

0 comments on commit f44ea0b

Please sign in to comment.