1
1
<script setup>
2
- import { XIcon , HammerIcon , LogInIcon , UpdatedIcon } from ' @modrinth/assets'
2
+ import {
3
+ CheckIcon ,
4
+ DropdownIcon ,
5
+ XIcon ,
6
+ HammerIcon ,
7
+ LogInIcon ,
8
+ UpdatedIcon ,
9
+ CopyIcon ,
10
+ } from ' @modrinth/assets'
3
11
import { ChatIcon } from ' @/assets/icons'
4
- import { ref } from ' vue'
12
+ import { ButtonStyled , Collapsible } from ' @modrinth/ui'
13
+ import { ref , computed } from ' vue'
5
14
import { login as login_flow , set_default_user } from ' @/helpers/auth.js'
6
15
import { handleError } from ' @/store/notifications.js'
7
16
import { handleSevereError } from ' @/store/error.js'
@@ -13,6 +22,7 @@ import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
13
22
const errorModal = ref ()
14
23
const error = ref ()
15
24
const closable = ref (true )
25
+ const errorCollapsed = ref (false )
16
26
17
27
const title = ref (' An error occurred' )
18
28
const errorType = ref (' unknown' )
@@ -118,6 +128,26 @@ async function repairInstance() {
118
128
}
119
129
loadingRepair .value = false
120
130
}
131
+
132
+ const hasDebugInfo = computed (
133
+ () =>
134
+ errorType .value === ' directory_move' ||
135
+ errorType .value === ' minecraft_auth' ||
136
+ errorType .value === ' state_init' ||
137
+ errorType .value === ' no_loader_version' ,
138
+ )
139
+
140
+ const debugInfo = computed (() => error .value .message ?? error .value ?? ' No error message.' )
141
+
142
+ const copied = ref (false )
143
+
144
+ async function copyToClipboard (text ) {
145
+ await navigator .clipboard .writeText (text)
146
+ copied .value = true
147
+ setTimeout (() => {
148
+ copied .value = false
149
+ }, 3000 )
150
+ }
121
151
< / script>
122
152
123
153
< template>
@@ -244,33 +274,49 @@ async function repairInstance() {
244
274
< / div>
245
275
< / template>
246
276
< template v- else >
247
- {{ error.message ?? error }}
277
+ {{ debugInfo }}
248
278
< / template>
249
- <template
250
- v-if ="
251
- errorType === ' directory_move' ||
252
- errorType === ' minecraft_auth' ||
253
- errorType === ' state_init' ||
254
- errorType === ' no_loader_version'
255
- "
256
- >
279
+ < template v- if = " hasDebugInfo" >
257
280
< hr / >
258
281
< p>
259
282
If nothing is working and you need help, visit
260
283
< a : href= " supportLink" > our support page< / a>
261
284
and start a chat using the widget in the bottom right and we will be more than happy to
262
285
assist! Make sure to provide the following debug information to the agent:
263
286
< / p>
264
- <details >
265
- <summary >Debug information</summary >
266
- {{ error.message ?? error }}
267
- </details >
268
287
< / template>
269
288
< / div>
270
- <div class =" input-group push-right" >
271
- <a :href =" supportLink" class =" btn" @click =" errorModal.hide()" ><ChatIcon /> Get support</a >
272
- <button v-if =" closable" class =" btn" @click =" errorModal.hide()" ><XIcon /> Close</button >
289
+ < div class = " flex items-center gap-2" >
290
+ < ButtonStyled>
291
+ < a : href= " supportLink" @click= " errorModal.hide()" >< ChatIcon / > Get support< / a>
292
+ < / ButtonStyled>
293
+ < ButtonStyled v- if = " closable" >
294
+ < button @click= " errorModal.hide()" >< XIcon / > Close< / button>
295
+ < / ButtonStyled>
296
+ < ButtonStyled v- if = " hasDebugInfo" >
297
+ < button : disabled= " copied" @click= " copyToClipboard(debugInfo)" >
298
+ < template v- if = " copied" > < CheckIcon class = " text-green" / > Copied! < / template>
299
+ < template v- else > < CopyIcon / > Copy debug info < / template>
300
+ < / button>
301
+ < / ButtonStyled>
273
302
< / div>
303
+ < template v- if = " hasDebugInfo" >
304
+ < div class = " bg-button-bg rounded-xl mt-2 overflow-clip" >
305
+ < button
306
+ class = " flex items-center justify-between w-full bg-transparent border-0 px-4 py-3 cursor-pointer"
307
+ @click= " errorCollapsed = !errorCollapsed"
308
+ >
309
+ < span class = " text-contrast font-extrabold m-0" > Debug information: < / span>
310
+ < DropdownIcon
311
+ class = " h-5 w-5 text-secondary transition-transform"
312
+ : class = " { 'rotate-180': !errorCollapsed }"
313
+ / >
314
+ < / button>
315
+ < Collapsible : collapsed= " errorCollapsed" >
316
+ < pre class = " m-0 px-4 py-3 bg-bg rounded-none" > {{ debugInfo }}< / pre>
317
+ < / Collapsible>
318
+ < / div>
319
+ < / template>
274
320
< / div>
275
321
< / ModalWrapper>
276
322
< / template>
0 commit comments