Skip to content

Commit 45c26ac

Browse files
committed
chore: improve ui
1 parent 2da4c91 commit 45c26ac

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

‎plugins/assets/src/spa/app/components/AssetDetails.vue‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ const deleteOpen = ref(false)
2727
const renameOpen = ref(false)
2828
const newName = ref('')
2929
const busy = ref(false)
30-
const notice = ref<{ kind: 'success' | 'error', message: string } | null>(null)
30+
const errorNotice = ref<string | null>(null)
3131
3232
watch(() => props.asset.path, (path) => {
3333
imageMeta.value = null
3434
textContent.value = null
35-
notice.value = null
35+
errorNotice.value = null
3636
const rpc = props.rpc
3737
if (!rpc)
3838
return
@@ -57,50 +57,50 @@ const aspectRatio = computed(() => {
5757
const snippets = computed(() => buildSnippets(props.asset, imageMeta.value))
5858
const supportsPreview = computed(() => SUPPORTS_PREVIEW.has(props.asset.type))
5959
60-
async function withNotice(fn: () => Promise<void>, successMessage: string): Promise<void> {
60+
async function runAction(fn: () => Promise<void>): Promise<void> {
6161
if (!props.rpc)
6262
return
63+
errorNotice.value = null
6364
busy.value = true
6465
try {
6566
await fn()
66-
notice.value = { kind: 'success', message: successMessage }
6767
}
6868
catch (cause) {
69-
notice.value = { kind: 'error', message: cause instanceof Error ? cause.message : String(cause) }
69+
errorNotice.value = cause instanceof Error ? cause.message : String(cause)
7070
}
7171
finally {
7272
busy.value = false
7373
}
7474
}
7575
7676
async function handleDelete(): Promise<void> {
77-
await withNotice(async () => {
77+
await runAction(async () => {
7878
await props.rpc!.call('devframes:plugin:assets:delete', { paths: [props.asset.path] })
7979
deleteOpen.value = false
8080
emit('changed')
8181
emit('close')
82-
}, 'Deleted')
82+
})
8383
}
8484
8585
async function handleRename(): Promise<void> {
86-
await withNotice(async () => {
86+
await runAction(async () => {
8787
await props.rpc!.call('devframes:plugin:assets:rename', { path: props.asset.path, newName: newName.value })
8888
renameOpen.value = false
8989
emit('changed')
9090
emit('close')
91-
}, 'Renamed')
91+
})
9292
}
9393
9494
async function handleOpenInEditor(): Promise<void> {
95-
await withNotice(async () => {
95+
await runAction(async () => {
9696
await props.rpc!.call('devframes:plugin:assets:open-in-editor', props.asset.path)
97-
}, 'Opened in editor')
97+
})
9898
}
9999
100100
async function handleRevealInFolder(): Promise<void> {
101-
await withNotice(async () => {
101+
await runAction(async () => {
102102
await props.rpc!.call('devframes:plugin:assets:reveal-in-folder', props.asset.path)
103-
}, 'Revealed in folder manager')
103+
})
104104
}
105105
106106
function openRenameDialog(): void {
@@ -206,8 +206,8 @@ function openInBrowser(): void {
206206
</ActionButton>
207207
</div>
208208

209-
<div v-if="notice" class="text-xs" :class="notice.kind === 'error' ? 'text-error' : 'text-success'">
210-
{{ notice.message }}
209+
<div v-if="errorNotice" class="text-xs text-error">
210+
{{ errorNotice }}
211211
</div>
212212

213213
<div class="flex-1" />

‎plugins/assets/src/spa/app/components/Toolbar.vue‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const viewTabs = [
4747
v-model="search"
4848
icon="i-ph-magnifying-glass"
4949
placeholder="Search assets…"
50+
size="sm"
5051
clearable
5152
class="max-w-80 w-full"
5253
/>
@@ -55,7 +56,7 @@ const viewTabs = [
5556
<template #end>
5657
<template v-if="selectedCount > 0">
5758
<span class="whitespace-nowrap text-sm font-medium">{{ selectedCount }} selected</span>
58-
<ActionButton class="text-error border-error/30!" icon="i-ph-trash-duotone" @click="emit('bulkDelete')">
59+
<ActionButton size="sm" class="h-7! py-0! text-error border-error/30!" icon="i-ph-trash-duotone" @click="emit('bulkDelete')">
5960
Delete
6061
</ActionButton>
6162
<ActionButton variant="text" @click="emit('clearSelection')">

0 commit comments

Comments
 (0)