From 340e599caeae3365131fd11b5e09f09a3f70a161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nd=C3=A8ye=20Anna=20Ndiaye?= <anna.ndiaye@savoirfairelinux.com> Date: Wed, 19 Aug 2020 15:45:19 -0400 Subject: [PATCH] Remove back button Change-Id: Ic5ae5aba256f0cef15cdb274ff20e9c8bd638046 --- .../ServerParameters/ServerParameters.js | 2 +- .../src/components/Sidebar/Sidebar.js | 23 +++++++++++-------- jams-react-client/src/layouts/Admin.js | 5 +++- jams-react-client/src/layouts/SignIn.js | 4 ++-- .../src/views/Blueprints/Blueprints.js | 15 ------------ jams-react-client/src/views/Groups/Groups.js | 13 ++--------- .../UserProfile/EditCreateUserProfile.js | 4 ++-- jams-react-client/src/views/Users/Users.js | 8 ------- 8 files changed, 25 insertions(+), 49 deletions(-) diff --git a/jams-react-client/src/components/ServerParameters/ServerParameters.js b/jams-react-client/src/components/ServerParameters/ServerParameters.js index 784fdb88..fdb7ff6c 100644 --- a/jams-react-client/src/components/ServerParameters/ServerParameters.js +++ b/jams-react-client/src/components/ServerParameters/ServerParameters.js @@ -95,7 +95,7 @@ export default function ServerParameters(props) { auth.authenticated = true auth.admin = true auth.checkDirectoryType(() => { - history.push('/admin'); + history.push('/admin/users'); }) } diff --git a/jams-react-client/src/components/Sidebar/Sidebar.js b/jams-react-client/src/components/Sidebar/Sidebar.js index 284f292e..e886d2cd 100755 --- a/jams-react-client/src/components/Sidebar/Sidebar.js +++ b/jams-react-client/src/components/Sidebar/Sidebar.js @@ -31,6 +31,11 @@ export default function Sidebar(props) { const handleCloseProfile = () => { auth.logout(() => { history.push("/") }) }; + + const handleListItemClick = (e, layout, path) => { + e.preventDefault(); + history.push(layout+path.substring(0, 2)) + }; // verifies if routeName is the one active (in browser input) function activeRoute(routeName) { @@ -62,7 +67,7 @@ export default function Sidebar(props) { activeClassName="active" key={key} > - <ListItem button className={classes.itemLink + listItemClasses}> + <ListItem button className={classes.itemLink + listItemClasses} onClick={e => handleListItemClick(e, prop.layout, prop.path)}> {typeof prop.icon === "string" ? ( <Icon className={classNames(classes.itemIcon, whiteFontClasses, { @@ -179,12 +184,12 @@ export default function Sidebar(props) { } Sidebar.propTypes = { - rtlActive: PropTypes.bool, - handleDrawerToggle: PropTypes.func, - bgColor: PropTypes.oneOf(["purple", "blue", "green", "orange", "red"]), - logo: PropTypes.string, - image: PropTypes.string, - logoText: PropTypes.string, - routes: PropTypes.arrayOf(PropTypes.object), - open: PropTypes.bool + rtlActive: PropTypes.bool, + handleDrawerToggle: PropTypes.func, + bgColor: PropTypes.oneOf(["purple", "blue", "green", "orange", "red"]), + logo: PropTypes.string, + image: PropTypes.string, + logoText: PropTypes.string, + routes: PropTypes.arrayOf(PropTypes.object), + open: PropTypes.bool }; diff --git a/jams-react-client/src/layouts/Admin.js b/jams-react-client/src/layouts/Admin.js index f1f29631..29864f97 100644 --- a/jams-react-client/src/layouts/Admin.js +++ b/jams-react-client/src/layouts/Admin.js @@ -34,7 +34,10 @@ const switchRoutes = ( } return null; })} - <Redirect from="/admin" to="/admin/users" /> + <Redirect from="/admin/u" to="/admin/users" /> + <Redirect from="/admin/g" to="/admin/groups" /> + <Redirect from="/admin/b" to="/admin/blueprints" /> + </Switch> ); diff --git a/jams-react-client/src/layouts/SignIn.js b/jams-react-client/src/layouts/SignIn.js index 74af2aaf..d2b00a44 100644 --- a/jams-react-client/src/layouts/SignIn.js +++ b/jams-react-client/src/layouts/SignIn.js @@ -77,7 +77,7 @@ export default function SignIn(props) { React.useEffect(() => { if(auth.isAuthenticated() && auth.isInstalled()) { - history.push('/admin'); + history.push('/admin/users'); } }) @@ -91,7 +91,7 @@ export default function SignIn(props) { auth.checkLastKnowStep(() => { auth.checkDirectoryType(() => { if(auth.isInstalled){ - history.push('/admin'); + history.push('/admin/users'); } else{ history.push('/'); diff --git a/jams-react-client/src/views/Blueprints/Blueprints.js b/jams-react-client/src/views/Blueprints/Blueprints.js index 19911555..3b141f85 100644 --- a/jams-react-client/src/views/Blueprints/Blueprints.js +++ b/jams-react-client/src/views/Blueprints/Blueprints.js @@ -131,11 +131,6 @@ export default function Blueprints() { setSelectedBlueprint(true) setSelectedBlueprintName(blueprintNameRedirect) } - function redirectToBlueprints(e) { - e.preventDefault() - setSelectedBlueprint(false); - history.push('/admin/blueprints') - } const handleCheckBlueprintNameExists = (searchBlueprintNameValue) => { axios(configApiCall(api_path_blueprints+"?name="+searchBlueprintNameValue, 'GET', null, null)).then((response)=>{ @@ -185,16 +180,6 @@ export default function Blueprints() { <h4>You are not allowed to access this section. Please contact your administrator to get administrator privileges.</h4> </div> ) - } else if(selectedBlueprint && auth.hasAdminScope()){ - return ( - <div> - <Button variant="contained" color="info" href="#contained-buttons" onClick={redirectToBlueprints} style={{color: "white"}}> - <KeyboardReturnIcon /> return to blueprints - </Button> - <h3>{selectedBlueprintName}</h3> - <Blueprint blueprintName={selectedBlueprintName}/> - </div> - ) } else { return ( diff --git a/jams-react-client/src/views/Groups/Groups.js b/jams-react-client/src/views/Groups/Groups.js index 6c2abb48..eb7d071f 100644 --- a/jams-react-client/src/views/Groups/Groups.js +++ b/jams-react-client/src/views/Groups/Groups.js @@ -160,12 +160,6 @@ export default function Groups() { setSelectedGroupName(name) } - const redirectToGroupList = (e) => { - e.preventDefault() - setSelectedGroup(false); - history.push('/admin/groups') - } - const handleCheckGroupNameExists = (searchGroupNameValue) => { axios(configApiCall(api_path_get_list_group+"?groupName="+searchGroupNameValue, 'GET', null, null)).then((response)=>{ if(response.data === "[]"){ @@ -220,12 +214,9 @@ export default function Groups() { if(selectedGroup && auth.hasAdminScope()){ return( <div> - <Button variant="contained" color="info" href="#contained-buttons" onClick={redirectToGroupList}> - <KeyboardReturnIcon /> - </Button> <EditGroup - groupName={selectedGroupName} - initCheckGroupNameExists={initCheckGroupNameExists} + groupName={selectedGroupName} + initCheckGroupNameExists={initCheckGroupNameExists} groupNameExits={groupNameExits} blueprintsOptionsItems={blueprintsOptionsItems} selectedBlueprint={selectedBlueprint} diff --git a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js index 8fcdcac9..e0110f43 100644 --- a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js +++ b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js @@ -183,7 +183,7 @@ export default function EditCreateUserProfile(props) { } const handleCancel = () => { - history.push('/admin'); + history.push('/admin/users'); } const handleCancelUpdate = () => { @@ -291,7 +291,7 @@ export default function EditCreateUserProfile(props) { const handleClosePassword = () => { setOpenPassword(false); - history.push('/admin'); + history.push('/admin/users'); } /** diff --git a/jams-react-client/src/views/Users/Users.js b/jams-react-client/src/views/Users/Users.js index 9ee6b083..894c3787 100644 --- a/jams-react-client/src/views/Users/Users.js +++ b/jams-react-client/src/views/Users/Users.js @@ -115,11 +115,6 @@ export default function Users() { setSelectedProfile(true); setSelectedUsername(username) } - const redirectToUsers = (e) => { - e.preventDefault() - setSelectedProfile(false); - history.push('/admin') - } const searchUsers = (value) => { axios(configApiCall(api_path_get_user_directory_search, 'GET', {"queryString": value ? value : "*"}, null)).then((response)=>{ @@ -151,9 +146,6 @@ export default function Users() { } else if(selectedProfile && auth.hasAdminScope()){ return ( <div> - <Button variant="contained" color="info" href="#contained-buttons" onClick={redirectToUsers}> - <KeyboardReturnIcon /> - </Button> <UserProfile username={selectedUsername}/> </div> ) -- GitLab