Skip to content

Commit 8a6d3a0

Browse files
committed
adds demo & reduced mode for live demo
1 parent cbd3fd8 commit 8a6d3a0

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

frontend/src/components/EmailContent/EmailAttachments.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div>
2+
<div class="flex flex-col gap-2">
33
<div v-if="attachments.length > 0" class="flex flex-wrap gap-2">
44
<a
55
v-for="attachment in attachments"
@@ -20,12 +20,6 @@
2020
</div>
2121

2222
<div v-if="inlineAttachments.length > 0" class="flex flex-wrap gap-2">
23-
<div
24-
class="text-gray-500 flex items-center cursor-help"
25-
title="Inline attachments are usually images displayed inside the email content and not typically intended to be downloaded."
26-
>
27-
Inline attachments:
28-
</div>
2923
<a
3024
v-for="attachment in inlineAttachments"
3125
:key="attachment.id"
@@ -37,10 +31,13 @@
3731
:is="getAttachmentIcon(attachment.content_type)"
3832
class="h-4 w-4 text-gray-600"
3933
/>
40-
<span>{{ attachment.filename || 'unnamed' }}</span>
41-
<span class="text-xs text-gray-600"
42-
>({{ formatSize(attachment.size) }})</span
43-
>
34+
<span>
35+
{{ attachment.filename || 'unnamed' }}
36+
<small class="text-gray-500">(inline)</small>
37+
</span>
38+
<span class="text-xs text-gray-600">
39+
({{ formatSize(attachment.size) }})
40+
</span>
4441
</a>
4542
</div>
4643
</div>

frontend/src/components/EmailContent/EmailHeader.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
}
146146
}
147147
148+
const demoMode = computed(() => {
149+
const searchParams = new URLSearchParams(window.location.search)
150+
return searchParams.get('demo') === 'true'
151+
})
152+
148153
const menuItems = computed<DropdownMenuItem[]>(() => [
149154
{
150155
id: 'download',
@@ -157,7 +162,7 @@
157162
id: 'delete',
158163
label: 'Delete',
159164
icon: TrashIcon,
160-
disabled: loadingDelete.value,
165+
disabled: loadingDelete.value || demoMode.value,
161166
onClick: handleDelete,
162167
},
163168
])

frontend/src/components/EmailLayout/EmailLayout.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<template>
22
<div class="flex flex-row h-full">
3-
<EmailSidebar :counts="counts" />
3+
<EmailSidebar v-if="!reducedMode" :counts="counts" />
44

5-
<EmailList :emails="emails" :loading="loading" @load-more="fetchNextPage" />
5+
<EmailList
6+
v-if="!reducedMode"
7+
:emails="emails"
8+
:loading="loading"
9+
@load-more="fetchNextPage"
10+
/>
611

712
<div class="grow">
813
<RouterView />
@@ -11,7 +16,7 @@
1116
</template>
1217

1318
<script setup lang="ts">
14-
import { ref, onMounted, watch } from 'vue'
19+
import { ref, onMounted, watch, computed } from 'vue'
1520
import { useWebSocket } from '@/composables/useWebSocket'
1621
import { apiClient } from '@/api/client'
1722
import { useSearchStore } from '@/stores/Search'
@@ -33,6 +38,11 @@
3338
const hasNextPage = ref(false)
3439
let searchTimeout: number | null = null
3540
41+
const reducedMode = computed(() => {
42+
const searchParams = new URLSearchParams(window.location.search)
43+
return searchParams.get('reduced') === 'true'
44+
})
45+
3646
const fetchSidebar = async () => {
3747
try {
3848
counts.value = await apiClient.getCounts()

frontend/src/router.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import { createRouter, createWebHistory } from 'vue-router'
1+
import {
2+
createRouter,
3+
createWebHistory,
4+
type RouteLocationNormalized,
5+
type NavigationGuardNext,
6+
} from 'vue-router'
27
import EmailView from './components/EmailContent/EmailView.vue'
38
import FullscreenEmailView from './components/EmailContent/FullscreenEmailView.vue'
49
import EmailLayout from './components/EmailLayout/EmailLayout.vue'
10+
import { apiClient } from './api/client'
511

612
const routes = [
713
{ path: '/', redirect: '/emails/inbox' },
@@ -15,6 +21,23 @@ const routes = [
1521
component: EmailLayout,
1622
children: [{ path: 'email/:id', component: EmailView }],
1723
},
24+
{
25+
path: '/redirect_first_email',
26+
component: EmailLayout,
27+
beforeEnter: async (
28+
to: RouteLocationNormalized,
29+
_from: RouteLocationNormalized,
30+
next: NavigationGuardNext
31+
) => {
32+
const response = await apiClient.inbox(1)
33+
const first = response.emails[0]
34+
if (first) {
35+
next({ path: `/emails/inbox/email/${first.id}`, query: to.query })
36+
} else {
37+
next({ path: '/emails/inbox' })
38+
}
39+
}
40+
},
1841
{ path: '/emails/:id/fullscreen', component: FullscreenEmailView },
1942
{ path: '/:pathMatch(.*)*', redirect: '/' },
2043
]

0 commit comments

Comments
 (0)