@innertia-solutions/innertia-nuxt 0.1.89 → 0.1.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/app.config.ts +8 -0
- package/components/App/NotificationBell.vue +4 -1
- package/components/App/NotificationHistory.vue +4 -2
- package/components/Mail/BrandingPreview.vue +60 -0
- package/components/Mail/BrandingSettings.vue +141 -0
- package/components/Notifications/Preferences.vue +98 -0
- package/components/Notifications/__tests__/sfc-compile.test.ts +34 -0
- package/components/Platform/Emails.vue +133 -0
- package/components/Platform/MailSettings.vue +213 -0
- package/composables/__tests__/useNotifications.test.ts +32 -0
- package/composables/internal/__tests__/forcePassword.test.ts +37 -0
- package/composables/internal/__tests__/mailBranding.test.ts +35 -0
- package/composables/internal/forcePassword.ts +39 -0
- package/composables/internal/mailBranding.ts +62 -0
- package/composables/useNotificationHistory/index.ts +8 -7
- package/composables/useNotificationPreferences/index.ts +28 -0
- package/composables/useNotificationPreferences/internal/__tests__/preferences.test.ts +39 -0
- package/composables/useNotificationPreferences/internal/preferences.ts +66 -0
- package/composables/useNotifications.js +10 -5
- package/docs/correos-notificaciones.md +101 -0
- package/middleware/06.force-password.global.ts +14 -0
- package/middleware/platform-owner.ts +12 -0
- package/nuxt.config.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Correos y notificaciones con marca
|
|
2
|
+
|
|
3
|
+
Front del motor de avisos y correos de innertia-laravel (`\Innertia\Notifications`, `\Innertia\Mail`).
|
|
4
|
+
Guía del backend: `docs/correos-notificaciones.md` de innertia-laravel (rutas, `NoticeTypes`, `Notifier`).
|
|
5
|
+
|
|
6
|
+
**Todo es opt-in:** ningún componente se monta solo y el middleware de cambio de clave forzado
|
|
7
|
+
no hace nada hasta activarlo. Los productos que tienen sus propias páginas siguen igual.
|
|
8
|
+
|
|
9
|
+
## Campanita en platform
|
|
10
|
+
|
|
11
|
+
El producto registra en su grupo platform `\Innertia\Notifications\Routes::register('notifications')`
|
|
12
|
+
(queda en `platform/notifications`) y monta la campanita en el layout de platform:
|
|
13
|
+
|
|
14
|
+
```vue
|
|
15
|
+
<App.NotificationBell endpoint="platform/notifications" all-route="/platform/notifications" />
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<!-- pages/platform/notifications.vue -->
|
|
20
|
+
<template><App.NotificationHistory endpoint="platform/notifications" /></template>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`useNotifications({ base })` y `useNotificationHistory({ base })` aceptan el mismo prefijo
|
|
24
|
+
(default `notifications`, el backoffice no cambia).
|
|
25
|
+
|
|
26
|
+
## Preferencias (Mi cuenta › Notificaciones)
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<Notifications.Preferences /> <!-- backoffice -->
|
|
30
|
+
<Notifications.Preferences endpoint="platform/me/notification-preferences" /> <!-- platform -->
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Lista los tipos registrados en `NoticeTypes` con un interruptor por canal (campanita/correo).
|
|
34
|
+
Los avisos críticos de cuenta se muestran con candado y deshabilitados (el servidor ignora
|
|
35
|
+
apagarlos). Solo envía lo cambiado. Composable: `useNotificationPreferences({ base })`.
|
|
36
|
+
|
|
37
|
+
## Registro de correos (/platform/emails)
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<!-- pages/platform/emails/index.vue -->
|
|
41
|
+
<script setup>definePageMeta({ layout: 'platform', middleware: 'platform' })</script>
|
|
42
|
+
<template><Platform.Emails :tenants="tenantOptions" /></template>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Filtros por destinatario/asunto, estado, tipo (de `emails/types`) y espacio (`tenants`, opcional).
|
|
46
|
+
Los fallidos se expanden para ver el motivo.
|
|
47
|
+
|
|
48
|
+
## Configuración de correo (/platform/settings/mail, solo owner)
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<script setup>definePageMeta({ layout: 'platform', middleware: ['platform', 'platform-owner'] })</script>
|
|
52
|
+
<template>
|
|
53
|
+
<Platform.MailSettings>
|
|
54
|
+
<!-- opcional: selector de imagen del producto -->
|
|
55
|
+
<template #logo-picker="{ set }"><Platform.FileImagePicker @picked="set" /></template>
|
|
56
|
+
</Platform.MailSettings>
|
|
57
|
+
</template>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Proveedor (Mailpit/SMTP, Resend), API key encriptada (confirmación al borrar), remitente, logo y
|
|
61
|
+
color con validación por campo, aviso de cambios sin guardar, correo de prueba con la
|
|
62
|
+
configuración guardada y vista previa en vivo + del correo enviado. El middleware
|
|
63
|
+
`platform-owner` de la capa redirige a `/platform` a quien no es owner (si el producto tiene uno
|
|
64
|
+
propio con ese nombre, gana el del producto).
|
|
65
|
+
|
|
66
|
+
## Marca del espacio (Sistema › Marca)
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<script setup>definePageMeta({ middleware: ['auth'] })</script>
|
|
70
|
+
<template>
|
|
71
|
+
<Mail.BrandingSettings>
|
|
72
|
+
<template #logo-picker="{ set }"><MiSelectorDeDocumentos @picked="(f) => set({ logo_file_id: f.id })" /></template>
|
|
73
|
+
</Mail.BrandingSettings>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Backend: `\Innertia\Mail\Routes::tenantBranding('settings/branding')` con el permiso del producto
|
|
78
|
+
(p. ej. `settings.manage`). Nombre visible, logo (URL pública o archivo de Documentos), color y pie
|
|
79
|
+
(dirección/teléfono), vista previa en vivo y "Enviarme un correo de prueba".
|
|
80
|
+
|
|
81
|
+
`<Mail.BrandingPreview :branding="campos" :platform="marcaPlataforma" />` sirve suelto: resuelve
|
|
82
|
+
igual que `Branding::for()` del backend (respaldo campo a campo y "Enviado vía …").
|
|
83
|
+
|
|
84
|
+
## Cambio de contraseña forzado
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// nuxt.config.ts del producto
|
|
88
|
+
appConfig: {
|
|
89
|
+
innertia: {
|
|
90
|
+
forcePassword: {
|
|
91
|
+
enabled: true,
|
|
92
|
+
routes: { '/backoffice': '/backoffice/auth/change-password' }, // prefijo → página de cambio
|
|
93
|
+
// allow: ['/backoffice/auth/'], // por defecto '<prefijo>/auth/'
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Con `user.force_password_change === true`, cualquier ruta del área lleva a su página de cambio.
|
|
100
|
+
`/platform` ya lo cubre `05.platform-password.global`. Si el producto tiene su propio
|
|
101
|
+
`force-password.global.ts`, bórralo al activar este.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveForcePasswordRedirect } from '../composables/internal/forcePassword'
|
|
2
|
+
|
|
3
|
+
// Cambio de contraseña forzado (force_password_change) fuera de /platform: mientras el
|
|
4
|
+
// usuario no defina una nueva, cualquier ruta del área lo lleva a su página de cambio.
|
|
5
|
+
// Opt-in: no hace nada hasta que el producto declara appConfig.innertia.forcePassword.enabled.
|
|
6
|
+
// appConfig: { innertia: { forcePassword: { enabled: true, routes: { '/backoffice': '/backoffice/auth/change-password' } } } }
|
|
7
|
+
// /platform lo cubre 05.platform-password.global.
|
|
8
|
+
export default defineNuxtRouteMiddleware((to) => {
|
|
9
|
+
const config = (useAppConfig() as any).innertia?.forcePassword
|
|
10
|
+
if (!config?.enabled) return
|
|
11
|
+
|
|
12
|
+
const target = resolveForcePasswordRedirect(to.path, useAuthStore().user, config)
|
|
13
|
+
if (target) return navigateTo(target, { replace: true })
|
|
14
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Secciones de /platform solo para el owner (configuración de correo, respaldos…). El backend
|
|
2
|
+
// responde 403 a staff (middleware platform.owner de innertia-laravel); esto evita mostrar
|
|
3
|
+
// formularios que van a fallar. Uso: definePageMeta({ middleware: ['platform-owner'] }).
|
|
4
|
+
// Un producto con su propio `platform-owner` lo reemplaza (el del producto tiene prioridad).
|
|
5
|
+
export default defineNuxtRouteMiddleware(() => {
|
|
6
|
+
const user = useAuthStore().user as any
|
|
7
|
+
|
|
8
|
+
if (user?.platform_role !== 'owner') {
|
|
9
|
+
if (import.meta.client) useToast().error('Solo el owner de la plataforma puede acceder a esta sección.')
|
|
10
|
+
return navigateTo('/platform')
|
|
11
|
+
}
|
|
12
|
+
})
|
package/nuxt.config.ts
CHANGED
|
@@ -29,7 +29,7 @@ export default defineNuxtConfig({
|
|
|
29
29
|
{ path: './components', pathPrefix: true, prefix: '' },
|
|
30
30
|
],
|
|
31
31
|
imports: {
|
|
32
|
-
dirs: ['stores', 'composables', 'composables/useWorkflow', 'composables/useStorageTestRunner', 'composables/useNotificationHistory', 'composables/usePasskeys', 'composables/useDriveBrowser', 'composables/useFileImports', 'composables/useFileVersions'],
|
|
32
|
+
dirs: ['stores', 'composables', 'composables/useWorkflow', 'composables/useStorageTestRunner', 'composables/useNotificationHistory', 'composables/usePasskeys', 'composables/useDriveBrowser', 'composables/useFileImports', 'composables/useFileVersions', 'composables/useNotificationPreferences'],
|
|
33
33
|
presets: [
|
|
34
34
|
{
|
|
35
35
|
from: '@tanstack/vue-query',
|