2024-02-18 23:05:15 +00:00
|
|
|
import variables from 'config/variables';
|
2023-03-21 19:59:16 +00:00
|
|
|
import { PureComponent } from 'react';
|
2021-08-15 21:28:37 +00:00
|
|
|
import Modal from 'react-modal';
|
2021-07-02 20:29:33 +00:00
|
|
|
|
2021-04-11 10:17:09 +00:00
|
|
|
import Main from './main/Main';
|
2021-03-20 12:55:20 +00:00
|
|
|
import Navbar from '../widgets/navbar/Navbar';
|
2021-10-13 19:00:40 +00:00
|
|
|
import Preview from '../helpers/preview/Preview';
|
2021-03-20 12:55:20 +00:00
|
|
|
|
2024-02-19 09:42:59 +00:00
|
|
|
import EventBus from 'utils/eventbus';
|
2021-03-20 12:55:20 +00:00
|
|
|
|
2022-04-08 22:01:32 +00:00
|
|
|
import Welcome from './welcome/Welcome';
|
2021-03-20 12:55:20 +00:00
|
|
|
|
2021-08-14 19:10:48 +00:00
|
|
|
export default class Modals extends PureComponent {
|
2021-03-23 13:10:34 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
2021-03-20 12:55:20 +00:00
|
|
|
this.state = {
|
|
|
|
mainModal: false,
|
|
|
|
updateModal: false,
|
|
|
|
welcomeModal: false,
|
2024-02-01 20:18:46 +00:00
|
|
|
appsModal: false,
|
2022-04-08 13:48:36 +00:00
|
|
|
preview: false,
|
2021-03-20 12:55:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2022-04-08 13:48:36 +00:00
|
|
|
if (
|
|
|
|
localStorage.getItem('showWelcome') === 'true' &&
|
|
|
|
window.location.search !== '?nointro=true'
|
|
|
|
) {
|
2021-03-20 12:55:20 +00:00
|
|
|
this.setState({
|
2022-04-08 13:48:36 +00:00
|
|
|
welcomeModal: true,
|
2021-03-20 12:55:20 +00:00
|
|
|
});
|
2021-09-28 22:04:04 +00:00
|
|
|
variables.stats.postEvent('modal', 'Opened welcome');
|
2021-03-20 12:55:20 +00:00
|
|
|
}
|
2021-04-14 20:20:43 +00:00
|
|
|
|
2021-09-03 11:31:12 +00:00
|
|
|
if (window.location.search === '?nointro=true') {
|
|
|
|
if (localStorage.getItem('showWelcome') === 'true') {
|
|
|
|
localStorage.setItem('showWelcome', false);
|
2023-03-16 11:11:18 +00:00
|
|
|
EventBus.emit('refresh', 'widgets');
|
|
|
|
EventBus.emit('refresh', 'backgroundwelcome');
|
2021-09-03 11:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 20:20:43 +00:00
|
|
|
// hide refresh reminder once the user has refreshed the page
|
|
|
|
localStorage.setItem('showReminder', false);
|
2021-03-20 12:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
closeWelcome() {
|
|
|
|
localStorage.setItem('showWelcome', false);
|
|
|
|
this.setState({
|
2022-04-08 13:48:36 +00:00
|
|
|
welcomeModal: false,
|
2021-03-20 12:55:20 +00:00
|
|
|
});
|
2023-03-16 11:11:18 +00:00
|
|
|
EventBus.emit('refresh', 'widgetsWelcomeDone');
|
|
|
|
EventBus.emit('refresh', 'widgets');
|
|
|
|
EventBus.emit('refresh', 'backgroundwelcome');
|
2021-06-21 16:42:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-13 19:00:40 +00:00
|
|
|
previewWelcome() {
|
|
|
|
localStorage.setItem('showWelcome', false);
|
2021-11-01 13:24:09 +00:00
|
|
|
localStorage.setItem('welcomePreview', true);
|
2021-10-13 19:00:40 +00:00
|
|
|
this.setState({
|
|
|
|
welcomeModal: false,
|
2022-04-08 13:48:36 +00:00
|
|
|
preview: true,
|
2021-10-13 19:00:40 +00:00
|
|
|
});
|
2023-03-16 11:11:18 +00:00
|
|
|
EventBus.emit('refresh', 'widgetsWelcome');
|
2021-10-13 19:00:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-21 16:42:14 +00:00
|
|
|
toggleModal(type, action) {
|
|
|
|
this.setState({
|
2022-04-08 13:48:36 +00:00
|
|
|
[type]: action,
|
2021-06-21 16:42:14 +00:00
|
|
|
});
|
2021-06-21 22:03:47 +00:00
|
|
|
|
|
|
|
if (action !== false) {
|
2021-09-28 22:04:04 +00:00
|
|
|
variables.stats.postEvent('modal', `Opened ${type.replace('Modal', '')}`);
|
2021-06-21 22:03:47 +00:00
|
|
|
}
|
2021-03-20 12:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2021-03-22 22:17:52 +00:00
|
|
|
<>
|
2024-01-01 11:47:58 +00:00
|
|
|
{this.state.welcomeModal === false && (
|
2022-04-08 13:48:36 +00:00
|
|
|
<Navbar openModal={(modal) => this.toggleModal(modal, true)} />
|
2024-01-01 11:47:58 +00:00
|
|
|
)}
|
2022-04-08 13:48:36 +00:00
|
|
|
<Modal
|
|
|
|
closeTimeoutMS={300}
|
|
|
|
id="modal"
|
|
|
|
onRequestClose={() => this.toggleModal('mainModal', false)}
|
|
|
|
isOpen={this.state.mainModal}
|
|
|
|
className="Modal mainModal"
|
|
|
|
overlayClassName="Overlay"
|
|
|
|
ariaHideApp={false}
|
|
|
|
>
|
|
|
|
<Main modalClose={() => this.toggleModal('mainModal', false)} />
|
2022-04-07 20:49:43 +00:00
|
|
|
</Modal>
|
2022-04-08 22:01:32 +00:00
|
|
|
<Modal
|
2022-04-11 21:57:07 +00:00
|
|
|
closeTimeoutMS={300}
|
|
|
|
onRequestClose={() => this.closeWelcome()}
|
|
|
|
isOpen={this.state.welcomeModal}
|
|
|
|
className="Modal welcomemodal mainModal"
|
2022-08-07 17:36:56 +00:00
|
|
|
overlayClassName="Overlay mainModal"
|
2022-04-11 21:57:07 +00:00
|
|
|
shouldCloseOnOverlayClick={false}
|
|
|
|
ariaHideApp={false}
|
|
|
|
>
|
|
|
|
<Welcome modalClose={() => this.closeWelcome()} modalSkip={() => this.previewWelcome()} />
|
|
|
|
</Modal>
|
2024-01-01 11:47:58 +00:00
|
|
|
{this.state.preview && <Preview setup={() => window.location.reload()} />}
|
2021-03-22 22:17:52 +00:00
|
|
|
</>
|
2021-03-20 12:55:20 +00:00
|
|
|
);
|
|
|
|
}
|
2021-07-12 10:34:05 +00:00
|
|
|
}
|