-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
156 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, {useContext, useEffect, useState} from 'react' | ||
import {getCookie, setCookie} from "cookies-next"; | ||
import TutorialSteps from "./TutorialSteps"; | ||
import AppContext from "../../../context/AppContext"; | ||
import Joyride from "react-joyride"; | ||
import {equals} from "../js/functions"; | ||
import {Alert} from 'react-bootstrap' | ||
import {Binoculars} from "react-bootstrap-icons"; | ||
|
||
function AppTutorial() { | ||
const {isLoggedIn} = useContext(AppContext) | ||
const [steps, setSteps] = useState([]) | ||
const [runTutorial, setRunTutorial] = useState(false) | ||
const [showAlert, setShowAlert] = useState(false) | ||
const [stepIndex, setStepIndex] = useState(0) | ||
const cookieKey = `tutorialCompleted_${isLoggedIn()}` | ||
|
||
useEffect(() => { | ||
const tutorialCompleted = getCookie(cookieKey) | ||
if (!tutorialCompleted) { | ||
setShowAlert(true) | ||
setSteps(TutorialSteps(isLoggedIn())) | ||
} | ||
}, []) | ||
|
||
const handleTutorial = () => { | ||
setShowAlert(false) | ||
// Set a quick timeout to allow the alert to close | ||
// first before Joyride calculates the highlight region | ||
setTimeout(()=> { | ||
setRunTutorial(true) | ||
}, 200) | ||
} | ||
return ( | ||
<> | ||
<Alert variant="info" show={showAlert} onClose={() => setShowAlert(false)} dismissible className='text-center alert-hlf mb-4'> | ||
<Alert.Heading><Binoculars /> Getting Started</Alert.Heading> | ||
<p>Welcome to the SenNet Data Portal. Get a quick tour of different sections of the application.</p> | ||
<a className='btn btn-primary' onClick={() => handleTutorial()}>Begin Tutorial Tour</a> | ||
</Alert> | ||
{steps.length > 0 && <Joyride | ||
steps={steps} | ||
scrollOffset={80} | ||
callback={(res) => { | ||
console.log(res) | ||
if (equals(res.action, 'reset')) { | ||
setCookie(cookieKey, true, {sameSite: 'Lax'}) | ||
} | ||
} | ||
} | ||
run={runTutorial} | ||
showProgress={true} | ||
showSkipButton={true} | ||
locale={{last: 'Finish Tutorial'}} | ||
continuous | ||
styles={{ | ||
options: { | ||
arrowColor: '#ffffff', | ||
backgroundColor: '#ffffff', | ||
primaryColor: '#0d6efd', | ||
textColor: 'rgba(0, 0, 0, 0.87)', | ||
width: 900, | ||
zIndex: 1000, | ||
} | ||
}} | ||
/>} | ||
</> | ||
) | ||
} | ||
|
||
|
||
export default AppTutorial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
|
||
function TutorialSteps(loggedIn) { | ||
const stepsCount = loggedIn ? 6 : 4 | ||
let _steps = [ | ||
{ | ||
target: '#search', | ||
disableBeacon: true, | ||
title: <span>Search Entities by Free Text (1/{stepsCount})</span>, | ||
content: 'To further narrow the relevant entities, type search terms or phrases into the Search bar. Entities containing any of the search terms will be returned.' | ||
}, | ||
{ | ||
target: '.sui-facet', | ||
title: <span>Filter Your Browsing (2/{stepsCount})</span>, | ||
content: 'The faceted search options on the left side allows filtering entities by any combination of categories. Search results update automatically as you edit the selection of filters.', | ||
}, | ||
{ | ||
target: '[data-column-id="2"].rdt_TableCol', | ||
title: <span>Sort Search Results (3/{stepsCount})</span>, | ||
content: 'Clicking the header of any column will sort search results. A bolded arrow indicates the current sorting selection. Clicking again will reverse the order.' | ||
}, | ||
{ | ||
target: '#sui-tbl-checkbox-actions', | ||
title: <span>Download Search Results (4/{stepsCount})</span>, | ||
content: <span>Clicking on the checkboxes <input type={'checkbox'} role='presentation' disabled /> on the left side of the search results table allows selecting distinct entities for export. Clicking on the ellipsis <button | ||
role='presentation' | ||
className="dropdown-toggle btn btn-secondary-outline border-0">...</button> at the top of the search results table allows for exporting either only the selected entities or all entities in the table to a <code>JSON</code> or <code>TSV</code> format.</span> | ||
} | ||
] | ||
if (loggedIn){ | ||
_steps.push({ | ||
target: '#nav-dropdown', | ||
title: <span>Registering entities (5/{stepsCount})</span>, | ||
content: <span>You may register individual and bulk entities by clicking on this menu. Then selecting under <i>Single</i> for single registration or under <i>Bulk</i> for bulk registration.</span> | ||
}) | ||
|
||
_steps.push({ | ||
target: '#nav-dropdown--bulkMetadata', | ||
title: <span>Bulk uploading metadata (6/{stepsCount})</span>, | ||
content: <span>Select this menu to bulk upload metadata. <br /> <small className='text-muted'>Note: You may also upload metadata for a single entity during registration. See previous step for details.</small></span> | ||
}) | ||
} | ||
return _steps | ||
} | ||
export default TutorialSteps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters