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

Feature dashboard tab && bot preview && joyride configuration #6762

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const BotBuilder = ({ app, active_tab, onboard_tour_run_state, setOnBoardTourRun
const { onMount, onUnmount } = app;

React.useEffect(() => {
if (!onboard_tour_run_state) setOnBoardTourRunState(false);
onMount();
return () => onUnmount();
}, []);
Expand Down
19 changes: 12 additions & 7 deletions packages/bot-web-ui/src/components/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Tabs } from '@deriv/components';
import { localize } from '@deriv/translations';
import Chart from 'Components/chart';
import ReactJoyride from 'react-joyride';
import { DBOT_ONBOARDING, handleJoyrideCallback, getTourStatus } from './joyride-config';
import { DBOT_ONBOARDING, handleJoyrideCallback, getTourSettings } from './joyride-config';
import classNames from 'classnames';
import { connect } from 'Stores/connect';
import RootStore from 'Stores/index';
Expand Down Expand Up @@ -32,15 +32,14 @@ const Dashboard = ({
setActiveTab,
toggleStrategyModal,
onEntered,
setTourActive,
has_tour_started,
has_file_loaded,
is_drawer_open,
onboard_tour_run_state,
setOnBoardTourRunState,
}: TDashboard) => {
const [show_side_bar, setShowSideBar] = React.useState<boolean>(true);
const [is_tour_running, setTourRun] = React.useState<boolean>(true);

const handleClick = (e: React.MouseEvent) => {
e.preventDefault();
setTourRun(true);
Expand All @@ -51,9 +50,16 @@ const Dashboard = ({
if (active_tab === 0 && has_file_loaded) {
onEntered();
}
const status = getTourStatus();
if (status === 'ready') setOnBoardTourRunState(false);
}, [active_tab]);
const tour_status = getTourSettings('status');

if (tour_status) {
const { action } = tour_status;
if (action === 'skip' || action === 'close' || action === 'reset') {
rupato-deriv marked this conversation as resolved.
Show resolved Hide resolved
setOnBoardTourRunState(false);
setTourActive(false);
}
}
}, [active_tab, handleJoyrideCallback]);
return (
<>
<div className='dashboard__main'>
Expand Down Expand Up @@ -124,7 +130,6 @@ export default connect(({ dashboard, quick_strategy, run_panel, load_modal }: Ro
setActiveTab: dashboard.setActiveTab,
toggleStrategyModal: quick_strategy.toggleStrategyModal,
is_drawer_open: run_panel.is_drawer_open,
onboard_tour_run_state: dashboard.onboard_tour_run_state,
onEntered: load_modal.onEntered,
has_file_loaded: dashboard.has_file_loaded,
has_tour_started: dashboard.has_tour_started,
Expand Down
30 changes: 18 additions & 12 deletions packages/bot-web-ui/src/components/dashboard/joyride-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ type TStep = {

export const getImageLocation = (image_name: string) => getUrlBase(`/public/images/common/${image_name}`);

export const setOnBoardTourToken = () => {
return storeSetting('onboard_tour_token', new Date().getTime());
};

export const getOnBoardTourToken = () => {
return getSetting('onboard_tour_token');
};

export const setTourStatus = (param: string) => {
export const setTourSettings = (param: number | { [key: string]: string }, type: string) => {
if (type === 'token') {
return storeSetting('onboard_tour_token', param);
}
return storeSetting('onboard_tour_status', param);
};

export const getTourStatus = () => {
export const getTourSettings = (type: string) => {
if (type === 'token') {
return getSetting('onboard_tour_token');
}
return getSetting('onboard_tour_status');
};

Expand All @@ -48,10 +46,18 @@ export const Step = ({ label, content }: TStep) => {
);
};

let onboarding_tour: { [key: string]: string } = {};
let current_target: number;
export const handleJoyrideCallback = (data: CallBackProps) => {
const { action, index, status, type } = data;
setTourStatus(status);
if (!getOnBoardTourToken()) setOnBoardTourToken();
if (current_target !== undefined && current_target !== index) {
rupato-deriv marked this conversation as resolved.
Show resolved Hide resolved
onboarding_tour = {};
onboarding_tour.status = status;
onboarding_tour.action = action;
}
current_target = index;
setTourSettings(onboarding_tour, 'tour');
if (!getTourSettings('token')) setTourSettings(new Date().getTime(), 'token');
};

type TJoyrideProps = Record<'showProgress' | 'showSkipButton' | 'spotlightClicks' | 'disableBeacon', boolean>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
.quick-strategy {
$quick-strategy: &;
height: calc(100vh - 16.6rem);
background: var(--content-bg-color);

&__notifications-container {
&--open {
Expand Down
36 changes: 18 additions & 18 deletions packages/bot-web-ui/src/stores/load-modal-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,26 @@ export default class LoadModalStore implements ILoadModalStore {
return;
}

//if (!this.recent_workspace || !this.recent_workspace.rendered) {
//TODO: this was the check check used on the older functionality
const ref = document.getElementById('load-strategy__blockly-container');
if (!this.recent_workspace || !this.recent_workspace.rendered) {
//TODO: this was the check check used on the older functionality
const ref = document.getElementById('load-strategy__blockly-container');

if (!ref) {
// eslint-disable-next-line no-console
console.warn('Could not find preview workspace element.');
return;
}

if (!ref) {
// eslint-disable-next-line no-console
console.warn('Could not find preview workspace element.');
return;
this.recent_workspace = Blockly.inject(ref, {
media: `${__webpack_public_path__}media/`,
zoom: {
wheel: true,
startScale: config.workspaces.previewWorkspaceStartScale,
},
readOnly: true,
scrollbars: true,
});
}

this.recent_workspace = Blockly.inject(ref, {
media: `${__webpack_public_path__}media/`,
zoom: {
wheel: true,
startScale: config.workspaces.previewWorkspaceStartScale,
},
readOnly: true,
scrollbars: true,
});
//}
load({ block_string: this.selected_strategy.xml, drop_event: {}, workspace: this.recent_workspace });
}

Expand Down