-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from UnofficialCrusaderPatch/troubleshooter-d…
…ialog Troubleshooter dialog
- Loading branch information
Showing
6 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/components/top-bar/troubleshooting/troubleshooting-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Message from '../../general/message'; | ||
import { setOverlayContent } from '../../overlay/overlay'; | ||
import { Troubleshooting } from '../../troubleshooting/troubleshooting-window'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export function TroubleShootingButton() { | ||
return ( | ||
<button | ||
type="button" | ||
className="reload-button" | ||
onClick={async () => { | ||
setOverlayContent(Troubleshooting, true, true); | ||
}} | ||
> | ||
<Message message="troubleshooting.button" /> | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { atom, useAtomValue } from 'jotai'; | ||
import { TROUBLESHOOTING_MD_CONTENT_ATOM } from '../../function/troubleshooting/state'; | ||
import Message from '../general/message'; | ||
import { SaferMarkdown } from '../markdown/safer-markdown'; | ||
import { OverlayContentProps } from '../overlay/overlay'; | ||
|
||
export const TROUBLESHOOTING_MD_ATOM = atom((get) => { | ||
const { isSuccess, data } = get(TROUBLESHOOTING_MD_CONTENT_ATOM); | ||
|
||
if (!isSuccess) { | ||
return ( | ||
<SaferMarkdown> | ||
Cannot display Troubleshooting document at this time | ||
</SaferMarkdown> | ||
); | ||
} | ||
|
||
return <SaferMarkdown>{data}</SaferMarkdown>; | ||
}); | ||
|
||
export function Troubleshooting(props: OverlayContentProps) { | ||
const { closeFunc } = props; | ||
const md = useAtomValue(TROUBLESHOOTING_MD_ATOM); | ||
return ( | ||
<div className="credits-container"> | ||
<h1 className="credits-title"> | ||
<Message message="troubleshooting.title" /> | ||
</h1> | ||
<div | ||
className="parchment-box credits-text-box" | ||
style={{ | ||
backgroundColor: '#0d1117', | ||
backgroundImage: 'none', | ||
}} | ||
> | ||
<div className="credits-text text-light">{md}</div> | ||
</div> | ||
<button | ||
type="button" | ||
className="ucp-button credits-close" | ||
onClick={closeFunc} | ||
> | ||
<Message message="close" /> | ||
</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { atomWithQuery } from 'jotai-tanstack-query'; | ||
import { ResponseType } from '@tauri-apps/api/http'; | ||
import { fetch } from '../../tauri/tauri-http'; | ||
|
||
// https://raw.githubusercontent.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch/refs/heads/main/TROUBLESHOOTING.md | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const TROUBLESHOOTING_MD_CONTENT_ATOM = atomWithQuery(() => ({ | ||
queryKey: ['troubleshooting'], | ||
queryFn: async () => { | ||
const request = await fetch<string>( | ||
'https://raw.githubusercontent.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch/refs/heads/main/TROUBLESHOOTING.md', | ||
{ | ||
responseType: ResponseType.Text, | ||
method: 'GET', | ||
}, | ||
); | ||
|
||
if (!request.ok) { | ||
return 'Failed to fetch Troubleshooting document'; | ||
} | ||
|
||
return request.data; | ||
}, | ||
staleTime: Infinity, | ||
})); |