fix: reset not working
refactored code
This commit is contained in:
parent
b5baaf3cb1
commit
dce61b1033
@ -7,12 +7,7 @@
|
|||||||
>
|
>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="text-base font-medium ml-1">
|
<div class="text-base font-medium ml-1">
|
||||||
<div v-if="!isOnboardingStepsCompleted && !showHelpCenter">
|
{{ __(title) }}
|
||||||
{{ __('Getting started') }}
|
|
||||||
</div>
|
|
||||||
<div v-else-if="showHelpCenter">
|
|
||||||
{{ __('Help center') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button @click="minimize = !minimize" variant="ghost">
|
<Button @click="minimize = !minimize" variant="ghost">
|
||||||
@ -29,22 +24,13 @@
|
|||||||
<div class="h-full overflow-hidden flex flex-col">
|
<div class="h-full overflow-hidden flex flex-col">
|
||||||
<OnboardingSteps v-if="!isOnboardingStepsCompleted && !showHelpCenter" />
|
<OnboardingSteps v-if="!isOnboardingStepsCompleted && !showHelpCenter" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1.5">
|
<div v-for="item in footerItems" class="flex flex-col gap-1.5">
|
||||||
<div
|
<div
|
||||||
v-if="!isOnboardingStepsCompleted && !showHelpCenter"
|
|
||||||
class="w-full flex gap-2 items-center hover:bg-surface-gray-1 text-ink-gray-8 rounded px-2 py-1.5 cursor-pointer"
|
class="w-full flex gap-2 items-center hover:bg-surface-gray-1 text-ink-gray-8 rounded px-2 py-1.5 cursor-pointer"
|
||||||
@click="showHelpCenter = !showHelpCenter"
|
@click="item.onClick"
|
||||||
>
|
>
|
||||||
<HelpIcon class="h-4" />
|
<component :is="item.icon" class="h-4" />
|
||||||
<div class="text-base">{{ __('Help centre') }}</div>
|
<div class="text-base">{{ __(item.label) }}</div>
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="showHelpCenter && !isOnboardingStepsCompleted"
|
|
||||||
class="w-full flex gap-2 items-center hover:bg-surface-gray-1 text-ink-gray-8 rounded px-2 py-1.5 cursor-pointer"
|
|
||||||
@click="showHelpCenter = !showHelpCenter"
|
|
||||||
>
|
|
||||||
<StepsIcon class="h-4" />
|
|
||||||
<div class="text-base">{{ __('Getting started') }}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -55,9 +41,61 @@ import MinimizeIcon from '@/components/Icons/MinimizeIcon.vue'
|
|||||||
import MaximizeIcon from '@/components/Icons/MaximizeIcon.vue'
|
import MaximizeIcon from '@/components/Icons/MaximizeIcon.vue'
|
||||||
import HelpIcon from '@/components/Icons/HelpIcon.vue'
|
import HelpIcon from '@/components/Icons/HelpIcon.vue'
|
||||||
import OnboardingSteps from '@/components/OnboardingSteps.vue'
|
import OnboardingSteps from '@/components/OnboardingSteps.vue'
|
||||||
import { isOnboardingStepsCompleted, minimize } from '@/composables/onboarding'
|
import {
|
||||||
import { ref } from 'vue'
|
isOnboardingStepsCompleted,
|
||||||
|
minimize,
|
||||||
|
useOnboarding,
|
||||||
|
} from '@/composables/onboarding'
|
||||||
|
import { onMounted, computed } from 'vue'
|
||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
const showHelpCenter = ref(false)
|
const showHelpCenter = ref(false)
|
||||||
|
|
||||||
|
const title = computed(() => {
|
||||||
|
if (!isOnboardingStepsCompleted.value && !showHelpCenter.value) {
|
||||||
|
return __('Getting started')
|
||||||
|
} else if (showHelpCenter.value) {
|
||||||
|
return __('Help center')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const footerItems = computed(() => {
|
||||||
|
let items = [
|
||||||
|
{
|
||||||
|
icon: HelpIcon,
|
||||||
|
label: __('Help centre'),
|
||||||
|
onClick: () => {
|
||||||
|
showHelpCenter.value = true
|
||||||
|
},
|
||||||
|
condition: !isOnboardingStepsCompleted.value && !showHelpCenter.value,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: StepsIcon,
|
||||||
|
label: __('Getting started'),
|
||||||
|
onClick: () => (showHelpCenter.value = false),
|
||||||
|
condition: showHelpCenter.value && !isOnboardingStepsCompleted.value,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: StepsIcon,
|
||||||
|
label: __('Reset onboarding steps'),
|
||||||
|
onClick: resetOnboardingSteps,
|
||||||
|
condition: showHelpCenter.value && isOnboardingStepsCompleted.value,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
return items.filter((item) => item.condition)
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetOnboardingSteps() {
|
||||||
|
const { reset } = useOnboarding()
|
||||||
|
reset()
|
||||||
|
isOnboardingStepsCompleted.value = false
|
||||||
|
showHelpCenter.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (isOnboardingStepsCompleted.value) {
|
||||||
|
showHelpCenter.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -199,7 +199,7 @@ export function useOnboarding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
updateAll(false)
|
updateAll(false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOnboardingStep(step, skipped = false) {
|
function updateOnboardingStep(step, skipped = false) {
|
||||||
@ -235,8 +235,8 @@ export function useOnboarding() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAll(value) {
|
function updateAll(value, reset = false) {
|
||||||
if (isOnboardingStepsCompleted.value) return
|
if (isOnboardingStepsCompleted.value && !reset) return
|
||||||
let user = window.user
|
let user = window.user
|
||||||
if (!user) return false
|
if (!user) return false
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user