Skip to content

Commit

Permalink
fix: 🚑 Don't make Request help page editable
Browse files Browse the repository at this point in the history
  • Loading branch information
albinmedoc committed Aug 2, 2024
1 parent 7024735 commit 2fb31ca
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 6 deletions.
66 changes: 66 additions & 0 deletions apps/wizarr-frontend/src/modules/help/components/Request.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<div class="flex flex-col space-y-4">
<div>
<h4 class="mb-3 text-xl font-bold dark:text-white">{{ __("Automatic Media Requests") }}</h4>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">
{{ __("We are excited to offer you a wide selection of media to choose from. If you're having trouble finding something you like, don't worry! We have a user-friendly request system that can automatically search for the media you're looking for.") }}
</p>
</div>

<ul class="space-y-2 text-left text-gray-500 dark:text-gray-400">
<li class="flex items-center space-x-3">
<i class="fas fa-check text-green-500 dark:text-green-400"></i>
<span>{{ __("Request any available Movie or TV Show") }}</span>
</li>
<li class="flex items-center space-x-3">
<i class="fas fa-check text-green-500 dark:text-green-400"></i>
<span>{{ __("Media will be automatically downloaded to your library") }}</span>
</li>
<li class="flex items-center space-x-3">
<i class="fas fa-check text-green-500 dark:text-green-400"></i>
<span>{{ __("You can recieve notifications when your media is ready") }}</span>
</li>
</ul>

<div class="flex justify-end pt-4">
<FormKit type="button" suffixIcon="fas fa-external-link-alt" @click="openURL">
{{ __("Check it Out") }}
</FormKit>
</div>
</div>
</template>

<script lang="ts">
import type { Requests } from "@/types/api/request";
import { defineComponent, defineAsyncComponent } from "vue";
export default defineComponent({
name: "Request",
props: {
requestURL: {
type: Array as () => Requests,
required: true,
},
},
methods: {
async selectURL() {
const RequestsList = defineAsyncComponent(() => import("./RequestsList.vue"));
this.$modal.openModal(RequestsList, {
title: "Select Request Server",
props: {
requestURLS: this.requestURL,
},
});
},
async openURL() {
if (this.requestURL.length === 1) {
window.open(this.requestURL[0].url, "_blank");
return;
}
this.selectURL();
},
},
});
</script>
66 changes: 66 additions & 0 deletions apps/wizarr-frontend/src/modules/help/components/RequestsList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<div class="flex flex-col space-y-2">
<template v-for="request in requests">
<ListItem :svg-string="request.icon">
<template #title>
<span class="text-lg">{{ request.name }}</span>
</template>
<template #buttons>
<div class="flex flex-row space-x-2">
<FormKit type="button" data-theme="secondary" @click="openURL(request.url)" :classes="{ input: '!bg-secondary !px-3.5 h-[36px]' }">
<i class="fa-solid fa-external-link"></i>
</FormKit>
</div>
</template>
</ListItem>
</template>
</div>
</template>

<script lang="ts">
import type { Requests, Request } from "@/types/api/request";
import { defineComponent } from "vue";
import ListItem from "@/components/ListItem.vue";
interface CustomRequest extends Request {
icon: string;
}
export default defineComponent({
name: "RequestsList",
components: {
ListItem,
},
props: {
requestURLS: {
type: Array as () => Requests,
required: true,
},
},
data() {
return {
requests: [] as CustomRequest[],
};
},
methods: {
openURL(url: string) {
window.open(url, "_blank");
},
async loadIcon(request: Request) {
return await import(`../../../assets/img/logo/${request.service}.svg?raw`);
},
},
async beforeMount() {
const requests = this.requestURLS;
requests.forEach(async (request) => {
const icon = await this.loadIcon(request);
this.requests.push({
...request,
icon: icon.default ?? "",
});
});
},
});
</script>
10 changes: 10 additions & 0 deletions apps/wizarr-frontend/src/modules/help/views/Help.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import WizarrLogo from "@/components/WizarrLogo.vue";
import LanguageSelector from "@/components/Buttons/LanguageSelector.vue";
import ThemeToggle from "@/components/Buttons/ThemeToggle.vue";
import Request from "../components/Request.vue";
import Discord from "../components/Discord.vue";
import Custom from "../components/Custom.vue";
Expand Down Expand Up @@ -92,6 +93,15 @@ export default defineComponent({
};
}),
);
if (!!this.requests.length) {
views.push({
name: "request",
view: Request,
props: {
requestURL: this.requests,
},
});
}
if (!!this.settings.server_discord_id) {
views.push({
name: "discord",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<OnboardingSection v-for="page in fixedOnboardingPages" .key="page.id" @clickEdit="editPage(page, true)" disabledReorder disableDelete>
<MdPreview :modelValue="page.value" :theme="currentTheme" :sanitize="sanitize" language="en-US" />
</OnboardingSection>
<OnboardingSection v-if="!!requests.length" disabledReorder disableDelete disableEdit>
<Request :requestURL="requests" />
</OnboardingSection>
<OnboardingSection v-if="!!settings.server_discord_id" disabledReorder disableDelete disableEdit>
<Discord />
</OnboardingSection>
Expand All @@ -25,6 +28,7 @@ import { useGettext } from "vue3-gettext";
import { useServerStore } from "@/stores/server";
import { useThemeStore } from "@/stores/theme";
import { useOnboardingStore } from "@/stores/onboarding";
import Request from "@/modules/help/components/Request.vue";
import Discord from "@/modules/help/components/Discord.vue";
import OnboardingSection from "../components/Onboarding/OnboardingSection.vue";
import EditOnboarding from "../components/Modals/EditOnboarding.vue";
Expand All @@ -37,6 +41,7 @@ export default defineComponent({
name: "Onboarding",
components: {
OnboardingSection,
Request,
Discord,
MdPreview,
},
Expand Down
6 changes: 0 additions & 6 deletions apps/wizarr-frontend/src/stores/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export enum FixedOnboardingPageType {
DownloadJellyfin = 4,
WelcomeEmby = 5,
DownloadEmby = 6,
Request = 7,
}

// Define the shape of the state in this store
Expand Down Expand Up @@ -56,11 +55,6 @@ export const useOnboardingStore = defineStore('onboarding', {
if(downloadPage) filteredPages.push(downloadPage);
}

if (!!serverStore.requests.length) {
const requestPage = pages.find((page) => page.id === FixedOnboardingPageType.Request);
if(requestPage) filteredPages.push(requestPage);
}

return filteredPages.sort((a, b) => a.id - b.id);
},
onboardingVariables: () => {
Expand Down

0 comments on commit 2fb31ca

Please sign in to comment.