Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): remove guided tour popover #3493

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web/cypress/e2e/Home/CreateTestFromCurl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('Create test from CURL Command', () => {
cy.get(`[data-cy="import-test-submit"]`).click();
cy.submitCreateForm();
cy.matchTestRunPageUrl();
cy.cancelOnBoarding();
cy.get('[data-cy=overlay-input-overlay]').should('contain.text', POKEMON_HTTP_ENDPOINT);
cy.deleteTest(true);
});
Expand Down
1 change: 0 additions & 1 deletion web/cypress/e2e/Home/CreateTestFromPostman.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('Create test from Postman Collection', () => {
cy.get(`[data-cy="import-test-submit"]`).click();
cy.submitCreateForm();
cy.matchTestRunPageUrl();
cy.cancelOnBoarding();
cy.get('[data-cy=overlay-input-overlay]').should('contain.text', 'create Test');
cy.deleteTest(true);
});
Expand Down
1 change: 0 additions & 1 deletion web/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ Cypress.Commands.add('makeSureUserIsOnTestDetailPage', () => {

Cypress.Commands.add('makeSureUserIsOnTracePage', () => {
cy.matchTestRunPageUrl();
cy.cancelOnBoarding();
});

Cypress.Commands.add('cancelOnBoarding', () => {
Expand Down
56 changes: 1 addition & 55 deletions web/src/providers/GuidedTour/GuidedTour.provider.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import {Button, notification, Space} from 'antd';
import {noop} from 'lodash';
import React, {createContext, useCallback, useContext, useEffect, useMemo, useState} from 'react';
import React, {createContext, useCallback, useContext, useMemo, useState} from 'react';
import Joyride from 'react-joyride';
import {useLocation} from 'react-router-dom';

import StepContent from 'components/GuidedTour/StepContent';
import {CallbackByGuidedTour, StepsByGuidedTour} from 'components/GuidedTour/steps';
import {switchTestRunMode} from 'components/GuidedTour/testRunSteps';
import {IGuidedTourState} from 'constants/GuidedTour';
import {useAppDispatch, useAppSelector} from 'redux/hooks';
import {setUserPreference} from 'redux/slices/User.slice';
import UserSelectors from 'selectors/User.selectors';
import HomeAnalyticsService from 'services/Analytics/HomeAnalytics.service';
import GuidedTourService from 'services/GuidedTour.service';
import {useNotification} from '../Notification/Notification.provider';

const {onGuidedTourClick} = HomeAnalyticsService;
const NOTIFICATION_KEY = 'guided-tour-notification';

interface IContext {
isGuidedTourRunning: boolean;
Expand All @@ -37,62 +31,14 @@ interface IProps {
export const useGuidedTour = () => useContext(Context);

const GuidedTourProvider = ({children}: IProps) => {
const dispatch = useAppDispatch();
const pathname = useLocation().pathname;
const tourByPathname = GuidedTourService.getByPathName(pathname);
const {showNotification} = useNotification();
const [guidedTourState, setGuidedTourState] = useState<IGuidedTourState>({
callback: noop,
run: false,
stepIndex: 0,
steps: [],
});
const showGuidedTourNotification = useAppSelector(state =>
UserSelectors.selectUserPreference(state, 'showGuidedTourNotification')
);

useEffect(() => {
if (!tourByPathname || !showGuidedTourNotification) return;

const onSkip = () => {
notification.close(NOTIFICATION_KEY);
dispatch(setUserPreference({key: 'showGuidedTourNotification', value: false}));
};

const onStart = () => {
onGuidedTourClick(); // Analytics
onSkip();
switchTestRunMode(0);
setGuidedTourState(prev => ({
...prev,
callback: CallbackByGuidedTour[tourByPathname](setGuidedTourState),
run: true,
stepIndex: 0,
steps: StepsByGuidedTour[tourByPathname],
}));
};

const btn = (
<Space>
<Button data-cy="guided-tour-cancel-notification" ghost onClick={onSkip} type="primary">
No thanks
</Button>
<Button onClick={onStart} type="primary">
Show me around
</Button>
</Space>
);

showNotification({
type: 'open',
description: 'Walk through Tracetest features',
duration: 0,
btn,
key: NOTIFICATION_KEY,
title: 'Do you want to take a quick tour of Tracetest?',
onClose: onSkip,
});
}, [dispatch, showGuidedTourNotification, showNotification, tourByPathname]);

const onStart = useCallback(() => {
if (!tourByPathname) return;
Expand Down
Loading