From 46c96e81e09d8992e7714dd3f17cff39c1737e9b Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Fri, 11 Mar 2022 23:31:29 +0100 Subject: [PATCH] Dismiss tour from overlay (#2525) (#2531) * Shows "(Deleted User)" instead of UUID when user not found (#2354) (#2465) * Shows "(Deleted User)" instead of long, unreadable UUID in case the user is not found In case a user is not found, at present unreadable and long UUIDs are shown which kill the look and feel of the application. This patch replaces the UUID with a more explanatory string. * Update server/services/store/mattermostauthlayer/mattermostauthlayer.go Co-authored-by: Doug Lauder (cherry picked from commit 68819185a4278be3493188b13894af228121e798) Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com> * Update CHANGELOG.md for v0.15 Added one more merged PR to the list * Added ability to dismiss tour from overlay * GH-2212 - Update global link on board (#2492) (#2495) (cherry picked from commit 49df41f9b2e05344f5ca00c0a6fcfcd6cfac2606) Co-authored-by: Asaad Mahmood * GH-2387 - Fixing link in comments (#2480) (#2498) (cherry picked from commit 5e2cf0b38699d4be9722482e0a56367fb690c452) Co-authored-by: Asaad Mahmood * Addead feature to start product tour on using the welcome template (#2468) * Fixed a bug where images of the welcome board were not copied over. (#2453) * Fixed a buig where images of welcome board were not copied over * Lint fixes * Fixed test * Fixed test * Fixed intended behavio * lint fixes * Fixed tests * Fixed tests Co-authored-by: Mattermost Build Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com> Co-authored-by: Winson Wu <93531870+wuwinson@users.noreply.github.com> Co-authored-by: Asaad Mahmood Co-authored-by: Mattermod (cherry picked from commit a53e94748993f223198e52546c4ea4cf120cdea4) Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> --- webapp/src/components/cardDialog.test.tsx | 1 + webapp/src/components/centerPanel.test.tsx | 1 + .../addProperties/add_properties.tsx | 64 ++++++++++++++++++- .../pulsating_dot/pulsating_dot.scss | 5 +- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/webapp/src/components/cardDialog.test.tsx b/webapp/src/components/cardDialog.test.tsx index dd1da60bc62..e6f727c3be8 100644 --- a/webapp/src/components/cardDialog.test.tsx +++ b/webapp/src/components/cardDialog.test.tsx @@ -55,6 +55,7 @@ describe('components/cardDialog', () => { cards: { [card.id]: card, }, + current: card.id, }, boards: { boards: { diff --git a/webapp/src/components/centerPanel.test.tsx b/webapp/src/components/centerPanel.test.tsx index 380425a3c68..9f3deb0a102 100644 --- a/webapp/src/components/centerPanel.test.tsx +++ b/webapp/src/components/centerPanel.test.tsx @@ -98,6 +98,7 @@ describe('components/centerPanel', () => { cards: { templates: [card1, card2], cards: [card1, card2], + current: card1.id, }, views: { views: { diff --git a/webapp/src/components/onboardingTour/addProperties/add_properties.tsx b/webapp/src/components/onboardingTour/addProperties/add_properties.tsx index 662c6d5f379..0b63efe30d1 100644 --- a/webapp/src/components/onboardingTour/addProperties/add_properties.tsx +++ b/webapp/src/components/onboardingTour/addProperties/add_properties.tsx @@ -1,6 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react' +import React, {useEffect} from 'react' import {FormattedMessage} from 'react-intl' @@ -10,8 +10,21 @@ import './add_properties.scss' import {Utils} from '../../../utils' import addProperty from '../../../../static/addProperty.gif' -import {CardTourSteps, TOUR_CARD} from '../index' +import {BaseTourSteps, CardTourSteps, TOUR_BASE, TOUR_CARD} from '../index' import TourTipRenderer from '../tourTipRenderer/tourTipRenderer' +import {OnboardingBoardTitle, OnboardingCardTitle} from '../../cardDetail/cardDetail' +import {useAppDispatch, useAppSelector} from '../../../store/hooks' +import { + getMe, + getOnboardingTourCategory, + getOnboardingTourStarted, + getOnboardingTourStep, + patchProps, +} from '../../../store/users' +import {IUser, UserConfigPatch, UserPropPrefix} from '../../../user' +import mutator from '../../../mutator' +import {getCurrentBoard} from '../../../store/boards' +import {getCurrentCard} from '../../../store/cards' const AddPropertiesTourStep = (): JSX.Element | null => { const title = ( @@ -29,6 +42,53 @@ const AddPropertiesTourStep = (): JSX.Element | null => { const punchout = useMeasurePunchouts(['.octo-propertyname.add-property'], []) + const me = useAppSelector(getMe) + const dispatch = useAppDispatch() + + const board = useAppSelector(getCurrentBoard) + const isOnboardingBoard = board ? board.title === OnboardingBoardTitle : false + + const card = useAppSelector(getCurrentCard) + const isOnboardingCard = card ? card.title === OnboardingCardTitle : false + + const onboardingTourStarted = useAppSelector(getOnboardingTourStarted) + const onboardingTourCategory = useAppSelector(getOnboardingTourCategory) + const onboardingTourStep = useAppSelector(getOnboardingTourStep) + + // start the card tour if onboarding card is opened up + // and the user is still on the base tour + useEffect(() => { + async function task() { + if (!me || !card) { + return + } + + const should = card.id && + isOnboardingBoard && + isOnboardingCard && + onboardingTourStarted && + onboardingTourCategory === TOUR_BASE && + onboardingTourStep === BaseTourSteps.OPEN_A_CARD.toString() + + if (!should) { + return + } + + const patch: UserConfigPatch = {} + patch.updatedFields = {} + patch.updatedFields[UserPropPrefix + 'tourCategory'] = TOUR_CARD + patch.updatedFields[UserPropPrefix + 'onboardingTourStep'] = CardTourSteps.ADD_PROPERTIES.toString() + + const updatedProps = await mutator.patchUserConfig(me.id, patch) + if (updatedProps) { + dispatch(patchProps(updatedProps)) + } + } + + // this hack is needed to allow performing async task in useEffect + task() + }, [card]) + return (