Add Changelog Modal component and fix import path in AutoUpdaterService

This commit is contained in:
Shidorien
2023-12-21 00:48:21 +01:00
parent 214ffc243d
commit ec0d2fb8c6
3 changed files with 19 additions and 16 deletions
@@ -0,0 +1,4 @@
.content * {
all: revert;
}
@@ -1,15 +1,14 @@
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import { useTranslation } from "renderer/hooks/use-translation.hook";
import { Changelog, ChangelogVersion } from "renderer/services/auto-updater.service";
import { ChangelogVersion } from "renderer/services/auto-updater.service";
import { LinkOpenerService } from "renderer/services/link-opener.service";
import { ModalComponent } from "renderer/services/modale.service";
import BeatRunning from "../../../../../assets/images/apngs/beat-running.png";
import { data } from "autoprefixer";
import BeatRunning from "../../../../../../assets/images/apngs/beat-running.png";
import DOMPurify from 'dompurify';
import './changelog-modal.component.css';
export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ resolver, data: changelog }) => {
console.log(changelog)
const linkOpener: LinkOpenerService = LinkOpenerService.getInstance();
const openGithub = () => linkOpener.open("https://github.com/Zagrios/bs-manager");
const openTwitter = () => linkOpener.open("https://twitter.com/BSManager_");
@@ -22,19 +21,19 @@ export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ resolve
<h1 className="text-3xl uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200">{changelog?.title}</h1>
<BsmImage className="mx-auto h-20" image={BeatRunning} />
<div className="relative h-80 ">
<div className=" absolute overflow-y-scroll h-full content grow" dangerouslySetInnerHTML={{ __html: changelog?.htmlBody }}/>
<div className=" absolute overflow-y-scroll h-full content grow" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(changelog?.htmlBody) }}/>
</div>
<span className="block w-[60%] mx-auto my-[16px] h-[2px] rounded-full bg-main-color-2" />
<span className="block w-[95%] mx-auto my-[16px] h-[3px] rounded-full bg-main-color-1" />
<div className=" flex flex-row justify-between">
<span><i>{formattedTimestamp}</i></span>
<span><i>{changelog?.version}</i></span>
</div>
<div className="flex gap-1 mt-2">
<BsmButton onClick={openGithub} className=" rounded-md h-6 p-1 bg-transparent" icon="github" withBar={false}/>
<BsmButton onClick={openTwitter} className=" rounded-md h-6 p-1" icon="twitter" withBar={false}/>
<BsmButton onClick={openSupportPage} className=" rounded-md h-6 p-1" icon="patreon" withBar={false}/>
<BsmButton onClick={openDiscord} className=" rounded-md h-6 p-[5px]" icon="discord" withBar={false}/>
</div>
<div className="flex gap-2 mt-1 justify-end h-7">
<BsmButton onClick={openTwitter} className="rounded-md p-1" icon="twitter" withBar={false} color="#1DA1F2" iconColor="#FFFFFF"/>
<BsmButton onClick={openGithub} className="rounded-md p-1" icon="github" withBar={false} color="#000000" iconColor="#FFFFFF"/>
<BsmButton onClick={openDiscord} className="rounded-md p-1" icon="discord" withBar={false} color="#5865F2" iconColor="#FFFFFF"/>
<BsmButton onClick={openSupportPage} className="rounded-md p-1" icon="patreon" withBar={false} color="#FF424D" iconColor="#FFFFFF"/>
</div>
</form>
)
}
@@ -4,7 +4,7 @@ import { IpcService } from "./ipc.service";
import { ProgressBarService } from "./progress-bar.service";
import { I18nService } from "./i18n.service";
import { ModalService } from "renderer/services/modale.service";
import { ChangelogModal } from "renderer/components/modal/modal-types/changelog-modal.component";
import { ChangelogModal } from "renderer/components/modal/modal-types/chabgelog-modal/changelog-modal.component";
import { error } from "console";
@@ -86,12 +86,12 @@ export class AutoUpdaterService {
private async getChangelogVersion(version:string): Promise<ChangelogVersion> {
const changelogs = await this.getChangelog();
if (!changelogs) {
throw new Error("No changelog found");
throw new Error(`No changelogs found`);
}
const changelogVersion = changelogs[version];
if (!changelogVersion) {
throw new Error("No changelog found for this version");
throw new Error(`No changelog found for this version (${version})`);
}