Skip to content

Commit ba32b4c

Browse files
committed
Left Nav title customization changes
Removed empty pages
1 parent 5b3cc48 commit ba32b4c

20 files changed

Lines changed: 112 additions & 112 deletions

gatsby-node.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const frontmatter = require('@github-docs/frontmatter');
55
const { v4: uuidv4 } = require('uuid');
66
const { createFilePath } = require('gatsby-source-filesystem');
77
const redirects = require('./src/redirects.json');
8+
const leftNavTitle = require('./src/left-nav-title.json');
89

910
const ignorePaths = [];
1011

@@ -131,7 +132,19 @@ exports.sourceNodes = async ({
131132

132133
let current = output;
133134
split.forEach((part) => {
134-
current[part] = current[part] || {};
135+
if(current[part])
136+
current[part] = current[part];
137+
else {
138+
current[part] = {};
139+
if(leftNavTitle[part]) {
140+
Object.keys(leftNavTitle[part]).forEach(key => {
141+
if(val.indexOf(key) === 0) {
142+
//console.log(key);
143+
current[part] = {leftNavTitle: leftNavTitle[part][key]};
144+
}
145+
})
146+
}
147+
}
135148
current = current[part];
136149
});
137150
current.url = `/${split.join('/')}/`;

src/components/LeftNav.jsx

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import { useStaticQuery, graphql, Link } from 'gatsby';
55
import React from 'react';
66
import './LeftNav.scss';
77
import book from './images/book.png';
8-
import web from './images/box.svg' ;
9-
import android from './images/android.svg';
10-
import ios from './images/ios.svg';
11-
import mobile from './images/mobile_line.svg';
12-
13-
// import { caret } from './caret.svg';
148

159

1610
const { v4: uuidv4 } = require('uuid');
@@ -46,7 +40,7 @@ class ListItem extends React.Component {
4640
let title;
4741
if (e.target.attributes.identifier) {
4842
title = e.target.attributes.identifier.value;
49-
} else {
43+
} else if (e.target.nextSibling.attributes.identifier) {
5044
title = e.target.nextSibling.attributes.identifier.value;
5145
}
5246
const { active } = this.state;
@@ -68,22 +62,15 @@ class ListItem extends React.Component {
6862
const { currentUrl } = this.state;
6963
return currentUrl.includes(url);
7064
}
71-
// bool to return whether current list item appears in the url
72-
handleLoginClick() {
73-
this.setState({isLoggedIn: true});
74-
}
7565

76-
handleLogoutClick() {
77-
this.setState({isLoggedIn: false});
78-
}
79-
child = (url) => {
66+
child = (data, url) => {
8067
const name = slugs.filter((val) => url === val.fields.slug);
8168
const { title } = name[0].frontmatter;
82-
return (
83-
<li key={`${title}-${uuidv4()}`} className={`child${this.inUrl(url) ? ' currentUrl text_green' : ''}`}>
69+
return ( url.indexOf("/overview/") === -1 &&
70+
<li key={`${data.leftNavTitle || title}-${uuidv4()}`} className={`child${this.inUrl(url) ? ' currentUrl text_green' : ''}`}>
8471
<div className="activeIndicator" />
8572
<img src={book} alt="book"/>
86-
<Link to={url}>{title}</Link>
73+
<Link to={url}>{data.leftNavTitle || title}</Link>
8774
</li>
8875
);
8976
} // Renders child element. Gets name from slugs array
@@ -93,35 +80,41 @@ class ListItem extends React.Component {
9380
if (this.inUrl(`/${name}/`)) {
9481
this.setActive(name);
9582
}
83+
// Appending overview page link to Parent node (which has arrow icon with title)
84+
// Instead of having overview as a separate link.
85+
let overviewLink = null;
86+
Object.keys(data).map(key => {
87+
if (data.hasOwnProperty('overview')) {
88+
if (data['overview'].url.indexOf(`/${name}/overview/`) !== -1)
89+
overviewLink = data['overview'].url;
90+
}
91+
else if (data[key].hasOwnProperty('overview')) {
92+
if (data[key]['overview'].url.indexOf(`/${name}/overview/`) !== -1)
93+
overviewLink = data[key]['overview'].url;
94+
}
95+
})
9696

9797
return (
9898
<ul
9999
key={`${name}-${uuidv4()}`}
100-
className={`
101-
${(active.indexOf(name) !== -1) ? 'active' : 'inactive'}
102-
${isRoot ? ' root' : ''}
103-
`}
100+
className={` ${(active.indexOf(name) !== -1) ? 'active' : 'inactive'} ${isRoot ? ' root' : ''} `}
104101
>
105102
<li className={`parent${this.inUrl(`/${name}/`) ? ' currentUrl text_green' : ''}`} onClick={this.toggleActive} identifier={name}>
106-
<button type="button" onClick={this.toggleActive} identifier={name}>
107-
{name.replace(/-/g, ' ')}
108-
</button>
109-
{/*<svg className='inline float-right top-2 relative folder-icon' width="13" height="8" viewBox="0 0 13 8" fill="none" xmlns="http://www.w3.org/2000/svg">*/}
110-
{/* <path d="M12.5253 1.5H1.09298C0.882619 1.5 0.711915 1.16397 0.711915 0.75C0.711915 0.335973 0.88265 0 1.09298 0H12.5253C12.7356 0 12.9063 0.336035 12.9063 0.75C12.9063 1.16397 12.7356 1.5 12.5253 1.5Z" fill="#183E46"/>*/}
111-
{/* <path d="M12.5253 4.5H1.09298C0.882619 4.5 0.711915 4.16397 0.711915 3.75C0.711915 3.33597 0.88265 3 1.09298 3H12.5253C12.7356 3 12.9063 3.33604 12.9063 3.75C12.9063 4.16397 12.7356 4.5 12.5253 4.5Z" fill="#183E46"/>*/}
112-
{/* <path d="M1.09301 6H8.71452C8.92488 6 9.09558 6.33603 9.09558 6.75C9.09558 7.16403 8.92485 7.5 8.71452 7.5H1.09301C0.882645 7.5 0.711941 7.16397 0.711941 6.75C0.711909 6.33597 0.882645 6 1.09301 6Z" fill="#183E46"/>*/}
113-
{/*</svg>*/}
114103
<svg onClick={this.toggleActive} identifier={name} className={`inline float_left relative folder-icon parent_caret${this.isActive(name) ? ' active_parent_caret' : ''}`} xmlns="http://www.w3.org/2000/svg" fill="none" height="24"
115104
viewBox="0 0 24 24" width="24">
116-
<path clip-rule="evenodd"
105+
<path clipRule="evenodd"
117106
d="m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z"
118-
fill="#333333" fill-rule="evenodd">
107+
fill="#333333" fillRule="evenodd">
119108

120109
</path>
121110
</svg>
122111
<svg onClick={this.toggleActive} identifier={name} className={`-mr-3 inline caret${this.isActive(name) ? ' active-caret' : ''}`} xmlns="http://www.w3.org/2000/svg" fill="none" height="24" viewBox="0 0 24 24" width="24"><path clipRule="evenodd" d="m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z" fill="#333333" fillRule="evenodd" /></svg>
112+
{ overviewLink && (<Link to={overviewLink} onClick={this.toggleActive} identifier={name}>{ data.leftNavTitle || name.replace(/-/g, ' ')} </Link>) }
113+
{ !overviewLink && (<button type="button" onClick={this.toggleActive} identifier={name}>
114+
{data.leftNavTitle || name.replace(/-/g, ' ')}
115+
</button>)}
123116
</li>
124-
<ListItem data={JSON.stringify(data)} />
117+
<ListItem data={JSON.stringify(data)} identifier={name}/>
125118
</ul>
126119
);
127120
} // renders parent element that has children
@@ -130,15 +123,15 @@ class ListItem extends React.Component {
130123
const { data } = this.state;
131124
const parsedData = JSON.parse(data);
132125
const keys = Object.keys(JSON.parse(data)).map((val) => val);
133-
134126
return (
135127
<>
136-
137128
{keys.map((val) => {
138-
if (parsedData[val].url) {
139-
return this.child(parsedData[val].url);
129+
if(val !== 'leftNavTitle' && val !== "old") {
130+
if (parsedData[val].url) {
131+
return this.child(parsedData[val], parsedData[val].url);
132+
}
133+
return this.parent(parsedData[val], val);
140134
}
141-
return this.parent(parsedData[val], val);
142135
})}
143136
</>
144137
);
@@ -164,13 +157,12 @@ const LeftNav = () => {
164157
}
165158
}`);
166159
slugs = data.allMarkdownRemark.nodes;
167-
168160
return (
169161
<>
170-
<div className="leftNav bg-gray-50 px-14 pt-5">
171-
<ListItem data={data.leftNavLinks.value} isRoot />
172-
</div>
173-
</>
162+
<div className="leftNav bg-gray-50 px-14 pt-5">
163+
<ListItem data={data.leftNavLinks.value} isRoot />
164+
</div>
165+
</>
174166
);
175167
};
176168

src/left-nav-title.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"automate-mobile-web-applications": {
3+
"/tutorials/getting-started/automate-mobile-web-applications": "Get Started with Automating Mobile Web Applications"
4+
},
5+
"automate-android-applications": {
6+
"/tutorials/getting-started/automate-android-applications/": "Get Started with Automating Android Apps "
7+
},
8+
"automate-rest-apis": {
9+
"/tutorials/getting-started/automate-rest-apis": "Get Started with REST API Testing"
10+
},
11+
"build-tests-using-recorder": {
12+
"/tutorials/test-cases/web-apps/build-tests-using-recorder/": "How to create web application tests using Test Recorder",
13+
"/tutorials/test-cases/mobile-apps/build-tests-using-recorder/": "How to create Android & iOS app tests using Test Recorder"
14+
},
15+
"build-tests-using-local-android-devices": {
16+
"/tutorials/test-cases/mobile-apps/build-tests-using-local-android-devices/" : "How to automate Android app tests using local devices"
17+
},
18+
"build-tests-using-local-ios-devices" : {
19+
"/tutorials/test-cases/mobile-apps/build-tests-using-local-ios-devices/": "How to automate iOS app tests using local devices"
20+
},
21+
"data-driven-testing": {
22+
"/tutorials/test-cases/data-driven-testing/": "How to automate data driven testing"
23+
},
24+
"what-is-jsonpath": {
25+
"/tutorials/rest-api-testing/what-is-jsonpath/": "What is JSONPath and How to query JSON using JSONPath"
26+
},
27+
"using-local-devices": {
28+
"/tutorials/test-plans/using-local-devices/": "How to create test plans to run on your local devices"
29+
},
30+
"how-to-setup-agents-to-run-tests-on-local-mobile-devices": {
31+
"/tutorials/agent/how-to-setup-agents-to-run-tests-on-local-mobile-devices/": "How to setup Agents to run tests on your local Mobile devices"
32+
},
33+
"rest-api-testing": {
34+
"/tutorials/rest-api-testing/": "REST API"
35+
},
36+
"agent": {
37+
"/tutorials/agent/": "Testsigma Agent"
38+
},
39+
"how-create-addons-actions": {
40+
"/tutorials/addons/how-create-addons-actions/": "How to create Addons for automated actions"
41+
},
42+
"how-create-addons-test-data-generators": {
43+
"/tutorials/addons/how-create-addons-test-data-generators/": "How to create a test data generator in Addons"
44+
},
45+
"how-create-addons-conditional-if": {
46+
"/tutorials/addons/how-create-addons-conditional-if/": "How to create a Conditonal IF action in Addons"
47+
},
48+
"how-create-addons-while-loops": {
49+
"/tutorials/addons/how-create-addons-while-loops/": "How to create a While action in Addons"
50+
}
51+
}

src/pages/tutorials/addons/actions-assertions.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/pages/tutorials/addons/handling-dynamic-xpaths.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/pages/tutorials/addons/how-create-addons-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "How to create addon for actions"
3-
order: 4.1
3+
order: 6.1
44
page_id: "How to create addon for actions"
55
search_keyword: "Addons, Testsigma Tutorials"
66
warning: false

src/pages/tutorials/addons/how-create-addons-conditional-if.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "How to add condition if actions"
3-
order: 4.3
3+
order: 6.3
44
page_id: "How to add condition if actions"
55
search_keyword: "Addons, Conditional if, Testsigma Tutorials"
66
warning: false

src/pages/tutorials/addons/how-create-addons-test-data-generators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Create Test data generators in Addons"
3-
order: 4.2
3+
order: 6.2
44
page_id: "Create Test data generators in Addons"
55
search_keyword: "Addons, Data Generators, Testsigma Tutorials"
66
warning: false

src/pages/tutorials/addons/how-create-addons-while-loops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "How to add While actions "
3-
order: 4.4
3+
order: 6.4
44
page_id: "How to add While actions "
55
search_keyword: "Addons, While Actions, Testsigma Tutorials"
66
warning: false

src/pages/tutorials/addons/how-test-actions-on-local.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)