Skip to content

Commit

Permalink
#356: solved active side navbar item issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxue1123 committed Jan 3, 2025
1 parent 8d3c0cf commit e579d2b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabric-portal",
"version": "1.7.3",
"version": "1.8.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.32",
Expand Down
13 changes: 12 additions & 1 deletion src/components/UserProfile/OtherIdentity.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { default as portalData } from "../../services/portalData.json";

class OtherIdentity extends React.Component {
state = {
Expand Down Expand Up @@ -117,7 +118,17 @@ class OtherIdentity extends React.Component {
const { other_identities } = this.props;
return (
<div>
<h5 className="mt-2">Other Identities</h5>
<h5 className="mt-2">
Other Identities
<a
href={portalData.learnArticles.guideToOtherIdentities}
target="_blank"
rel="noreferrer"
>
<i className="fa fa-question-circle mx-2"></i>
User Guide
</a>
</h5>
<div className="form-row ps-1">
<div className="form-group slice-builder-form-group w-25 me-2">
<label htmlFor="inputtype" className="slice-builder-label">
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/SideNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SideNav extends React.Component {
{this.props.items.map((item, index) => {
return (
item.active ?
<Nav.Link href={item.hash} key={`sidenav-${index}`} onClick={() => this.props.handleChange(index)}>{item.name}</Nav.Link> :
<Nav.Link href={item.hash} key={`sidenav-${index}`} onClick={() => this.props.handleChange(index)} className="active">{item.name}</Nav.Link> :
<Nav.Link eventKey={item.hash} key={`sidenav-${index}`} onClick={() => this.props.handleChange(index)}>{item.name}</Nav.Link>
);
})}
Expand Down
10 changes: 9 additions & 1 deletion src/pages/ProjectForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,15 @@ class ProjectForm extends Form {
2: "#slices",
3: "#volumes",
}
this.setState({ activeIndex: newIndex });
this.setState({
activeIndex: newIndex,
SideNavItems: [
{ name: "BASIC INFORMATION", active: newIndex === 0 },
{ name: "PROJECT MEMBERSHIPS", active: newIndex === 1 },
{ name: "SLICES", active: newIndex === 2 },
{ name: "PERSISTENT STORAGE", active: newIndex === 3 }
]
});
this.props.navigate(`/projects/${this.props.match.params.id}${indexToHash[newIndex]}`);
};

Expand Down
23 changes: 19 additions & 4 deletions src/pages/User.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import Col from 'react-bootstrap/Col';
class User extends React.Component {
state = {
SideNavItems: [
{ name: "MY PROFILE", active: true },
{ name: "MY ROLES & PROJECTS", active: false },
{ name: "MY SSH KEYS", active: false },
{ name: "MY SLICES", active: false },
{ name: "MY PROFILE", hash: "#profile", active: true },
{ name: "MY ROLES & PROJECTS", hash: "#roles", active: false },
{ name: "MY SSH KEYS", hash: "#sshKeys", active: false },
{ name: "MY SLICES", hash: "#slices", active: false },
],
user: {},
activeIndex: 0,
Expand All @@ -41,6 +41,21 @@ class User extends React.Component {

handleChange = (newIndex) => {
this.setState({ activeIndex: newIndex });
const indexToHash = {
0: "#profile",
1: "#roles",
2: "#sshKeys",
3: "#slices",
}
this.setState({ activeIndex: newIndex,
SideNavItems: [
{ name: "MY PROFILE", active: newIndex === 0 },
{ name: "MY ROLES & PROJECTS", active: newIndex === 1 },
{ name: "MY SSH KEYS", active: newIndex === 2 },
{ name: "MY SLICES", active: newIndex === 3 }
]
});
this.props.navigate(`/user${indexToHash[newIndex]}`);
};

handleRoleRefresh = async () => {
Expand Down
5 changes: 3 additions & 2 deletions src/services/portalData.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.7.3",
"version": "1.8.0",
"defaultFacility": "FABRIC",
"facilityOptions": ["FABRIC"],
"projectTypeOptions": [
Expand Down Expand Up @@ -94,7 +94,8 @@
"guideToSliceManager": "https://learn.fabric-testbed.net/knowledge-base/fabrictestbed-slice_manager/",
"guideToSliceEditor": "https://learn.fabric-testbed.net/knowledge-base/slice-editor/",
"guideToUseArtifactManager": "https://learn.fabric-testbed.net/knowledge-base/artifact-manager/",
"guideToCommunityList": "https://learn.fabric-testbed.net/knowledge-base/project-science-domain-community-list/"
"guideToCommunityList": "https://learn.fabric-testbed.net/knowledge-base/project-science-domain-community-list/",
"guideToOtherIdentities": "https://learn.fabric-testbed.net/knowledge-base/add-other-identities-in-portal/"
},
"usernameOnImageMapping": {
"default_centos8_stream": "centos",
Expand Down

0 comments on commit e579d2b

Please sign in to comment.