Skip to content

Commit aa3576a

Browse files
committed
fix: hide modal header & add "Hide update reminder" button w/ tooltip
1 parent 0646f82 commit aa3576a

File tree

4 files changed

+60
-17
lines changed

4 files changed

+60
-17
lines changed

apps/app-frontend/src/App.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ import { openUrl } from '@tauri-apps/plugin-opener'
6969
import { type } from '@tauri-apps/plugin-os'
7070
import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'
7171
import { defineMessages, useVIntl } from '@vintl/vintl'
72-
import { computed, onMounted, onUnmounted, provide, ref, useTemplateRef, watch } from 'vue'
72+
import { createTooltip, destroyTooltip } from 'floating-vue'
73+
import {
74+
computed,
75+
nextTick,
76+
onMounted,
77+
onUnmounted,
78+
provide,
79+
ref,
80+
useTemplateRef,
81+
watch,
82+
} from 'vue'
7383
import { RouterView, useRoute, useRouter } from 'vue-router'
7484
import { create_profile_and_install_from_file } from './helpers/pack'
7585
import { generateSkinPreviews } from './helpers/rendering/batch-skin-renderer'
@@ -470,6 +480,20 @@ async function forceOpenUpdateModal() {
470480
updateModal.value.show(availableUpdate.value)
471481
}
472482
483+
const updateButton = useTemplateRef('updateButton')
484+
async function showUpdateButtonTooltip() {
485+
await nextTick()
486+
const tooltip = createTooltip(updateButton.value.$el, {
487+
placement: 'right',
488+
content: 'Click here to view the update again.',
489+
})
490+
tooltip.show()
491+
setTimeout(() => {
492+
tooltip.hide()
493+
destroyTooltip(updateButton.value.$el)
494+
}, 3500)
495+
}
496+
473497
function handleClick(e) {
474498
let target = e.target
475499
while (target != null) {
@@ -515,6 +539,7 @@ function handleAuxClick(e) {
515539
ref="updateModal"
516540
@update-skipped="skipUpdate"
517541
@update-enqueued-for-later="updateEnqueuedForLater"
542+
@modal-hidden="showUpdateButtonTooltip"
518543
/>
519544
</Suspense>
520545
<Suspense>
@@ -572,6 +597,7 @@ function handleAuxClick(e) {
572597
<div class="flex flex-grow"></div>
573598
<NavButton
574599
v-if="!!availableUpdate"
600+
ref="updateButton"
575601
v-tooltip.right="
576602
enqueuedUpdate === availableUpdate?.version
577603
? 'Update installation queued for next restart'

apps/app-frontend/src/components/ui/UpdateModal.vue

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<template>
2-
<ModalWrapper
3-
ref="modal"
4-
:header="formatMessage(messages.header)"
5-
:on-hide="onHide"
6-
:closable="!updatingImmediately && !downloadInProgress"
7-
>
2+
<ModalWrapper ref="modal" hide-header :closable="false" :on-hide="onHide">
83
<div class="flex flex-col gap-4">
9-
<div class="max-w-[500px]">
10-
<div class="font-extrabold text-contrast text-xl mb-1">
11-
Modrinth App v{{ update!.version }}
4+
<div class="w-[500px]">
5+
<div class="font-extrabold text-contrast text-xl">
6+
{{ formatMessage(messages.header) }} Modrinth App v{{ update!.version }}
127
</div>
138
<template v-if="!downloadInProgress && !downloadError">
14-
<div class="mb-4 leading-tight">{{ formatMessage(messages.bodyVersion) }}</div>
15-
<div class="text-sm text-secondary mb-3">
9+
<div class="mb-1 leading-tight">{{ formatMessage(messages.bodyVersion) }}</div>
10+
<div class="text-sm text-secondary mb-2">
1611
{{ formatMessage(messages.downloadSize, { size: formatBytes(updateSize) }) }}
1712
</div>
1813
</template>
@@ -49,7 +44,7 @@
4944
</ButtonStyled>
5045
</div>
5146
</div>
52-
<div v-if="!downloadError" class="flex flex-wrap gap-2 w-full mb-2">
47+
<div v-if="!downloadError" class="flex flex-wrap gap-2 w-full">
5348
<JoinedButtons
5449
:actions="installActions"
5550
:disabled="updatingImmediately || downloadInProgress"
@@ -74,7 +69,7 @@ import { defineMessages, useVIntl } from '@vintl/vintl'
7469
import { useTemplateRef, ref, computed } from 'vue'
7570
import { AppearingProgressBar, ButtonStyled, JoinedButtons } from '@modrinth/ui'
7671
import type { JoinedButtonAction } from '@modrinth/ui'
77-
import { ExternalIcon, DownloadIcon, RedoIcon, ClipboardCopyIcon } from '@modrinth/assets'
72+
import { ExternalIcon, DownloadIcon, RedoIcon, ClipboardCopyIcon, XIcon } from '@modrinth/assets'
7873
import { enqueueUpdateForInstallation, getUpdateSize } from '@/helpers/utils'
7974
import { formatBytes } from '@modrinth/utils'
8075
import { handleError } from '@/store/notifications'
@@ -85,13 +80,14 @@ import { ChatIcon } from '@/assets/icons'
8580
8681
const emit = defineEmits<{
8782
(e: 'updateEnqueuedForLater', version: string | null): Promise<void>
83+
(e: 'modalHidden'): void
8884
}>()
8985
9086
const { formatMessage } = useVIntl()
9187
const messages = defineMessages({
9288
header: {
9389
id: 'app.update.modal-header',
94-
defaultMessage: 'An update is available!',
90+
defaultMessage: 'Update available - ',
9591
},
9692
copiedError: {
9793
id: 'app.update.copied-error',
@@ -131,6 +127,10 @@ const messages = defineMessages({
131127
id: 'app.update.try-again',
132128
defaultMessage: 'Try again',
133129
},
130+
hide: {
131+
id: 'app.update.hide',
132+
defaultMessage: 'Hide update reminder',
133+
},
134134
})
135135
136136
type UpdateData = {
@@ -146,7 +146,7 @@ const update = ref<UpdateData>()
146146
const updateSize = ref<number>()
147147
148148
const updatingImmediately = ref(false)
149-
const downloadInProgress = ref(true)
149+
const downloadInProgress = ref(false)
150150
const downloadProgress = ref(0)
151151
const copiedError = ref(false)
152152
const downloadError = ref<Error | null>(null)
@@ -167,6 +167,15 @@ const installActions = computed<JoinedButtonAction[]>(() => [
167167
icon: RedoIcon,
168168
action: updateAtNextExit,
169169
},
170+
{
171+
id: 'hide',
172+
label: formatMessage(messages.hide),
173+
action: () => {
174+
hide()
175+
emit('modalHidden')
176+
},
177+
icon: XIcon,
178+
},
170179
])
171180
172181
const downloadedBytes = computed(() => {

apps/app-frontend/src/components/ui/modal/ModalWrapper.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const props = defineProps({
1111
type: String,
1212
default: null,
1313
},
14+
hideHeader: {
15+
type: Boolean,
16+
default: false,
17+
},
1418
closable: {
1519
type: Boolean,
1620
default: true,
@@ -53,6 +57,7 @@ function onModalHide() {
5357
:header="header"
5458
:noblur="!themeStore.advancedRendering"
5559
:closable="closable"
60+
:hide-header="hideHeader"
5661
@hide="onModalHide"
5762
>
5863
<template #title>

packages/ui/src/components/modal/NewModal.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<div class="modal-body flex flex-col bg-bg-raised rounded-2xl">
2323
<div
2424
data-tauri-drag-region
25+
v-if="!hideHeader"
2526
class="grid grid-cols-[auto_min-content] items-center gap-12 p-6 border-solid border-0 border-b-[1px] border-divider max-w-full"
2627
>
2728
<div class="flex text-wrap break-words items-center gap-3 min-w-0">
@@ -60,6 +61,7 @@ const props = withDefaults(
6061
closeOnClickOutside?: boolean
6162
warnOnClose?: boolean
6263
header?: string
64+
hideHeader?: boolean
6365
onHide?: () => void
6466
onShow?: () => void
6567
}>(),
@@ -71,6 +73,7 @@ const props = withDefaults(
7173
closeOnEsc: true,
7274
warnOnClose: false,
7375
header: undefined,
76+
hideHeader: false,
7477
onHide: () => {},
7578
onShow: () => {},
7679
},
@@ -134,7 +137,7 @@ function updateMousePosition(event: { clientX: number; clientY: number }) {
134137
}
135138
136139
function handleKeyDown(event: KeyboardEvent) {
137-
if (props.closeOnEsc && event.key === 'Escape') {
140+
if (props.closeOnEsc && event.key === 'Escape' && props.closable) {
138141
hide()
139142
mouseX.value = window.innerWidth / 2
140143
mouseY.value = window.innerHeight / 2

0 commit comments

Comments
 (0)