diff --git a/Accounts/src/Utils/Login.ts b/Accounts/src/Utils/Login.ts index 26e0b101bd..3c94217fff 100644 --- a/Accounts/src/Utils/Login.ts +++ b/Accounts/src/Utils/Login.ts @@ -22,6 +22,7 @@ export default abstract class LoginUtil { UserUtil.setEmail(user.email as Email); UserUtil.setUserId(user.id as ObjectID); UserUtil.setName(user.name as Name); + UserUtil.setIsMasterAdmin(user.isMasterAdmin as boolean); Analytics.userAuth(user.email!); diff --git a/AdminDashboard/src/App.tsx b/AdminDashboard/src/App.tsx index 8183eccec9..9291d34a4f 100644 --- a/AdminDashboard/src/App.tsx +++ b/AdminDashboard/src/App.tsx @@ -9,7 +9,7 @@ import { import Navigation from 'CommonUI/src/Utils/Navigation'; import User from 'CommonUI/src/Utils/User'; import URL from 'Common/Types/API/URL'; -import { ACCOUNTS_URL } from 'CommonUI/src/Config'; +import { ACCOUNTS_URL, DASHBOARD_URL } from 'CommonUI/src/Config'; import MasterPage from './Components/MasterPage/MasterPage'; import RouteMap from './Utils/RouteMap'; import PageMap from './Utils/PageMap'; @@ -32,6 +32,10 @@ const App: () => JSX.Element = () => { Navigation.navigate(URL.fromString(ACCOUNTS_URL.toString())); } } + + if(!User.isMasterAdmin()){ + Navigation.navigate(URL.fromString(DASHBOARD_URL.toString())) + } return ( diff --git a/AdminDashboard/src/Components/NavBar/NavBar.tsx b/AdminDashboard/src/Components/NavBar/NavBar.tsx index fe7cd9b2a1..ac0e960bd1 100644 --- a/AdminDashboard/src/Components/NavBar/NavBar.tsx +++ b/AdminDashboard/src/Components/NavBar/NavBar.tsx @@ -11,13 +11,33 @@ const DashboardNavbar: FunctionComponent = (): ReactElement => { return ( + + + + + + + + ); }; diff --git a/AdminDashboard/src/Utils/PageMap.ts b/AdminDashboard/src/Utils/PageMap.ts index 797892b88f..4a1674415c 100644 --- a/AdminDashboard/src/Utils/PageMap.ts +++ b/AdminDashboard/src/Utils/PageMap.ts @@ -1,7 +1,11 @@ enum PageMap { INIT = 'INIT', HOME = 'HOME', - LOGOUT = 'LOGOUT' + LOGOUT = 'LOGOUT', + SETTINGS = 'SETTINGS', + USERS = 'USERS', + PROJECTS = 'PROJECTS', + } export default PageMap; diff --git a/AdminDashboard/src/Utils/RouteMap.ts b/AdminDashboard/src/Utils/RouteMap.ts index 27e2207320..fce1263997 100644 --- a/AdminDashboard/src/Utils/RouteMap.ts +++ b/AdminDashboard/src/Utils/RouteMap.ts @@ -5,9 +5,12 @@ import RouteParams from './RouteParams'; import ObjectID from 'Common/Types/ObjectID'; const RouteMap: Dictionary = { - [PageMap.INIT]: new Route(`/admin-dashboard`), - [PageMap.HOME]: new Route(`/admin-dashboard`), - [PageMap.LOGOUT]: new Route(`/admin-dashboard/logout`) + [PageMap.INIT]: new Route(`/admin`), + [PageMap.HOME]: new Route(`/admin`), + [PageMap.LOGOUT]: new Route(`/admin/logout`), + [PageMap.SETTINGS]: new Route(`/admin/settings`), + [PageMap.PROJECTS]: new Route(`/admin/projects`), + [PageMap.USERS]: new Route(`/admin/users`), }; export class RouteUtil { diff --git a/CommonServer/Config.ts b/CommonServer/Config.ts index 286393d1f4..32bd52dca3 100644 --- a/CommonServer/Config.ts +++ b/CommonServer/Config.ts @@ -184,7 +184,7 @@ export const ApiReferenceRoute: Route = new Route( ); export const AdminDashboardRoute: Route = new Route( - process.env['ADMINDASHBOARD_ROUTE'] || '/admin-dashboard' + process.env['ADMIN_DASHBOARD_ROUTE'] || '/admin-dashboard' ); export const IsProduction: boolean = diff --git a/CommonUI/src/Components/TopAlert/TopAlert.tsx b/CommonUI/src/Components/TopAlert/TopAlert.tsx index 60160294df..4bc5b76c1f 100644 --- a/CommonUI/src/Components/TopAlert/TopAlert.tsx +++ b/CommonUI/src/Components/TopAlert/TopAlert.tsx @@ -14,7 +14,13 @@ const TopAlert: FunctionComponent = (

{props.title} -  - {props.description} + {props.description}    + + Go to User Dashboard +

diff --git a/CommonUI/src/Config.ts b/CommonUI/src/Config.ts index eb7912f17f..a880427c89 100644 --- a/CommonUI/src/Config.ts +++ b/CommonUI/src/Config.ts @@ -47,7 +47,7 @@ export const HELM_ROUTE: Route = new Route(env('HELMCHART_ROUTE')); export const API_DOCS_ROUTE: Route = new Route(env('API_REFERENCE_ROUTE')); export const ADMIN_DASHBOARD_ROUTE: Route = new Route( - env('ADMINDASHBOARD_ROUTE') + env('ADMIN_DASHBOARD_ROUTE') ); export const ACCOUNTS_ROUTE: Route = new Route(env('ACCOUNTS_ROUTE')); export const HOME_ROUTE: Route = new Route(env('HOME_ROUTE')); diff --git a/CommonUI/src/Utils/User.ts b/CommonUI/src/Utils/User.ts index 26557ea925..67afabfe1f 100644 --- a/CommonUI/src/Utils/User.ts +++ b/CommonUI/src/Utils/User.ts @@ -118,6 +118,14 @@ export default class User { return sessionStorage.removeItem('initialUrl'); } + public static isMasterAdmin(): boolean { + return LocalStorage.getItem('is_master_admin') as boolean; + } + + public static setIsMasterAdmin(isMasterAdmin: boolean): void { + LocalStorage.setItem('is_master_admin', isMasterAdmin); + } + public static isLoggedIn(): boolean { return LocalStorage.getItem('access_token') ? true : false; } diff --git a/Dashboard/src/Components/Header/UserProfile.tsx b/Dashboard/src/Components/Header/UserProfile.tsx index 9c01d05638..a3e9e41697 100644 --- a/Dashboard/src/Components/Header/UserProfile.tsx +++ b/Dashboard/src/Components/Header/UserProfile.tsx @@ -7,6 +7,9 @@ import BlankProfilePic from 'CommonUI/src/Images/users/blank-profile.svg'; import HeaderIconDropdownButton from 'CommonUI/src/Components/Header/HeaderIconDropdownButton'; import IconDropdownItem from 'CommonUI/src/Components/Header/IconDropdown/IconDropdownItem'; import IconDropdownMenu from 'CommonUI/src/Components/Header/IconDropdown/IconDropdownMenu'; +import Navigation from 'CommonUI/src/Utils/Navigation'; +import { ADMIN_DASHBOARD_URL } from 'CommonUI/src/Config'; +import User from 'CommonUI/src/Utils/User'; export interface ComponentProps { onClickUserProfile: () => void; @@ -37,6 +40,15 @@ const DashboardUserProfile: FunctionComponent = ( icon={IconProp.User} /> + {User.isMasterAdmin() ? { + setIsDropdownVisible(false); + Navigation.navigate(ADMIN_DASHBOARD_URL); + }} + icon={IconProp.Settings} + /> : <>} + { diff --git a/config.example.env b/config.example.env index 951b3bba08..4e7b0230a5 100644 --- a/config.example.env +++ b/config.example.env @@ -109,7 +109,7 @@ REALTIME_ROUTE=/realtime API_DOCS_ROUTE=/reference NOTIFICATION_ROUTE=/notification DASHBOARD_ROUTE=/dashboard -ADMIN_DASHBOARD_ROUTE=/admin-dashboard +ADMIN_DASHBOARD_ROUTE=/admin DASHBOARD_API_ROUTE=/api WORKFLOW_ROUTE=/workflow LINK_SHORTENER_ROUTE=/l