(
-
-)
+const StartExploringContainer = () => {
+ const { enabled, handleJoyrideCallback } = useTours()
+ return (
+
+ )
+}
-export default connect(
- 'selectToursEnabled',
- withTour(StartExploringContainer)
-)
+export default StartExploringContainer
diff --git a/src/files/FilesPage.js b/src/files/FilesPage.js
index ede996fd1..e5b39b2d2 100644
--- a/src/files/FilesPage.js
+++ b/src/files/FilesPage.js
@@ -3,12 +3,12 @@ import { findDOMNode } from 'react-dom'
import { Helmet } from 'react-helmet'
import { connect } from 'redux-bundler-react'
import { withTranslation, Trans } from 'react-i18next'
-import ReactJoyride from 'react-joyride'
+import ReactJoyride, { STATUS } from 'react-joyride'
+import { useTours } from '../contexts/tours-context'
// Lib
import { filesTour } from '../lib/tours.js'
// Components
import ContextMenu from './context-menu/ContextMenu.js'
-import withTour from '../components/tour/withTour.js'
import InfoBoxes from './info-boxes/InfoBoxes.js'
import FilePreview from './file-preview/FilePreview.js'
import FilesList from './files-list/FilesList.js'
@@ -30,8 +30,15 @@ const FilesPage = ({
doFetchPinningServices, doFilesFetch, doPinsFetch, doFilesSizeGet, doFilesDownloadLink, doFilesDownloadCarLink, doFilesWrite, doAddCarFile, doFilesBulkCidImport, doFilesAddPath, doUpdateHash,
doFilesUpdateSorting, doFilesNavigateTo, doFilesMove, doSetCliOptions, doFetchRemotePins, remotePins, pendingPins, failedPins,
ipfsProvider, ipfsConnected, doFilesMakeDir, doFilesShareLink, doFilesCopyCidProvide, doFilesDelete, doSetPinning, onRemotePinClick, doPublishIpnsKey,
- files, filesPathInfo, pinningServices, toursEnabled, handleJoyrideCallback, isCliTutorModeEnabled, cliOptions, t
+ files, filesPathInfo, pinningServices, isCliTutorModeEnabled, cliOptions, t
}) => {
+ const { enabled: toursEnabled, disableTours } = useTours()
+ const handleJoyrideCallback = useCallback((data) => {
+ const { action, status } = data
+ if (action === 'close' || status === STATUS.FINISHED) {
+ disableTours()
+ }
+ }, [disableTours])
const { doExploreUserProvidedPath } = useExplore()
const contextMenuRef = useRef()
const [modals, setModals] = useState({ show: null, files: null })
@@ -435,7 +442,6 @@ export default connect(
'doFilesNavigateTo',
'doFilesUpdateSorting',
'selectFilesSorting',
- 'selectToursEnabled',
'doFilesWrite',
'doFilesBulkCidImport',
'doFilesDownloadLink',
@@ -448,5 +454,5 @@ export default connect(
'selectCliOptions',
'doSetPinning',
'doPublishIpnsKey',
- withTour(withTranslation('files')(FilesPage))
+ withTranslation('files')(FilesPage)
)
diff --git a/src/index.js b/src/index.js
index 5ac1181b2..8488389d0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -12,6 +12,7 @@ import { DndProvider } from 'react-dnd'
import DndBackend from './lib/dnd-backend.js'
import { HeliaProvider, ExploreProvider } from 'ipld-explorer-components/providers'
import { ContextBridgeProvider } from './helpers/context-bridge.jsx'
+import { ToursProvider } from './contexts/tours-context'
const appVersion = process.env.REACT_APP_VERSION
const gitRevision = process.env.REACT_APP_GIT_REV
@@ -35,6 +36,7 @@ async function render () {
ReactDOM.render(
+
@@ -44,6 +46,7 @@ async function render () {
+
,
document.getElementById('root')
diff --git a/src/peers/PeersPage.js b/src/peers/PeersPage.js
index 4f2bcc266..b9b749325 100644
--- a/src/peers/PeersPage.js
+++ b/src/peers/PeersPage.js
@@ -1,11 +1,11 @@
-import React from 'react'
+import React, { useCallback } from 'react'
import { connect } from 'redux-bundler-react'
import { Helmet } from 'react-helmet'
import { withTranslation } from 'react-i18next'
-import ReactJoyride from 'react-joyride'
-import withTour from '../components/tour/withTour.js'
+import ReactJoyride, { STATUS } from 'react-joyride'
import { peersTour } from '../lib/tours.js'
import { getJoyrideLocales } from '../helpers/i8n.js'
+import { useTours } from '../contexts/tours-context'
// Components
import Box from '../components/box/Box.js'
@@ -15,7 +15,15 @@ import AddConnection from './AddConnection/AddConnection.js'
import CliTutorMode from '../components/cli-tutor-mode/CliTutorMode.js'
import { cliCmdKeys, cliCommandList } from '../bundles/files/consts.js'
-const PeersPage = ({ t, toursEnabled, handleJoyrideCallback }) => (
+const PeersPage = ({ t }) => {
+ const { enabled: toursEnabled, disableTours } = useTours()
+ const handleJoyrideCallback = useCallback((data) => {
+ const { action, status } = data
+ if (action === 'close' || status === STATUS.FINISHED) {
+ disableTours()
+ }
+ }, [disableTours])
+ return (
{t('title')} | IPFS
@@ -41,10 +49,10 @@ const PeersPage = ({ t, toursEnabled, handleJoyrideCallback }) => (
locale={getJoyrideLocales(t)}
showProgress />
-)
+ )
+}
export default connect(
- 'selectToursEnabled',
'selectIsCliTutorModeEnabled',
- withTour(withTranslation('peers')(PeersPage))
+ withTranslation('peers')(PeersPage)
)
diff --git a/src/settings/SettingsPage.js b/src/settings/SettingsPage.js
index fc52316cc..ca356c09f 100644
--- a/src/settings/SettingsPage.js
+++ b/src/settings/SettingsPage.js
@@ -1,12 +1,12 @@
-import React from 'react'
+import React, { useCallback } from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'redux-bundler-react'
import { withTranslation, Trans } from 'react-i18next'
-import ReactJoyride from 'react-joyride'
+import ReactJoyride, { STATUS } from 'react-joyride'
// Tour
import { settingsTour } from '../lib/tours.js'
-import withTour from '../components/tour/withTour.js'
import { getJoyrideLocales } from '../helpers/i8n.js'
+import { useTours } from '../contexts/tours-context'
// Components
import Tick from '../icons/GlyphSmallTick.js'
import Box from '../components/box/Box.js'
@@ -375,6 +375,24 @@ export class SettingsPageContainer extends React.Component {
export const TranslatedSettingsPage = withTranslation('settings')(SettingsPageContainer)
+const SettingsPageWithTours = (props) => {
+ const { enabled: toursEnabled, disableTours, disableTooltip } = useTours()
+ const handleJoyrideCallback = useCallback((data) => {
+ const { action, status } = data
+ if (action === 'close' || status === STATUS.FINISHED) {
+ disableTours()
+ }
+ }, [disableTours])
+ return (
+
+ )
+}
+
export default connect(
'selectConfig',
'selectIpfsConnected',
@@ -385,7 +403,6 @@ export default connect(
'selectConfigSaveLastSuccess',
'selectConfigSaveLastError',
'selectIsIpfsDesktop',
- 'selectToursEnabled',
'selectShowAnalyticsComponents',
'selectAnalyticsEnabled',
'selectArePinningServicesSupported',
@@ -393,5 +410,5 @@ export default connect(
'doSaveConfig',
'selectIsCliTutorModeEnabled',
'doToggleCliTutorMode',
- withTour(TranslatedSettingsPage)
+ SettingsPageWithTours
)
diff --git a/src/status/StatusPage.js b/src/status/StatusPage.js
index 214c5884e..d4c309b57 100644
--- a/src/status/StatusPage.js
+++ b/src/status/StatusPage.js
@@ -1,8 +1,8 @@
-import React from 'react'
+import React, { useCallback } from 'react'
import { Helmet } from 'react-helmet'
import { withTranslation, Trans } from 'react-i18next'
import { connect } from 'redux-bundler-react'
-import ReactJoyride from 'react-joyride'
+import ReactJoyride, { STATUS } from 'react-joyride'
import { IdentityProvider } from '../contexts/identity-context.jsx'
import StatusConnected from './StatusConnected.js'
import BandwidthStatsDisabled from './BandwidthStatsDisabled.js'
@@ -15,7 +15,7 @@ import Box from '../components/box/Box.js'
import AnalyticsBanner from '../components/analytics-banner/AnalyticsBanner.js'
import { statusTour } from '../lib/tours.js'
import { getJoyrideLocales } from '../helpers/i8n.js'
-import withTour from '../components/tour/withTour.js'
+import { useTours } from '../contexts/tours-context'
const StatusPage = ({
t,
@@ -25,10 +25,15 @@ const StatusPage = ({
doEnableAnalytics,
doDisableAnalytics,
doToggleShowAnalyticsBanner,
- toursEnabled,
- handleJoyrideCallback,
nodeBandwidthEnabled
}) => {
+ const { enabled, disableTours } = useTours()
+ const handleJoyrideCallback = useCallback((data) => {
+ const { action, status } = data
+ if (action === 'close' || status === STATUS.FINISHED) {
+ disableTours()
+ }
+ }, [disableTours])
return (
@@ -79,7 +84,7 @@ const StatusPage = ({
:
}
void} props.handleJoyrideCallback
*/
-const WelcomePage = ({ t, ipfsInitFailed, ipfsConnected, ipfsReady, toursEnabled, handleJoyrideCallback }) => {
+const WelcomePage = ({ t, ipfsInitFailed, ipfsConnected, ipfsReady }) => {
+ const { enabled: toursEnabled, disableTours } = useTours()
const isSameOrigin = useBridgeSelector('selectIsSameOrigin')
+ const handleJoyrideCallback = useCallback(
+ /**
+ * @param {import('react-joyride').CallBackProps} data
+ */
+ (data) => {
+ const { action, status } = data
+ if (action === 'close' || status === STATUS.FINISHED) {
+ disableTours()
+ }
+ }, [disableTours])
if (!ipfsInitFailed && !ipfsReady) {
return
@@ -83,6 +94,5 @@ export default connect(
'selectIpfsInitFailed',
'selectIpfsConnected',
'selectIpfsReady',
- 'selectToursEnabled',
- withTour(withTranslation('welcome')(WelcomePage))
+ withTranslation('welcome')(WelcomePage)
)