mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-12 09:04:14 +02:00
Addead feature to start product tour on using the welcome template (#2468)
This commit is contained in:
parent
a30fef5848
commit
bca12fd4ce
@ -53,6 +53,11 @@ describe('components/boardTemplateSelector/boardTemplateSelector', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
const state = {
|
||||
users: {
|
||||
me: {
|
||||
id: 'user_id_1',
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
userWorkspaces: new Array<UserWorkspace>(workspace1),
|
||||
current: workspace1,
|
||||
|
@ -16,11 +16,15 @@ import {fetchGlobalTemplates, getGlobalTemplates} from '../../store/globalTempla
|
||||
import {useAppDispatch, useAppSelector} from '../../store/hooks'
|
||||
import TelemetryClient, {TelemetryActions, TelemetryCategory} from '../../telemetry/telemetryClient'
|
||||
|
||||
import './boardTemplateSelector.scss'
|
||||
import {OnboardingBoardTitle} from '../cardDetail/cardDetail'
|
||||
import {IUser, UserConfigPatch, UserPropPrefix} from '../../user'
|
||||
import {getMe, patchProps} from '../../store/users'
|
||||
import {BaseTourSteps, TOUR_BASE} from '../onboardingTour'
|
||||
|
||||
import BoardTemplateSelectorPreview from './boardTemplateSelectorPreview'
|
||||
import BoardTemplateSelectorItem from './boardTemplateSelectorItem'
|
||||
|
||||
import './boardTemplateSelector.scss'
|
||||
|
||||
type Props = {
|
||||
title?: React.ReactNode
|
||||
description?: React.ReactNode
|
||||
@ -35,6 +39,7 @@ const BoardTemplateSelector = (props: Props) => {
|
||||
const intl = useIntl()
|
||||
const history = useHistory()
|
||||
const match = useRouteMatch<{boardId: string, viewId?: string}>()
|
||||
const me = useAppSelector<IUser|null>(getMe)
|
||||
|
||||
const showBoard = useCallback(async (boardId) => {
|
||||
const params = {...match.params, boardId: boardId || ''}
|
||||
@ -69,6 +74,33 @@ const BoardTemplateSelector = (props: Props) => {
|
||||
const templates = useMemo(() => Object.values(unsortedTemplates).sort((a: Board, b: Board) => a.createAt - b.createAt), [unsortedTemplates])
|
||||
const allTemplates = globalTemplates.concat(templates)
|
||||
|
||||
const resetTour = async () => {
|
||||
TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.StartTour)
|
||||
|
||||
if (!me) {
|
||||
return
|
||||
}
|
||||
|
||||
const patch: UserConfigPatch = {
|
||||
updatedFields: {
|
||||
[UserPropPrefix + 'onboardingTourStep']: BaseTourSteps.OPEN_A_CARD.toString(),
|
||||
[UserPropPrefix + 'tourCategory']: TOUR_BASE,
|
||||
},
|
||||
}
|
||||
|
||||
const patchedProps = await octoClient.patchUserConfig(me.id, patch)
|
||||
if (patchedProps) {
|
||||
await dispatch(patchProps(patchedProps))
|
||||
}
|
||||
}
|
||||
|
||||
const handleUseTemplate = async () => {
|
||||
await mutator.addBoardFromTemplate(intl, showBoard, () => showBoard(currentBoard.id), activeTemplate.id, activeTemplate.workspaceId === '0')
|
||||
if (activeTemplate.title === OnboardingBoardTitle) {
|
||||
resetTour()
|
||||
}
|
||||
}
|
||||
|
||||
const [activeTemplate, setActiveTemplate] = useState<Board>(allTemplates[0])
|
||||
|
||||
useEffect(() => {
|
||||
@ -142,7 +174,7 @@ const BoardTemplateSelector = (props: Props) => {
|
||||
<Button
|
||||
filled={true}
|
||||
size={'medium'}
|
||||
onClick={() => mutator.addBoardFromTemplate(intl, showBoard, () => showBoard(currentBoard.id), activeTemplate.id, activeTemplate.workspaceId === '0')}
|
||||
onClick={handleUseTemplate}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='BoardTemplateSelector.use-this-template'
|
||||
|
Loading…
Reference in New Issue
Block a user