Skip to content

Commit 5a2c3e8

Browse files
committed
Suggestions from code review. Code format error text in error details. Handling failed debug zip generation case.
1 parent f73b0ac commit 5a2c3e8

File tree

6 files changed

+89
-42
lines changed

6 files changed

+89
-42
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
dist
33
*.syso
44

5-
65
.DS_Store
76

7+
# Specifically allow the provided code workspace with the multi-root workaround
8+
!.vscode/SatisfactoryModManager.code-workspace
9+
810
# Created by https://www.toptal.com/developers/gitignore/api/goland+all,go,visualstudiocode
911
# Edit at https://www.toptal.com/developers/gitignore?templates=goland+all,go,visualstudiocode
1012

@@ -126,8 +128,6 @@ fabric.properties
126128
!.vscode/launch.json
127129
!.vscode/extensions.json
128130
!.vscode/*.code-snippets
129-
# Specifically allow the provided code workspace with the multi-root workaround
130-
!.vscode/SatisfactoryModManager.code-workspace
131131

132132
# Local History for Visual Studio Code
133133
.history/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ or run `pnpm translations` to update the translation data.
7373

7474
Make sure that your IDE is connecting with the frontend's installation of ESLint to get the best experience.
7575

76-
VSCode users, a preconfigured workspace is provided in `./vscode`
76+
VSCode users, a preconfigured workspace is provided in `.vscode/`
7777
that allows editing both Go and Svelte files
7878
while maintaining correct ESLint functionality.
7979

backend/app/debug_info.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (a *app) generateAndSaveDebugInfo(filename string) error {
204204
return nil
205205
}
206206

207-
func (a *app) GenerateDebugInfo() bool {
207+
func (a *app) GenerateDebugInfo() (bool, error) {
208208
defaultFileName := fmt.Sprintf("SMMDebug-%s.zip", time.Now().UTC().Format("2006-01-02-15-04-05"))
209209
filename, err := wailsRuntime.SaveFileDialog(appCommon.AppContext, wailsRuntime.SaveDialogOptions{
210210
DefaultFilename: defaultFileName,
@@ -217,18 +217,18 @@ func (a *app) GenerateDebugInfo() bool {
217217
})
218218
if err != nil {
219219
slog.Error("failed to open save dialog", slog.Any("error", err))
220-
return false
220+
return false, err
221221
}
222222
if filename == "" {
223-
slog.Error("failed to save, filename was empty, the user might have cancelled the dialog")
224-
return false
223+
// user canceled the save dialog
224+
return false, nil
225225
}
226226

227227
err = a.generateAndSaveDebugInfo(filename)
228228
if err != nil {
229229
slog.Error("failed to generate debug info", slog.Any("error", err))
230-
return false
230+
return false, err
231231
}
232232

233-
return true
233+
return true, nil
234234
}

frontend/src/App.svelte

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,20 @@
239239
<ErrorDetails
240240
error={''}
241241
fullPageMode={true}
242-
parent={{ onClose: () => {} }}
243242
>
244-
<!-- Svelte slots don't support dynamic passing, so this is kinda ugly. Switch to snippets once in svelte 5 https://github.com/sveltejs/svelte/issues/7651-->
245-
<T
246-
slot="title"
247-
defaultValue={noInstallsError ? 'No Satisfactory installs found' : '{invalidInstalls} invalid Satisfactory {invalidInstalls, plural, one {install} other {installs}} found'}
248-
keyName={noInstallsError ? 'error.no_installs' : 'error.invalid_installs'}
249-
params={{ invalidInstalls: $invalidInstalls.length }}
250-
/>
243+
<svelte:fragment slot="title">
244+
{#if noInstallsError}
245+
<T
246+
defaultValue="No Satisfactory installs found"
247+
keyName="error.no_installs"
248+
/>
249+
{:else}
250+
<T
251+
defaultValue={'{invalidInstalls} invalid Satisfactory {invalidInstalls, plural, one {install} other {installs}} found'}
252+
keyName="error.invalid_installs"
253+
params={{ invalidInstalls: $invalidInstalls.length }} />
254+
{/if}
255+
</svelte:fragment>
251256
</ErrorDetails>
252257
</div>
253258
</ModsList>

frontend/src/lib/components/modals/ErrorDetails.svelte

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,78 @@
11
<script lang="ts">
2+
import { type PopupSettings, popup } from '@skeletonlabs/skeleton';
23
import { getTranslate } from '@tolgee/svelte';
34
45
import T from '$lib/components/T.svelte';
6+
import Tooltip from '$lib/components/Tooltip.svelte';
57
import { GenerateDebugInfo } from '$wailsjs/go/app/app';
6-
import { BrowserOpenURL } from '$wailsjs/runtime/runtime';
8+
import { BrowserOpenURL, LogError } from '$wailsjs/runtime/runtime';
79
8-
export let parent: { onClose: () => void };
10+
export let onClose: (() => void) | null = null;
911
1012
export let fullPageMode: boolean = false;
11-
let sectionClass: string = fullPageMode ? 'p-4' : 'px-4';
13+
$: sectionClass = fullPageMode ? 'p-4' : 'px-4';
1214
13-
let openDiscordTooltipText: string;
1415
const { t } = getTranslate();
15-
t.subscribe((getTranslationText) => {
16-
openDiscordTooltipText = getTranslationText(
17-
'error.open_modding_discord.must_generate_debug_first',
18-
'You must generate debug info first',
19-
);
20-
});
16+
$: openDiscordTooltipText = $t(
17+
'error.open_modding_discord.must_generate_debug_first',
18+
'You must generate debug info first',
19+
);
2120
2221
let allowOpeningDiscord: boolean = false;
22+
let debugFileGenerationError: boolean = false;
2323
2424
let onClickGenerateDebugInfo = async () => {
25-
let didUserSaveFile = await GenerateDebugInfo();
26-
if (didUserSaveFile) {
25+
try {
26+
let didUserSaveFile = await GenerateDebugInfo();
27+
if (didUserSaveFile) {
28+
// Explicitly set to true -> if people click to save a second time but cancel, don't lock them out
29+
allowOpeningDiscord = true;
30+
}
31+
} catch (error) {
32+
LogError(`GenerateDebugInfo failed: ${error}`);
33+
debugFileGenerationError = true;
34+
// Enable the Discord button so they can report the error
2735
allowOpeningDiscord = true;
28-
openDiscordTooltipText = '';
29-
} else {
30-
alert(
31-
'Failed to generate and save the debug info file. Did you click the Cancel button? If not, manually check your Satisfactory Mod Manager log files for more information: https://docs.ficsit.app/satisfactory-modding/latest/faq.html#Files_Logs',
32-
);
3336
}
3437
};
3538
3639
let OpenDiscord = () => {
3740
BrowserOpenURL('https://discord.ficsit.app/');
3841
};
42+
43+
let OpenLogDocs = () => {
44+
BrowserOpenURL('https://docs.ficsit.app/satisfactory-modding/latest/faq.html#Files_Logs');
45+
};
46+
47+
const popupId = 'error-details-open-discord-popup';
48+
const openDiscordPopup = {
49+
event: 'hover',
50+
target: popupId,
51+
middleware: {
52+
offset: 4,
53+
},
54+
placement: 'bottom-end',
55+
} satisfies PopupSettings;
56+
3957
export let error: string;
4058
</script>
4159

42-
<!-- Replace with svelte snippets once in Svelte 5 -->
4360
<header class="card-header font-bold text-2xl text-center">
4461
<slot name="title" />
4562
</header>
4663
<section class={`${sectionClass} overflow-y-auto`}>
47-
<p>{error}</p>
64+
<p class="font-mono">{error}</p>
4865
</section>
4966
<section class={sectionClass}>
5067
<p class={fullPageMode ? 'text-base text-center' : ''}>
5168
<T
52-
defaultValue="Seems wrong? Click the button below to gather logs, then send the generated zip file on the modding discord in #help-using-mods."
69+
defaultValue="Seems wrong? Click the button below to gather logs, then send the generated zip file on the modding Discord in #help-using-mods."
5370
keyName="error.reporting_directions"
5471
/>
5572
</p>
5673
</section>
5774
<section class={sectionClass}>
58-
<p class="text-base text-center">
75+
<p class="text-base">
5976
<button
6077
class="btn text-primary-600 variant-ringed"
6178
on:click={onClickGenerateDebugInfo}
@@ -68,19 +85,44 @@
6885
<button
6986
class="btn text-primary-600 variant-ringed"
7087
disabled={!allowOpeningDiscord}
71-
title={openDiscordTooltipText}
7288
on:click={OpenDiscord}
89+
use:popup={openDiscordPopup}
7390
>
7491
<T
7592
defaultValue="Open the Modding Discord"
7693
keyName="error.open_modding_discord"
7794
/>
7895
</button>
96+
<Tooltip disabled={allowOpeningDiscord} {popupId}>
97+
{openDiscordTooltipText}
98+
</Tooltip>
7999
</p>
80100
</section>
101+
{#if debugFileGenerationError}
102+
<section class={sectionClass}>
103+
<p class="text-base text-red-500">
104+
<T
105+
defaultValue="An error occurred while generating the debug file. Please manually check your Satisfactory Mod Manager log files for more information and report this on the Discord. Use the button below to open the documentation and learn how."
106+
keyName="error.failed_to_generate_debug"
107+
/>
108+
</p>
109+
</section>
110+
<section class={sectionClass}>
111+
<button
112+
class="btn text-primary-600 variant-ringed"
113+
on:click={OpenLogDocs}
114+
>
115+
<T
116+
defaultValue="Open the Logging Documentation"
117+
keyName="error.open_log_docs"
118+
/>
119+
</button>
120+
</section>
121+
{/if}
81122
{#if !fullPageMode}
82123
<footer class="card-footer">
83-
<button class="btn" on:click={parent.onClose}>
124+
<!-- Must lambda the onClose call for type matching to be happy -->
125+
<button class="btn" on:click={onClose}>
84126
<T defaultValue="Close" keyName="common.close" />
85127
</button>
86128
</footer>

frontend/src/lib/components/modals/ErrorModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
style="max-height: calc(100vh - 3rem); max-width: calc(100vw - 3rem);"
1313
class="w-[48rem] card flex flex-col gap-6"
1414
>
15-
<ErrorDetails {error} {parent}>
15+
<ErrorDetails {error} onClose={parent.onClose}>
1616
<T slot="title" defaultValue="Something went wrong" keyName="error.title" />
1717
</ErrorDetails>
1818
</div>

0 commit comments

Comments
 (0)