@motor-cms/ui-admin 1.16.2 → 1.16.3
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.
|
@@ -7,7 +7,8 @@ const { can } = usePermissions()
|
|
|
7
7
|
const { user } = useSanctumAuth<User>()
|
|
8
8
|
const router = useRouter()
|
|
9
9
|
const { completeOnboarding } = useProfileApi()
|
|
10
|
-
const { commitDone
|
|
10
|
+
const { commitDone } = useOnboardingDone()
|
|
11
|
+
const { isEnabled } = useOnboardingEnabled()
|
|
11
12
|
|
|
12
13
|
const { isCompleted: announcementsCompleted, markCompleted: markAnnouncementsDone } = useOnboardingState('dashboard-announcements')
|
|
13
14
|
const { isCompleted: notificationsCompleted, markCompleted: markNotificationsDone } = useOnboardingState('notifications')
|
|
@@ -225,17 +226,14 @@ const stopWatch = watch(
|
|
|
225
226
|
if (!announcementsW || !notificationsW || !searchW || !adminNavW || !userData) return
|
|
226
227
|
stopWatch()
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// resetAll() in useOnboardingResetAll clears the skip flag, so a
|
|
232
|
-
// deliberate "restart tour" from the profile page still works correctly.
|
|
233
|
-
if (userData.show_onboarding && !isDone()) {
|
|
229
|
+
const shouldRun = isEnabled.value
|
|
230
|
+
|
|
231
|
+
if (shouldRun) {
|
|
234
232
|
userData.show_onboarding = false
|
|
235
233
|
resetOnboardingState()
|
|
236
234
|
}
|
|
237
235
|
|
|
238
|
-
if (!announcementsCompleted.value) {
|
|
236
|
+
if (shouldRun && !announcementsCompleted.value) {
|
|
239
237
|
startAnnouncements()
|
|
240
238
|
}
|
|
241
239
|
},
|
|
@@ -129,3 +129,23 @@ export function useOnboardingDone() {
|
|
|
129
129
|
|
|
130
130
|
return { commitDone, isDone }
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Central guard: should the onboarding tour run for this user?
|
|
135
|
+
*
|
|
136
|
+
* Returns true only when BOTH conditions are met:
|
|
137
|
+
* 1. Backend says show_onboarding=true (fresh user or "restart tour" from profile)
|
|
138
|
+
* 2. User hasn't already completed/skipped the tour in this browser (isDone=false)
|
|
139
|
+
*
|
|
140
|
+
* Use this everywhere instead of hand-rolling the check.
|
|
141
|
+
*/
|
|
142
|
+
export function useOnboardingEnabled() {
|
|
143
|
+
const { user } = useSanctumAuth<User>()
|
|
144
|
+
const { isDone } = useOnboardingDone()
|
|
145
|
+
|
|
146
|
+
const isEnabled = computed(() => {
|
|
147
|
+
return !!user.value?.data?.show_onboarding && !isDone()
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
return { isEnabled }
|
|
151
|
+
}
|
package/app/pages/index.vue
CHANGED
|
@@ -47,17 +47,6 @@ function onAnnouncementCreated() {
|
|
|
47
47
|
|
|
48
48
|
const toast = useToast()
|
|
49
49
|
|
|
50
|
-
onMounted(() => {
|
|
51
|
-
if (sessionStorage.getItem('motor:login-success')) {
|
|
52
|
-
sessionStorage.removeItem('motor:login-success')
|
|
53
|
-
toast.add({
|
|
54
|
-
title: t('motor-core.login.login_success'),
|
|
55
|
-
color: 'success',
|
|
56
|
-
icon: 'i-lucide-check-circle'
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
50
|
async function onDismiss(id: number) {
|
|
62
51
|
await dismissAnnouncement(id)
|
|
63
52
|
toast.add({ title: t('motor-admin.dashboard.announcement_dismissed'), icon: 'i-lucide-check', color: 'success' })
|
package/app/pages/login.vue
CHANGED
|
@@ -4,6 +4,7 @@ import type { FormSubmitEvent } from '@nuxt/ui'
|
|
|
4
4
|
|
|
5
5
|
const { t } = useI18n()
|
|
6
6
|
const { login } = useSanctumAuth()
|
|
7
|
+
const toast = useToast()
|
|
7
8
|
|
|
8
9
|
definePageMeta({
|
|
9
10
|
layout: 'auth',
|
|
@@ -53,7 +54,11 @@ async function onSubmit(event: FormSubmitEvent<Schema>) {
|
|
|
53
54
|
email: event.data.email,
|
|
54
55
|
password: event.data.password
|
|
55
56
|
})
|
|
56
|
-
|
|
57
|
+
toast.add({
|
|
58
|
+
title: t('motor-core.login.login_success'),
|
|
59
|
+
color: 'success',
|
|
60
|
+
icon: 'i-lucide-check-circle'
|
|
61
|
+
})
|
|
57
62
|
} catch {
|
|
58
63
|
error.value = t('motor-core.login.login_failed')
|
|
59
64
|
} finally {
|
package/app/pages/profile.vue
CHANGED
|
@@ -185,6 +185,7 @@ async function onRestartTour() {
|
|
|
185
185
|
try {
|
|
186
186
|
await resetOnboarding()
|
|
187
187
|
resetOnboardingState()
|
|
188
|
+
await refreshIdentity()
|
|
188
189
|
success(t('motor-core.profile.toast_tour_reset_title'), t('motor-core.profile.toast_tour_reset_message'))
|
|
189
190
|
await router.push('/')
|
|
190
191
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motor-cms/ui-admin",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"zod": "^4.0.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@motor-cms/ui-core": ">=1.16.
|
|
23
|
+
"@motor-cms/ui-core": ">=1.16.3",
|
|
24
24
|
"nuxt": "^4.0.0",
|
|
25
25
|
"vue": "^3.5.0"
|
|
26
26
|
}
|