@motor-cms/ui-admin 1.16.1 → 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, isDone } = useOnboardingDone()
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
- // Only reset if the user has NOT already committed a skip.
229
- // isSkipCommitted() reads localStorage, so it survives hard reloads even
230
- // when the completeOnboarding() API call was cancelled by the browser.
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
+ }
@@ -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.1",
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.1",
23
+ "@motor-cms/ui-core": ">=1.16.3",
24
24
  "nuxt": "^4.0.0",
25
25
  "vue": "^3.5.0"
26
26
  }