Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | 1x 61x 1x 1x 61x 1x 1x 1x 1x 28x 1x 2x 52x 1x 1x 1x 54x 1x 54x 1x 1x 1x 1x 1x 54x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 20x 28x 2x 2x 2x 2x 5x 5x 5x 40x 40x 40x 11x 9x 8x 8x 8x 8x 3x 3x 8x 6x 6x 6x 6x 4x 3x 3x 3x 3x 3x 6x 1x 1x 2x 2x 2x 1x 1x 1x 1x | <template>
<PageLayout :title="t('navigation.flows')" class="flows-page">
<template #action>
<button
class="btn btn-outline-secondary me-2 refresh-flows-btn"
:disabled="loading"
@click="refreshFlows"
>
<font-awesome-icon icon="fa-solid fa-rotate-right" class="me-md-2" />
<span class="d-none d-md-inline">{{ t('common.refresh') }}</span>
</button>
<button class="btn btn-success" data-tour="flows-create" @click="startCreate">
<font-awesome-icon icon="fa-solid fa-plus" class="me-md-2" />
<span class="d-none d-md-inline">{{ t('flow.createNew') }}</span>
</button>
</template>
<!-- Creating only: editing opens the app-wide FlowEditSidebar -->
<FlowFormSidebar
:is-open="showFlowDialog"
mode="create"
:form-data="flowForm"
:content-languages="contentLanguages"
:loading="formLoading"
:error="formError"
:can-update="true"
:can-delete="false"
:flow-id="newFlowId"
@update:form-data="flowForm = $event"
@close="cancelFlowForm"
@submit="saveFlow"
/>
<div class="container-fluid">
<!-- Switch error -->
<div v-if="switchError" class="alert alert-danger alert-dismissible fade show" role="alert">
{{ switchError }}
<button type="button" class="btn-close" aria-label="Close" @click="switchError = ''" />
</div>
<!-- Loading state: only for the first load, a refresh keeps the known flows on screen -->
<LoadingSpinner v-if="loading && flowsStore.myFlows.length === 0" />
<!-- Empty state -->
<div v-else-if="!loading && flowsStore.myFlows.length === 0" class="row">
<div class="col-12 text-center py-5">
<font-awesome-icon
icon="fa-solid fa-building"
class="text-muted mb-3"
style="font-size: 4rem"
/>
<h4>{{ t('flow.noFlows') }}</h4>
<p class="text-muted">{{ t('flow.createFirstFlow') }}</p>
<button class="btn btn-success mt-2" @click="startCreate">
<font-awesome-icon icon="fa-solid fa-plus" class="me-2" />
{{ t('flow.createNew') }}
</button>
</div>
</div>
</div>
<!-- Flows grid with VirtualCardGrid -->
<VirtualCardGrid
v-if="flowsStore.myFlows.length > 0"
:items="sortedFlows"
:has-more="false"
:is-loading="false"
>
<template #card="{ item: flow }">
<UnifiedContentCard :active="authStore.currentFlow === flow.flowId">
<template v-if="canManageFlow(flow)" #actions>
<button
class="btn btn-sm btn-secondary action-icon"
:title="t('flow.editFlow')"
@click.stop="openFlowEdit(flow.flowId)"
>
<font-awesome-icon icon="fa-solid fa-pen" />
</button>
</template>
<template v-else #actions>
<button
class="btn btn-sm btn-danger action-icon"
:title="t('member.leave')"
@click.stop="startLeaveFlow(flow)"
>
<font-awesome-icon icon="fa-solid fa-xmark" />
</button>
</template>
<template #picture>
<div class="flow-picture-container">
<ImageField
v-if="flow.picture"
:model-value="flow.picture"
:field="{ name: 'picture', type: 'image', fieldId: 'flow-picture' }"
:is-editing="false"
:entity-id="flow.flowId"
:item-id="flow.flowId"
object-fit="cover"
no-thumbnail
:clickable="false"
no-wrapper
/>
<div v-else class="default-picture">
<div class="default-picture-inner">
<div class="default-picture-art">
<span class="default-picture-sun" />
<span class="default-picture-mountain default-picture-mountain-back" />
<span class="default-picture-mountain default-picture-mountain-front" />
</div>
<span class="default-picture-label">{{ t('common.noImage') }}</span>
</div>
</div>
</div>
</template>
<h5 class="card-title d-flex align-items-center">
<div v-if="flow.icon" class="flow-icon-container me-2">
<ImageField
:model-value="flow.icon"
:field="{ name: 'icon', type: 'image', fieldId: 'flow-icon' }"
:is-editing="false"
:entity-id="flow.flowId"
:item-id="flow.flowId"
object-fit="contain"
:clickable="false"
no-wrapper
no-thumbnail
/>
</div>
<font-awesome-icon v-else icon="fa-solid fa-building" class="me-2 text-primary" />
{{ flow.flowName }}
</h5>
<p class="card-text">
<small class="text-muted">{{ t('flow.identifier') }}: {{ flow.flowSlug }}</small>
</p>
<p v-if="flow.description" class="card-text text-muted small">
{{ flow.description }}
</p>
<p v-if="flow.createdAt" class="card-text">
<small class="text-muted"
>{{ t('flow.created') }}: {{ formatDate(flow.createdAt) }}</small
>
</p>
<p class="card-text">
<span v-if="flow.isOwner" class="badge bg-warning">{{ t('flow.owner') }}</span>
</p>
<template #footer>
<button
v-if="authStore.currentFlow !== flow.flowId"
class="btn btn-sm btn-primary p-2 w-100"
:disabled="switchingFlowId !== null"
@click.stop="switchToFlow(flow.flowId)"
>
<span
v-if="switchingFlowId === flow.flowId"
class="spinner-border spinner-border-sm me-2"
role="status"
aria-hidden="true"
/>
{{ t('flow.switchToThisFlow') }}
</button>
<button
v-else
class="btn btn-sm btn-success p-2 w-100"
style="pointer-events: none; cursor: default"
>
<font-awesome-icon icon="fa-solid fa-check" class="me-1" />{{
t('flow.currentlyActive')
}}
</button>
</template>
</UnifiedContentCard>
</template>
</VirtualCardGrid>
</PageLayout>
<ConfirmModal
:is-open="confirmLeaveFlow.open"
:title="t('member.leave')"
:message="t('common.confirmLeave')"
:confirm-label="t('member.leave')"
variant="danger"
@confirm="doLeaveFlow"
@cancel="confirmLeaveFlow.open = false"
/>
<FloatingPageActions :scroll-top-title="t('common.backToTop')" />
</template>
<script setup lang="ts">
// @implements UC-FLOW-009.1, UC-FLOW-001.1, UC-FLOW-002.1, UC-FLOW-003.1, UC-FLOW-004.1, UC-FLOW-005.1, UC-FLOW-006.1, UC-FLOW-007.1, UC-FLOW-008.1, UC-I18N-004.1, UC-INVITE-005.1, UC-APIKEY-006.1
import { ref, onMounted, computed, reactive } from 'vue'
import PageLayout from '@/components/PageLayout.vue'
import VirtualCardGrid from '@/components/VirtualCardGrid.vue'
import FlowFormSidebar from '@/components/FlowFormSidebar.vue'
import ConfirmModal from '@/components/ConfirmModal.vue'
import UnifiedContentCard from '@/components/UnifiedContentCard.vue'
import ImageField from '@/components/ImageField.vue'
import LoadingSpinner from '@/components/LoadingSpinner.vue'
import FloatingPageActions from '@/components/FloatingPageActions.vue'
import { useFlowsStore, type FlowMembership } from '@/stores/flows'
import { useAuthStore } from '@/stores/auth'
import { useUILanguage } from '@/composables/useUILanguage'
import { useDateFormat } from '@/composables/useDateFormat'
import { hasFlowPermission } from '@/composables/usePermissions'
import { storeToRefs } from 'pinia'
import { CONTENT_LANGUAGES } from '@/utils/languages'
import { useToastStore } from '@/stores/toast'
import { useFlowEditSidebar } from '@/composables/useFlowEditSidebar'
import { getErrorMessage } from '@/utils/errors'
import { useRouter } from 'vue-router'
import { flowRoute } from '@/router/flowRoutes'
import type { FlowSpace } from '@/utils/spaceTheme'
const flowsStore = useFlowsStore()
const toastStore = useToastStore()
const authStore = useAuthStore()
const router = useRouter()
const { t } = useUILanguage()
const { openFlowEdit } = useFlowEditSidebar()
const { formatDate } = useDateFormat()
const contentLanguages = CONTENT_LANGUAGES
const { loading } = storeToRefs(flowsStore)
const flowForm = ref<{
name: string
slug: string
defaultLanguage: string
enabledLanguages: string[]
description?: string
picture?: string
icon?: string
space?: FlowSpace
}>({
name: '',
slug: '',
defaultLanguage: 'en',
enabledLanguages: ['en', 'fr']
})
// Generated up front so picture/icon uploads during creation are keyed by
// the flow's real, final id from the start — sent to the API as `id` on
// create — instead of a placeholder that would need reconciling afterward.
const newFlowId = ref(crypto.randomUUID())
const showFlowDialog = ref(false)
const formLoading = ref(false)
const formError = ref('')
const switchError = ref('')
const switchingFlowId = ref<string | null>(null)
const confirmLeaveFlow = reactive({
open: false,
flowId: ''
})
const sortedFlows = computed(() => {
return [...flowsStore.myFlows].sort((a, b) => a.flowName.localeCompare(b.flowName))
})
// A member can open the edit sidebar (settings update and/or Danger Zone
// delete — each gated separately inside FlowFormSidebar) once they hold
// either permission, not just the flow owner.
function canManageFlow(flow: FlowMembership): boolean {
return hasFlowPermission(flow, 'flows:update') || hasFlowPermission(flow, 'flows:delete')
}
function startCreate() {
showFlowDialog.value = true
newFlowId.value = crypto.randomUUID()
flowForm.value = {
name: '',
slug: '',
defaultLanguage: 'en',
enabledLanguages: ['en', 'fr']
}
formError.value = ''
}
function cancelFlowForm() {
showFlowDialog.value = false
flowForm.value = {
name: '',
slug: '',
defaultLanguage: 'en',
enabledLanguages: ['en', 'fr']
}
formError.value = ''
}
async function refreshFlows() {
await flowsStore.fetchMyFlows()
}
onMounted(async () => {
await refreshFlows()
})
// Switching is opening the flow's URL: only this tab changes flow
async function switchToFlow(flowId: string) {
const flow = flowsStore.myFlows.find((f) => f.flowId === flowId)
if (!flow) return
switchingFlowId.value = flowId
switchError.value = ''
try {
await router.push(flowRoute(flow.flowSlug, 'home'))
} catch (err: any) {
console.error('[FlowsPage] switchToFlow error:', err)
switchError.value = getErrorMessage(err, 'Failed to switch flow')
} finally {
switchingFlowId.value = null
}
}
async function saveFlow() {
formLoading.value = true
formError.value = ''
try {
const created = await flowsStore.createFlow({
id: newFlowId.value,
name: flowForm.value.name,
slug: flowForm.value.slug,
description: flowForm.value.description,
picture: flowForm.value.picture,
icon: flowForm.value.icon
})
// A user's first flow opens right away
if (!authStore.currentFlow) await router.push(flowRoute(created.slug, 'home'))
cancelFlowForm()
toastStore.success(t('flow.createSuccess'))
} catch (err: any) {
console.error('[saveFlow] error:', {
message: err.message,
status: err.response?.status,
data: err.response?.data,
code: err.code
})
formError.value = getErrorMessage(err, 'Failed to create flow', t)
toastStore.error(t('flow.createError'))
} finally {
formLoading.value = false
}
}
function startLeaveFlow(flow: any) {
confirmLeaveFlow.flowId = flow.flowId
confirmLeaveFlow.open = true
}
async function doLeaveFlow() {
confirmLeaveFlow.open = false
try {
await flowsStore.leaveFlow(confirmLeaveFlow.flowId)
toastStore.success(t('flow.leaveSuccess'))
} catch (err: any) {
console.error('[doLeaveFlow] error:', err)
switchError.value = getErrorMessage(err, 'Failed to leave flow')
toastStore.error(t('flow.leaveError'))
}
}
</script>
<style scoped>
.flow-icon-container {
width: 2rem;
height: 2rem;
overflow: hidden;
border-radius: 4px;
flex-shrink: 0;
background: var(--bw-surface-muted);
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
.flow-icon-container :deep(img) {
display: block;
}
.flow-picture-container {
width: 100%;
height: 150px;
overflow: hidden;
background: var(--bw-surface-muted);
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
}
.flow-picture-container :deep(img) {
display: block;
}
.default-picture {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background:
radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08), transparent 45%),
radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.06), transparent 50%),
linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08));
color: rgba(255, 255, 255, 0.35);
}
.default-picture-inner {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.default-picture-art {
position: relative;
width: 100%;
height: 100%;
border-radius: 0;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
overflow: hidden;
}
.default-picture-label {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 0.7rem;
opacity: 0.85;
letter-spacing: 0.03em;
line-height: 1;
white-space: nowrap;
color: rgba(230, 236, 245, 0.95);
background: rgba(15, 20, 30, 0.48);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 999px;
padding: 0.28rem 0.6rem;
backdrop-filter: blur(2px);
}
.default-picture-sun {
position: absolute;
top: 18%;
left: 20%;
width: 1rem;
height: 1rem;
border-radius: 999px;
background: rgba(20, 28, 40, 0.45);
}
.default-picture-mountain {
position: absolute;
bottom: -2px;
width: 56%;
height: 54%;
background: rgba(20, 28, 40, 0.62);
clip-path: polygon(0% 100%, 34% 48%, 56% 70%, 72% 38%, 100% 100%);
}
.default-picture-mountain-back {
left: -2%;
opacity: 0.75;
}
.default-picture-mountain-front {
right: -2%;
}
/* Mobile optimization */
@media (max-width: 767px) {
.display-6 {
font-size: 1.5rem;
}
.card-header h5 {
font-size: 1rem;
}
/* Stack form fields vertically */
.row.g-3 {
row-gap: 0.75rem !important;
}
/* Form buttons can be full width, but not action buttons */
.card .btn {
width: 100%;
margin-top: 0.5rem;
}
/* Card grid: single column on mobile */
.col-md-6,
.col-lg-4 {
flex: 0 0 100%;
max-width: 100%;
}
.card-title {
font-size: 1rem;
}
}
</style>
|