Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions apps/app-frontend/src/components/ui/ErrorModal.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup>
import {
CheckIcon,
CopyIcon,
DropdownIcon,
FolderOpenIcon,
HammerIcon,
LogInIcon,
TextSearchIcon,
UpdatedIcon,
WrenchIcon,
XIcon,
Expand All @@ -15,7 +15,6 @@ import {
ButtonLink,
Collapsible,
defineMessages,
IconButton,
injectNotificationManager,
useVIntl,
} from '@modrinth/ui'
Expand All @@ -29,11 +28,22 @@ import { login as login_flow, set_default_user } from '@/helpers/auth.js'
import { install_existing_instance } from '@/helpers/install'
import { cancel_directory_change } from '@/helpers/settings.ts'
import { showAppDbBackupsFolder } from '@/helpers/utils.js'
import { openExternalUrl } from '@/platform/external-links'
import { useCopyAsPaste } from '@/shared/composables/use-copy-as-paste'

const { handleError } = injectNotificationManager()
const copyAsPaste = useCopyAsPaste()
const { formatMessage } = useVIntl()

const messages = defineMessages({
inspectDebugInfo: {
id: 'app.error.inspect-debug-info',
defaultMessage: 'Inspect debug info',
},
copiedDebugInfo: {
id: 'app.error.copied-debug-info',
defaultMessage: 'Copied',
},
openBackupsFolder: {
id: 'app.error.state-init.open-backups-folder',
defaultMessage: 'Open backups folder',
Expand Down Expand Up @@ -159,9 +169,16 @@ const hasDebugInfo = computed(
const debugInfo = computed(() => error.value.message ?? error.value ?? 'No error message.')

const copied = ref(false)
const copying = ref(false)

async function copyToClipboard(text) {
await navigator.clipboard.writeText(text)
async function inspectDebugInfo(text) {
copying.value = true
try {
const url = await copyAsPaste(text)
if (url) await openExternalUrl(url)
} finally {
copying.value = false
}
copied.value = true
setTimeout(() => {
copied.value = false
Expand Down Expand Up @@ -316,9 +333,7 @@ async function copyToClipboard(text) {
/>
</button>
<Collapsible :collapsed="errorCollapsed">
<div
class="p-3 bg-surface-2 rounded-2xl text-xs grid grid-cols-[1fr_auto] max-w-full items-start"
>
<div class="p-3 bg-surface-2 rounded-2xl text-xs flex flex-col gap-3 max-w-full">
<div
class="m-0 p-0 rounded-none bg-transparent text-sm font-mono break-words overflow-auto"
>
Expand All @@ -328,15 +343,17 @@ async function copyToClipboard(text) {
{{ formatMessage(messages.openBackupsFolder) }}
</button>
</div>
<IconButton
v-tooltip="'Copy debug info'"
:label="'Copy debug info'"
:disabled="copied"
@click="copyToClipboard(debugInfo)"
<Button
type="outlined"
size="xs"
class="w-fit"
:disabled="copied || copying"
@click="inspectDebugInfo(debugInfo)"
>
<template v-if="copied"> <CheckIcon class="text-green" /> </template>
<template v-else> <CopyIcon /> </template>
</IconButton>
<CheckIcon v-if="copied" />
<TextSearchIcon v-else />
{{ formatMessage(copied ? messages.copiedDebugInfo : messages.inspectDebugInfo) }}
</Button>
</div>
</Collapsible>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import {
BoxIcon,
CheckIcon,
CopyIcon,
DownloadIcon,
MinecraftServerIcon,
PauseIcon,
PlayIcon,
TextSearchIcon,
TrashIcon,
UpdatedIcon,
UploadIcon,
Expand Down Expand Up @@ -57,7 +57,10 @@ const messages = defineMessages({
pause: { id: 'app.download-manager.pause', defaultMessage: 'Pause installation' },
resume: { id: 'app.download-manager.resume', defaultMessage: 'Resume installation' },
retry: { id: 'app.action-bar.install.retry', defaultMessage: 'Retry' },
copyDetails: { id: 'app.action-bar.install.copy-details', defaultMessage: 'Copy details' },
inspectDetails: {
id: 'app.action-bar.install.inspect-details',
defaultMessage: 'Inspect details',
},
copied: { id: 'app.action-bar.install.copied-details', defaultMessage: 'Copied' },
dismiss: { id: 'app.action-bar.install.dismiss', defaultMessage: 'Dismiss' },
cancel: { id: 'app.download-manager.cancel', defaultMessage: 'Cancel installation' },
Expand Down Expand Up @@ -236,8 +239,8 @@ const instanceLink = computed(() =>
@click="$emit('copyDetails', job.id)"
>
<CheckIcon v-if="job.copied" />
<CopyIcon v-else />
{{ formatMessage(job.copied ? messages.copied : messages.copyDetails) }}
<TextSearchIcon v-else />
{{ formatMessage(job.copied ? messages.copied : messages.inspectDetails) }}
</Button>
<Button
v-if="job.canRetry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ import {
install_job_pause,
install_job_resume,
install_job_retry,
install_job_support_details,
installJobInstanceId,
type InstallJobSnapshot,
} from '@/helpers/install'
import { get_many as getInstances } from '@/helpers/instance'
import {
getInstallJobSupportDetails,
getInstallJobSupportPasteUrl,
setInstallJobSupportPasteUrl,
} from '@/platform/app-lib/install/commands'
import { openExternalUrl } from '@/platform/external-links'
import { injectAppEvents } from '@/providers/app-events'
import { useCopyAsPaste } from '@/shared/composables/use-copy-as-paste'

import { debugInfoExports, type DebugInfoExportTask } from './debug-info-export'
import { createDownloadTransferTracker } from './download-transfer'
Expand Down Expand Up @@ -109,6 +115,7 @@ export function useDownloadManager() {
const events = injectAppEvents()
const { handleError } = injectNotificationManager()
const appSettings = useAppSettings()
const copyAsPaste = useCopyAsPaste()
const display = useInstallJobDisplay()
const { formatMessage } = useVIntl()
const formatBytes = useFormatBytes()
Expand Down Expand Up @@ -530,18 +537,31 @@ export function useDownloadManager() {
await Promise.all(completedJobs.value.map((job) => dismiss(job.id)))
}

async function copyInstallJobDetails(id: string) {
const cached = await getInstallJobSupportPasteUrl(id)
if (cached) {
await navigator.clipboard.writeText(cached)
return cached
}
const { details, finished_modified } = await getInstallJobSupportDetails(id)
const url = await copyAsPaste(details)
if (url && finished_modified !== null) {
await setInstallJobSupportPasteUrl(id, url, finished_modified)
}
return url
}

async function copyDetails(id: string) {
await runAction(id, async () => {
const publish = sharedInstancePublishes.value.get(id)
const file = externalFileDownloads.value.get(id) ?? debugInfoExports.value.get(id)
const details = publish
? (publish.details ?? publish.error ?? '')
const url = publish
? await copyAsPaste(publish.details ?? publish.error ?? '')
: file
? (file.error ?? '')
: await install_job_support_details(id)
if (disposed) return
await navigator.clipboard.writeText(details)
? await copyAsPaste(file.error ?? '')
: await copyInstallJobDetails(id)
if (disposed) return
if (url) await openExternalUrl(url)
copiedJobs.value.add(id)
clearTimeout(copiedTimeouts.get(id))
copiedTimeouts.set(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<script setup lang="ts">
import {
CheckIcon,
CopyIcon,
DropdownIcon,
LogInIcon,
MessagesSquareIcon,
TextSearchIcon,
WrenchIcon,
} from '@modrinth/assets'
import { Admonition, Button, ButtonLink, Collapsible, IconButton, NewModal } from '@modrinth/ui'
import { Admonition, Button, ButtonLink, Collapsible, NewModal } from '@modrinth/ui'
import { computed, ref } from 'vue'

import { handleSevereError } from '@/composables/use-error.js'
import { login as login_flow, set_default_user } from '@/helpers/auth.js'
import { openExternalUrl } from '@/platform/external-links'
import { useCopyAsPaste } from '@/shared/composables/use-copy-as-paste'

import { type MinecraftAuthError, minecraftAuthErrors } from './minecraft-auth-errors'

Expand All @@ -20,6 +22,8 @@ const rawError = ref<string>('')
const matchedError = ref<MinecraftAuthError | null>(null)
const debugCollapsed = ref(true)
const copied = ref(false)
const copying = ref(false)
const copyAsPaste = useCopyAsPaste()
const loadingSignIn = ref(false)

function show(errorVal: { message?: string; code?: string }) {
Expand Down Expand Up @@ -57,8 +61,14 @@ async function signInAgain() {

const debugInfo = computed(() => rawError.value || 'No error message.')

async function copyToClipboard(text: string) {
await navigator.clipboard.writeText(text)
async function inspectDebugInfo(text: string) {
copying.value = true
try {
const url = await copyAsPaste(text)
if (url) await openExternalUrl(url)
} finally {
copying.value = false
}
copied.value = true
setTimeout(() => {
copied.value = false
Expand Down Expand Up @@ -163,23 +173,23 @@ async function copyToClipboard(text: string) {
/>
</button>
<Collapsible :collapsed="debugCollapsed">
<div
class="p-3 bg-surface-2 rounded-2xl text-xs grid grid-cols-[1fr_auto] max-w-full items-start"
>
<div class="p-3 bg-surface-2 rounded-2xl text-xs flex flex-col gap-3 max-w-full">
<div
class="m-0 p-0 rounded-none bg-transparent text-sm font-mono break-words overflow-auto"
>
{{ debugInfo }}
</div>
<IconButton
v-tooltip="'Copy debug info'"
:label="'Copy debug info'"
:disabled="copied"
@click="copyToClipboard(debugInfo)"
<Button
type="outlined"
size="xs"
class="w-fit"
:disabled="copied || copying"
@click="inspectDebugInfo(debugInfo)"
>
<template v-if="copied"> <CheckIcon class="text-green" /> </template>
<template v-else> <CopyIcon /> </template>
</IconButton>
<CheckIcon v-if="copied" />
<TextSearchIcon v-else />
{{ copied ? 'Copied' : 'Inspect debug info' }}
</Button>
</div>
</Collapsible>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import { useAppSettings } from '@/composables/use-app-settings.ts'
import { get_ads_debug_state } from '@/helpers/ads.js'
import { purge_cache_types } from '@/helpers/cache.js'
import { appSettingsKeys, get, set } from '@/helpers/settings.ts'
import { copyToClipboard, showAppDbBackupsFolder } from '@/helpers/utils.js'
import { showAppDbBackupsFolder } from '@/helpers/utils.js'
import { useCopyAsPaste } from '@/shared/composables/use-copy-as-paste'

const { addNotification, handleError } = injectNotificationManager()
const { formatMessage } = useVIntl()
const { adConsentAvailable } = injectPageContext()
const appSettings = useAppSettings()
const copyAsPaste = useCopyAsPaste()
const queryClient = useQueryClient()
const clearCacheConfirmModal = ref<InstanceType<typeof ConfirmModalWrapper> | null>(null)
const copyingAdDetails = ref(false)
Expand Down Expand Up @@ -134,12 +136,12 @@ const messages = defineMessages({
},
alwaysShowCopyDetailsTitle: {
id: 'app.settings.resource-management.always-show-copy-details.title',
defaultMessage: 'Always show copy details',
defaultMessage: 'Always show inspect details',
},
alwaysShowCopyDetailsDescription: {
id: 'app.settings.resource-management.always-show-copy-details.description',
defaultMessage:
'Show the Copy details action while an install is queued or running. It is always available for failed or interrupted installs.',
'Show the Inspect details action while an install is queued or running. It is always available for failed or interrupted installs.',
},
})

Expand Down Expand Up @@ -207,7 +209,7 @@ async function handleCopyAdDetails() {
}

const { current_ad: currentAd, ...info } = adReport
await copyToClipboard(
await copyAsPaste(
`CURRENT_AD: ${currentAd ?? 'unknown'}\n\nINFO:\n${JSON.stringify(info, null, 2)}`,
)

Expand Down
4 changes: 0 additions & 4 deletions apps/app-frontend/src/helpers/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,6 @@ export async function install_job_dismiss(jobId: string) {
return await invoke<void>('plugin:install|install_job_dismiss', { jobId })
}

export async function install_job_support_details(jobId: string) {
return await invoke<string>('plugin:install|install_job_support_details', { jobId })
}

export function installJobInstanceId(job: InstallJobSnapshot): string | null {
return job.instance_id ?? job.target.instance_id ?? null
}
Expand Down
3 changes: 0 additions & 3 deletions apps/app-frontend/src/locales/ar-SA/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions apps/app-frontend/src/locales/cs-CZ/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions apps/app-frontend/src/locales/da-DK/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions apps/app-frontend/src/locales/de-CH/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions apps/app-frontend/src/locales/de-DE/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading