Skip to content

Commit

Permalink
define data-tour attribute for the tours
Browse files Browse the repository at this point in the history
  • Loading branch information
Beking0912 committed Aug 18, 2023
1 parent 51ab5f2 commit 6cb6558
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/pages/groupComparison/GroupComparisonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export default class GroupComparisonPage extends React.Component<
break;
case 1:
studyHeader = (
<h3 id="single-study-group-comparison-header">
<h3 data-tour="single-study-group-comparison-header">
<StudyLink studyId={studies[0].studyId}>
{studies[0].name}
</StudyLink>
Expand Down Expand Up @@ -393,7 +393,7 @@ export default class GroupComparisonPage extends React.Component<
<span>
{studyHeader}Groups from{' '}
<span
id="single-study-group-comparison-attribute"
data-tour="single-study-group-comparison-attribute"
style={{ fontWeight: 'bold', fontStyle: 'italic' }}
>
{this.store.sessionClinicalAttributeName}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/groupComparison/groupSelector/GroupSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class GroupSelector extends React.Component<
);
return (
<div
id="single-study-group-comparison-groups"
data-tour="single-study-group-comparison-groups"
style={{
display: 'flex',
alignItems: 'center',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/studyView/charts/ChartContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export class ChartContainer extends React.Component<IChartContainerProps, {}> {
return {
content: (
<div
id="mutated-genes-table-compare-btn"
data-tour="mutated-genes-table-compare-btn"
style={{ display: 'flex', alignItems: 'center' }}
>
<ComparisonVsIcon
Expand Down
2 changes: 1 addition & 1 deletion src/pages/studyView/studyPageHeader/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default class ActionButtons extends React.Component<
overlay={<span>{this.virtualStudyButtonTooltip}</span>}
>
<button
id="action-button-bookmark"
data-tour="action-button-bookmark"
className="btn btn-default btn-sm"
disabled={!this.props.loadingComplete}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class StudySummary extends React.Component<
{this.descriptionFirstLine}
{this.hasMoreDescription && (
<i
id="show-more-description-icon"
data-tour="show-more-description-icon"
className={`fa fa-${
this.showMoreDescription ? 'minus' : 'plus'
}-circle`}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/studyView/tabs/SummaryTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ export class StudySummaryTab extends React.Component<
// 2. The maintainer of RGL repo currently not actively accepts pull requests. So we don't know when the
// issue will be solved.
return (
<div key={chartMeta.uniqueKey} id={props.id}>
<div key={chartMeta.uniqueKey} data-tour={props.id}>
<DelayedRender>
{/* Delay the render after a setTimeout, because synchronous rendering would jam UI updates
and make things laggy */}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/studyView/virtualStudy/VirtualStudy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default class VirtualStudy extends React.Component<
render() {
return (
<div
id="virtual-study-summary-panel"
data-tour="virtual-study-summary-panel"
className={styles.virtualStudy}
>
<If condition={this.virtualStudy.isError}>
Expand Down Expand Up @@ -280,7 +280,7 @@ export default class VirtualStudy extends React.Component<
<div className="input-group-btn">
{this.showSaveButton && (
<button
id="virtual-study-summary-save-btn"
data-tour="virtual-study-summary-save-btn"
className={classnames(
'btn btn-default',
styles.saveButton
Expand Down Expand Up @@ -312,7 +312,7 @@ export default class VirtualStudy extends React.Component<
</button>
)}
<button
id="virtual-study-summary-share-btn"
data-tour="virtual-study-summary-share-btn"
className={classnames(
'btn btn-default',
styles.saveButton
Expand Down Expand Up @@ -427,7 +427,7 @@ export default class VirtualStudy extends React.Component<
</span>
{this.saving && (
<span
id="virtual-study-summary-query-btn"
data-tour="virtual-study-summary-query-btn"
className="btn btn-default"
onClick={event => {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PageLayout extends React.Component<IPageLayout, {}> {
noMargin
)}
>
<div id="mainColumn">
<div id="mainColumn" data-tour="mainColumn">
<div>{this.props.children}</div>
</div>
{this.props.rightBar && (
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/query/CancerStudySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default class CancerStudySelector extends React.Component<

return (
<div
id="cancer-study-search-box"
data-tour="cancer-study-search-box"
style={{
display: 'flex',
alignItems: 'center',
Expand Down Expand Up @@ -269,7 +269,7 @@ export default class CancerStudySelector extends React.Component<
</Then>
</If>
<div
id="cancer-study-list-container"
data-tour="cancer-study-list-container"
className={styles.cancerStudyListContainer}
data-test="cancerTypeListContainer"
>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/query/QueryContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export default class QueryContainer extends React.Component<
}
>
<a
id="explore-studies-button"
data-tour="explore-studies-button"
onClick={() =>
!this
.exploreCohortsButtonDisabled &&
Expand Down
6 changes: 5 additions & 1 deletion src/shared/components/query/studyList/StudyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ export default class StudyList extends QueryStoreComponent<
styles.Level(currentLevel)
);
return (
<ul id={cancerType.id} key={arrayIndex} className={ulClassName}>
<ul
data-tour={cancerType.id}
key={arrayIndex}
className={ulClassName}
>
{heading}
{childStudies.map(this.renderCancerStudy)}
{childCancerTypes.map(this.renderCancerType)}
Expand Down
22 changes: 11 additions & 11 deletions src/tours/Steps/GroupComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getSteps: GetSteps = ({
}) => [
// Step 0: Type “glioma” in the search box
{
selector: '#cancer-study-search-box input',
selector: '[data-tour="cancer-study-search-box"] input',
content: () => (
<div className="step">
<p className="title">Search for the studies</p>
Expand All @@ -30,7 +30,7 @@ const getSteps: GetSteps = ({
},
// Step 1: Click on “View study summary” button
{
selector: '#cancer-study-list-container',
selector: '[data-tour="cancer-study-list-container"]',
content: () => (
<div className="step">
<p className="title">Click the button</p>
Expand All @@ -48,7 +48,7 @@ const getSteps: GetSteps = ({
// Step 2: Select more than one sample in the Mutated Genes table
// TODO: must have overlap
{
selector: '#mutated-genes-table',
selector: '[data-tour="mutated-genes-table"]',
content: () => (
<div className="step">
<p className="title">Select two samples</p>
Expand All @@ -64,7 +64,7 @@ const getSteps: GetSteps = ({
setLockTour(true);
if (node) {
const findCompareBtn = () => {
const compareBtn = document.getElementById('mutated-genes-table-compare-btn');
const compareBtn = document.querySelector('[data-tour="mutated-genes-table-compare-btn"]');
if (compareBtn) {
setGotoStep(3);
document.removeEventListener('click', findCompareBtn);
Expand All @@ -76,7 +76,7 @@ const getSteps: GetSteps = ({
},
// Step 3: Click the “Compare” button
{
selector: '#mutated-genes-table-compare-btn',
selector: '[data-tour="mutated-genes-table-compare-btn"]',
content: () => (
<div className="step">
<p className="title">Click the Compare button</p>
Expand Down Expand Up @@ -108,7 +108,7 @@ const getIntroductionTabsSteps: GetSteps = ({
}) => [
// Step 4: Show the header of the page
{
selector: '#single-study-group-comparison-header',
selector: '[data-tour="single-study-group-comparison-header"]',
content: () => (
<div className="step">
<p className="title">The original study</p>
Expand All @@ -118,7 +118,7 @@ const getIntroductionTabsSteps: GetSteps = ({
},
// Step 5: Show the attribute
{
selector: '#single-study-group-comparison-attribute',
selector: '[data-tour="single-study-group-comparison-attribute"]',
content: () => (
<div className="step">
<p className="title">The attribute</p>
Expand All @@ -128,7 +128,7 @@ const getIntroductionTabsSteps: GetSteps = ({
},
// Step 6: Show the available groups
{
selector: '#single-study-group-comparison-groups',
selector: '[data-tour="single-study-group-comparison-groups"]',
content: () => (
<div className="step">
<p className="title">The available groups</p>
Expand Down Expand Up @@ -168,7 +168,7 @@ const getIntroductionTabsSteps: GetSteps = ({
},
// Step 8: Intro to the Survival tab
{
selector: '#mainColumn',
selector: '[data-tour="mainColumn"]',
content: () => (
<div className="step">
<p className="title">The Survival tab</p>
Expand All @@ -195,7 +195,7 @@ const getIntroductionTabsSteps: GetSteps = ({
},
// Step 9: Intro to the Clinical tab
{
selector: '#mainColumn',
selector: '[data-tour="mainColumn"]',
content: () => (
<div className="step">
<p className="title">The Clinical tab</p>
Expand All @@ -222,7 +222,7 @@ const getIntroductionTabsSteps: GetSteps = ({
},
// Step 10: Intro to the Genomic Alterations tab
{
selector: '#mainColumn',
selector: '[data-tour="mainColumn"]',
content: () => (
<div className="step">
<p className="title">The Genomic Alterations tab</p>
Expand Down
36 changes: 18 additions & 18 deletions src/tours/Steps/VirtualStudy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getSteps: GetSteps = ({
}) => [
// Step 0: Type “glioma” in the search box
{
selector: '#cancer-study-search-box input',
selector: '[data-tour="cancer-study-search-box"] input',
content: () => (
<div className="step">
<p className="title">Search for the studies</p>
Expand All @@ -30,7 +30,7 @@ const getSteps: GetSteps = ({
},
// Step 1: Select two studies
{
selector: '#cancer-study-list-container',
selector: '[data-tour="cancer-study-list-container"]',
content: () => (
<div className="step">
<p className="title">Select two studies</p>
Expand All @@ -47,7 +47,7 @@ const getSteps: GetSteps = ({
},
// Step 2: Click the “Explore Selected Studies” button
{
selector: '#explore-studies-button',
selector: '[data-tour="explore-studies-button"]',
content: () => (
<div className="step">
<p className="title">Click the Explore button</p>
Expand All @@ -63,7 +63,7 @@ const getSteps: GetSteps = ({
},
// Step 3: Click the “+” icon
{
selector: '#show-more-description-icon',
selector: '[data-tour="show-more-description-icon"]',
content: () => (
<div className="step">
<p className="title">See list of studies</p>
Expand All @@ -73,7 +73,7 @@ const getSteps: GetSteps = ({
},
// Step 4: Select samples in the Mutated Genes table
{
selector: '#mutated-genes-table',
selector: '[data-tour="mutated-genes-table"]',
content: () => (
<div className="step">
<p className="title">Select samples</p>
Expand Down Expand Up @@ -104,7 +104,7 @@ const getSteps: GetSteps = ({
},
// Step 6: Click the bookmark icon
{
selector: '#action-button-bookmark',
selector: '[data-tour="action-button-bookmark"]',
content: () => (
<div className="step">
<p className="title">Click the bookmark icon</p>
Expand Down Expand Up @@ -139,7 +139,7 @@ const getNotLoggedInSteps: GetSteps = ({
}) => [
// Step 7: Click on the Share button
{
selector: '#virtual-study-summary-panel',
selector: '[data-tour="virtual-study-summary-panel"]',
content: () => (
<div className="step">
<p className="title">Click on the Share button</p>
Expand All @@ -160,8 +160,8 @@ const getNotLoggedInSteps: GetSteps = ({
action: () => {
// only after user clicked the share button, the tour will continue
setGotoStep(null);
const shareButton = document.getElementById(
'virtual-study-summary-share-btn'
const shareButton = document.querySelector(
'[data-tour="virtual-study-summary-share-btn"]'
);
if (shareButton) {
const handleClick = () => {
Expand All @@ -176,7 +176,7 @@ const getNotLoggedInSteps: GetSteps = ({
},
// Step 8: Show the share link
{
selector: '#virtual-study-summary-panel',
selector: '[data-tour="virtual-study-summary-panel"]',
content: () => (
<div className="step">
<p className="title">Share your virtual study</p>
Expand All @@ -203,7 +203,7 @@ const getNotLoggedInSteps: GetSteps = ({
const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
// Step 7: Click on the Save button
{
selector: '#virtual-study-summary-panel',
selector: '[data-tour="virtual-study-summary-panel"]',
content: () => (
<div className="step">
<p className="title">Click on the Save button</p>
Expand All @@ -223,8 +223,8 @@ const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
action: () => {
// only after user clicked the save button, the tour will continue
setGotoStep(null);
const shareButton = document.getElementById(
'virtual-study-summary-save-btn'
const shareButton = document.querySelector(
'[data-tour="virtual-study-summary-save-btn"]'
);
if (shareButton) {
const handleClick = () => {
Expand All @@ -239,7 +239,7 @@ const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
},
// Step 8: Show the share link
{
selector: '#virtual-study-summary-panel',
selector: '[data-tour="virtual-study-summary-panel"]',
content: () => (
<div className="step">
<p className="title">Already saved</p>
Expand Down Expand Up @@ -273,8 +273,8 @@ const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
// hide the original next step button
setLockTour(true);

const queryButton = document.getElementById(
'virtual-study-summary-query-btn'
const queryButton = document.querySelector(
'[data-tour="virtual-study-summary-query-btn"]'
);
if (queryButton) {
const handleClick = () => {
Expand All @@ -299,7 +299,7 @@ const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
},
// Step 9: In homepage, Show the new virtual study pre-selected
{
selector: '#my_virtual_studies_list',
selector: '[data-tour="my_virtual_studies_list"]',
content: () => (
<div className="step">
<p className="title">My Virtual Studies</p>
Expand All @@ -310,7 +310,7 @@ const getLoggedInSteps: GetSteps = ({ setLockTour, setGotoStep, endTour }) => [
action: () => {
setLockTour(false);
// end the tour if user clicked the screen
const searchBox = document.querySelector("#cancer-study-search-box input");
const searchBox = document.querySelector('[data-tour="cancer-study-search-box"] input');

if (searchBox && (searchBox as any).value !== '') {
searchBox.setAttribute('value', '');
Expand Down

0 comments on commit 6cb6558

Please sign in to comment.