From 456c67e409833b63cda8c272e90819ed03528d0b Mon Sep 17 00:00:00 2001 From: Arkajyoti Mukherjee <32966391+arkajyotiMukherjee@users.noreply.github.com> Date: Thu, 10 Sep 2020 22:40:31 +0530 Subject: [PATCH] chore: (litmus-portal) Final build bug fixes, refactoring and imporvements (#2029) - refactored directory structure for frontend - browse workflow table fixes and header notification fixes - settings and project selection fixes - project switching fixes, routing changes for settings and disabling buttons for release - routes and breadcrumbs fixed - tab switching improved with redux Signed-off-by: arkajyotiMukherjee --- .../component/LinearProgressBar.spec.tsx | 4 +- .../cypress/component/passedVsFailed.spec.tsx | 5 +- .../semiCircularProgressBar.spec.tsx | 4 +- .../cypress/component/weightSlider.spec.tsx | 2 +- .../src/components/AdjustedWeights/index.tsx | 6 +- .../src/components/BreadCrumbs/index.tsx | 27 +++--- .../Header/NotificationDropdown.tsx | 21 ++--- .../Header/NotificationListItem.tsx | 20 ++--- .../Header/ProfileDropdownItems.tsx | 48 +++++----- .../Header/ProfileDropdownSection.tsx | 4 +- .../Header/ProjectListItem.tsx | 4 +- .../layouts => components}/Header/index.tsx | 21 ++--- .../layouts => components}/Header/styles.ts | 0 .../src/components/QuickActionCard/index.tsx | 75 +++++++++------- .../layouts => components}/SideBar/index.tsx | 32 ++++--- .../layouts => components}/SideBar/styles.ts | 0 .../src/components/WorkflowStepper/index.tsx | 12 +-- .../frontend/src/containers/app/App.tsx | 33 ++++--- .../src/containers/layouts/Scaffold/index.tsx | 10 +-- .../frontend/src/models/graphql/invite.ts | 7 ++ .../frontend/src/models/redux/tabs.ts | 18 ++++ .../frontend/src/pages/Community/index.tsx | 18 ++-- .../frontend/src/pages/HomePage/index.tsx | 20 +++-- .../frontend/src/pages/Settings/index.tsx | 89 +++++++++++-------- .../src/pages/WorkflowDetails/index.tsx | 6 +- .../frontend/src/pages/Workflows/index.tsx | 40 ++++++--- .../frontend/src/redux/actions/tabs.ts | 15 ++++ .../frontend/src/redux/reducers/index.ts | 4 + .../frontend/src/redux/reducers/tabs.ts | 25 ++++++ .../BrowseSchedule/TableData.tsx | 8 +- .../ChaosWorkflows/BrowseSchedule/index.tsx | 14 +-- .../ChaosWorkflows/BrowseSchedule/styles.ts | 1 + .../BrowseTemplate/ExperimentDetails.tsx | 4 +- .../ChaosWorkflows/BrowseTemplate/Head.tsx | 4 +- .../BrowseTemplate/Recommendation.tsx | 0 .../ChaosWorkflows/BrowseTemplate/index.tsx | 12 +-- .../ChaosWorkflows/BrowseTemplate/styles.ts | 0 .../BrowseWorkflow/HeaderSection.tsx | 30 +++---- .../BrowseWorkflow/TableData.tsx | 14 +-- .../ChaosWorkflows/BrowseWorkflow/index.tsx | 10 +-- .../ChaosWorkflows/BrowseWorkflow/styles.ts | 1 + .../ChaosWorkflows/CustomStatus/Status.tsx | 0 .../ChaosWorkflows/CustomStatus/styles.ts | 0 .../ChaosWorkflows/Templates/index.tsx | 10 +-- .../ChaosWorkflows/Templates/styles.ts | 0 .../CommunityTimeSeriesPlot/index.tsx | 8 +- .../CommunityTimeSeriesPlot/styles.ts | 0 .../Community/GeoMap/CityMap.tsx | 2 +- .../Community/GeoMap/CountryMap.tsx | 2 +- .../Community/GeoMap/geo.json | 0 .../Community/GeoMap/index.tsx | 2 +- .../CreateWorkflow/ChooseWorkflow/index.tsx | 16 ++-- .../CreateWorkflow/ChooseWorkflow/styles.ts | 0 .../ReliabilityScore/ResultTable.tsx | 4 +- .../CreateWorkflow/ReliabilityScore/index.tsx | 22 ++--- .../CreateWorkflow/ReliabilityScore/styles.ts | 0 .../ScheduleWorkflow/SetTime/index.tsx | 0 .../ScheduleWorkflow/SetTime/styles.ts | 0 .../CreateWorkflow/ScheduleWorkflow/index.tsx | 4 +- .../CreateWorkflow/ScheduleWorkflow/styles.ts | 0 .../CreateWorkflow/ToggleComponent/index.tsx | 0 .../CreateWorkflow/ToggleComponent/styles.ts | 0 .../CreateWorkflow/TuneWorkflow/index.tsx | 12 +-- .../CreateWorkflow/TuneWorkflow/styles.ts | 0 .../CreateWorkflow/VerifyCommit/index.tsx | 26 +++--- .../CreateWorkflow/VerifyCommit/styles.ts | 0 .../CreateWorkflow/WeightSlider/index.tsx | 0 .../CreateWorkflow/WeightSlider/styles.ts | 0 .../CreateWorkflow/WorkflowCluster/index.tsx | 14 +-- .../CreateWorkflow/WorkflowCluster/styles.ts | 0 .../ReturningHome/PassedVsFailed/index.tsx | 0 .../ReturningHome/PassedVsFailed/styles.ts | 0 .../ProgressBar/LinearProgressBar/index.tsx | 0 .../SemiCircularProgressBar/index.tsx | 0 .../SemiCircularProgressBar/styles.ts | 0 .../ReturningHome/TotalExperiments/index.tsx | 0 .../ReturningHome/TotalExperiments/styles.ts | 0 .../AccountsTab/AccountSettings/index.tsx | 6 +- .../AccountsTab/AccountSettings/styles.ts | 0 .../AccountsTab/PersonalDetails/index.tsx | 8 +- .../AccountsTab/PersonalDetails/styles.ts | 0 .../Invitation/ReceivedInvitations/index.tsx | 30 +++---- .../Invitation/ReceivedInvitations/styles.ts | 0 .../Invitation/SentInvitations/index.tsx | 16 ++-- .../Invitation/SentInvitations/styles.ts | 0 .../Settings/TeammingTab/Invitation/index.tsx | 4 +- .../Settings/TeammingTab/Invitation/styles.ts | 0 .../InviteNew/Invite/TableData.tsx | 7 +- .../TeammingTab/InviteNew/Invite/index.tsx | 22 ++--- .../TeammingTab/InviteNew/Invite/styles.ts | 0 .../Settings/TeammingTab/InviteNew/index.tsx | 4 +- .../Settings/TeammingTab/InviteNew/styles.ts | 0 .../Settings/TeammingTab/index.tsx | 14 +-- .../Settings/TeammingTab/styles.ts | 0 .../CreateUser/NewUserModal/index.tsx | 8 +- .../CreateUser/NewUserModal/styles.ts | 0 .../CreateUser/UserDetails/index.tsx | 6 +- .../CreateUser/UserDetails/styles.ts | 0 .../UserManagementTab/CreateUser/index.tsx | 4 +- .../UserManagementTab/CreateUser/styles.ts | 0 .../EditUser/DelUser/index.tsx | 14 +-- .../EditUser/DelUser/styles.ts | 0 .../EditUser/ResetModal/index.tsx | 8 +- .../EditUser/ResetModal/styles.ts | 0 .../UserManagementTab/EditUser/index.tsx | 4 +- .../UserManagementTab/EditUser/styles.ts | 0 .../UserManagement/index.tsx | 10 +-- .../UserManagement/styles.ts | 0 .../WorkflowDetails/ArgoWorkflow/index.tsx | 8 +- .../WorkflowDetails/ArgoWorkflow/styles.ts | 0 .../WorkflowDetails/WorkflowInfo/index.tsx | 6 +- .../WorkflowDetails/WorkflowInfo/styles.ts | 0 112 files changed, 531 insertions(+), 438 deletions(-) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/NotificationDropdown.tsx (94%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/NotificationListItem.tsx (97%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/ProfileDropdownItems.tsx (85%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/ProfileDropdownSection.tsx (96%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/ProjectListItem.tsx (95%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/index.tsx (92%) rename litmus-portal/frontend/src/{containers/layouts => components}/Header/styles.ts (100%) rename litmus-portal/frontend/src/{containers/layouts => components}/SideBar/index.tsx (79%) rename litmus-portal/frontend/src/{containers/layouts => components}/SideBar/styles.ts (100%) create mode 100644 litmus-portal/frontend/src/models/redux/tabs.ts create mode 100644 litmus-portal/frontend/src/redux/actions/tabs.ts create mode 100644 litmus-portal/frontend/src/redux/reducers/tabs.ts rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseSchedule/TableData.tsx (95%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseSchedule/index.tsx (96%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseSchedule/styles.ts (99%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseTemplate/ExperimentDetails.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseTemplate/Head.tsx (95%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseTemplate/Recommendation.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseTemplate/index.tsx (83%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseTemplate/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseWorkflow/HeaderSection.tsx (97%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseWorkflow/TableData.tsx (89%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseWorkflow/index.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/BrowseWorkflow/styles.ts (99%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/CustomStatus/Status.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/CustomStatus/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/Templates/index.tsx (84%) rename litmus-portal/frontend/src/{components/Sections => views}/ChaosWorkflows/Templates/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/CommunityTimeSeriesPlot/index.tsx (99%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/CommunityTimeSeriesPlot/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/GeoMap/CityMap.tsx (97%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/GeoMap/CountryMap.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/GeoMap/geo.json (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Community/GeoMap/index.tsx (88%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ChooseWorkflow/index.tsx (92%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ChooseWorkflow/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ReliabilityScore/ResultTable.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ReliabilityScore/index.tsx (86%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ReliabilityScore/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ScheduleWorkflow/SetTime/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ScheduleWorkflow/SetTime/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ScheduleWorkflow/index.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ScheduleWorkflow/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ToggleComponent/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/ToggleComponent/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/TuneWorkflow/index.tsx (87%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/TuneWorkflow/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/VerifyCommit/index.tsx (90%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/VerifyCommit/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/WeightSlider/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/WeightSlider/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/WorkflowCluster/index.tsx (92%) rename litmus-portal/frontend/src/{components/Sections => views}/CreateWorkflow/WorkflowCluster/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/PassedVsFailed/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/PassedVsFailed/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/ProgressBar/LinearProgressBar/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/ProgressBar/SemiCircularProgressBar/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/ProgressBar/SemiCircularProgressBar/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/TotalExperiments/index.tsx (100%) rename litmus-portal/frontend/src/{components/Sections => views}/ReturningHome/TotalExperiments/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/AccountsTab/AccountSettings/index.tsx (97%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/AccountsTab/AccountSettings/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/AccountsTab/PersonalDetails/index.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/AccountsTab/PersonalDetails/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/ReceivedInvitations/index.tsx (87%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/ReceivedInvitations/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/SentInvitations/index.tsx (88%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/SentInvitations/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/index.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/Invitation/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/InviteNew/Invite/TableData.tsx (95%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/InviteNew/Invite/index.tsx (95%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/InviteNew/Invite/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/InviteNew/index.tsx (86%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/InviteNew/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/index.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/TeammingTab/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/NewUserModal/index.tsx (93%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/NewUserModal/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/UserDetails/index.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/UserDetails/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/index.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/CreateUser/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/DelUser/index.tsx (90%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/DelUser/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/ResetModal/index.tsx (94%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/ResetModal/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/index.tsx (96%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/EditUser/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/UserManagement/index.tsx (98%) rename litmus-portal/frontend/src/{components/Sections => views}/Settings/UserManagementTab/UserManagement/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/WorkflowDetails/ArgoWorkflow/index.tsx (87%) rename litmus-portal/frontend/src/{components/Sections => views}/WorkflowDetails/ArgoWorkflow/styles.ts (100%) rename litmus-portal/frontend/src/{components/Sections => views}/WorkflowDetails/WorkflowInfo/index.tsx (96%) rename litmus-portal/frontend/src/{components/Sections => views}/WorkflowDetails/WorkflowInfo/styles.ts (100%) diff --git a/litmus-portal/frontend/cypress/component/LinearProgressBar.spec.tsx b/litmus-portal/frontend/cypress/component/LinearProgressBar.spec.tsx index 111abb1b1..99e21af79 100644 --- a/litmus-portal/frontend/cypress/component/LinearProgressBar.spec.tsx +++ b/litmus-portal/frontend/cypress/component/LinearProgressBar.spec.tsx @@ -1,7 +1,7 @@ /// -import React from 'react'; import { mount } from 'cypress-react-unit-test'; -import LinearProgressBar from '../../src/components/Sections/ReturningHome/ProgressBar/LinearProgressBar'; +import React from 'react'; +import LinearProgressBar from '../../src/views/ReturningHome/ProgressBar/LinearProgressBar'; describe('Linear Progressbar Testing', () => { it('Progressbar stroke for value 3', () => { diff --git a/litmus-portal/frontend/cypress/component/passedVsFailed.spec.tsx b/litmus-portal/frontend/cypress/component/passedVsFailed.spec.tsx index a28248f18..abda1ae92 100644 --- a/litmus-portal/frontend/cypress/component/passedVsFailed.spec.tsx +++ b/litmus-portal/frontend/cypress/component/passedVsFailed.spec.tsx @@ -1,9 +1,8 @@ /// -import React from 'react'; import { mount } from 'cypress-react-unit-test'; - -import PassedVsFailed from '../../src/components/Sections/ReturningHome/PassedVsFailed/index'; +import React from 'react'; +import PassedVsFailed from '../../src/views/ReturningHome/PassedVsFailed/index'; // Test Suite - Passing props -> passed: 75, failed: 25 describe('Passed Vs Failed: props -> passed: 75, failed: 25', () => { diff --git a/litmus-portal/frontend/cypress/component/semiCircularProgressBar.spec.tsx b/litmus-portal/frontend/cypress/component/semiCircularProgressBar.spec.tsx index 7f5f23b50..6fd1b6b4f 100644 --- a/litmus-portal/frontend/cypress/component/semiCircularProgressBar.spec.tsx +++ b/litmus-portal/frontend/cypress/component/semiCircularProgressBar.spec.tsx @@ -1,8 +1,8 @@ /// -import React from 'react'; import { mount } from 'cypress-react-unit-test'; -import SemiCircularProgressBar from '../../src/components/Sections/ReturningHome/ProgressBar/SemiCircularProgressBar'; +import React from 'react'; +import SemiCircularProgressBar from '../../src/views/ReturningHome/ProgressBar/SemiCircularProgressBar'; // Test Suite - // Progress Bar props -> value = 50, 10, 100 diff --git a/litmus-portal/frontend/cypress/component/weightSlider.spec.tsx b/litmus-portal/frontend/cypress/component/weightSlider.spec.tsx index 0a9cc3cd1..78db2b927 100644 --- a/litmus-portal/frontend/cypress/component/weightSlider.spec.tsx +++ b/litmus-portal/frontend/cypress/component/weightSlider.spec.tsx @@ -1,7 +1,7 @@ /// import { mount } from 'cypress-react-unit-test'; import React from 'react'; -import CustomSlider from '../../src/components/Sections/CreateWorkflow/WeightSlider'; +import CustomSlider from '../../src/views/CreateWorkflow/WeightSlider'; describe('Testing Custom Slider with different values', () => { [10, 5, 2].map((i) => { diff --git a/litmus-portal/frontend/src/components/AdjustedWeights/index.tsx b/litmus-portal/frontend/src/components/AdjustedWeights/index.tsx index 037584335..1a7879439 100644 --- a/litmus-portal/frontend/src/components/AdjustedWeights/index.tsx +++ b/litmus-portal/frontend/src/components/AdjustedWeights/index.tsx @@ -1,8 +1,8 @@ -import React from 'react'; import { Typography } from '@material-ui/core'; -import LinearProgressBar from '../Sections/ReturningHome/ProgressBar/LinearProgressBar'; -import useStyles from './styles'; +import React from 'react'; import capitalize from '../../utils/capitalize'; +import LinearProgressBar from '../../views/ReturningHome/ProgressBar/LinearProgressBar'; +import useStyles from './styles'; interface AdjustedWeightsProps { testName: string; diff --git a/litmus-portal/frontend/src/components/BreadCrumbs/index.tsx b/litmus-portal/frontend/src/components/BreadCrumbs/index.tsx index 3a2ce1264..8bb892269 100644 --- a/litmus-portal/frontend/src/components/BreadCrumbs/index.tsx +++ b/litmus-portal/frontend/src/components/BreadCrumbs/index.tsx @@ -1,8 +1,7 @@ import Breadcrumbs from '@material-ui/core/Breadcrumbs'; import * as React from 'react'; -import { useEffect } from 'react'; import { Link } from 'react-router-dom'; -import { history } from '../../redux/configureStore'; +import capitalize from '../../utils/capitalize'; import useStyles from './styles'; interface CustomBreadcrumbsProps { @@ -10,38 +9,32 @@ interface CustomBreadcrumbsProps { } const CustomBreadcrumbs: React.FC = ({ location }) => { - const path: string[] = location.split('/'); - - let intermediateRoutes: string = '/'; - + const pathname: string[] = location.split('/'); + let intermediateRoutes = '/'; const classes = useStyles(); - useEffect(() => {}, [path]); - return ( - {path.map((path: string) => { + {pathname.map((path) => { if (path) { intermediateRoutes += path; - + // If Template/Workflow Name is clicked [Workflow / Workflow-name / Template] + // it would redirect to /workflows + if (pathname[2] === 'template' && path === pathname[3]) { + return {path}; + } const link = ( { - history.push(`/${path}`); - }} > - {path.charAt(0).toUpperCase() + path.slice(1)} + {capitalize(path)} ); - intermediateRoutes += '/'; - return link; } - return ''; })} diff --git a/litmus-portal/frontend/src/containers/layouts/Header/NotificationDropdown.tsx b/litmus-portal/frontend/src/components/Header/NotificationDropdown.tsx similarity index 94% rename from litmus-portal/frontend/src/containers/layouts/Header/NotificationDropdown.tsx rename to litmus-portal/frontend/src/components/Header/NotificationDropdown.tsx index 866f74ea2..8dc8daa6f 100644 --- a/litmus-portal/frontend/src/containers/layouts/Header/NotificationDropdown.tsx +++ b/litmus-portal/frontend/src/components/Header/NotificationDropdown.tsx @@ -1,24 +1,24 @@ /* eslint-disable no-nested-ternary */ -import React, { useState, useRef } from 'react'; import { - Popover, - IconButton, AppBar, + Badge, + Box, + IconButton, List, ListItem, ListItemText, + Popover, Typography, - Box, - Badge, } from '@material-ui/core'; import NotificationsOutlinedIcon from '@material-ui/icons/NotificationsOutlined'; -import NotificationListItem from './NotificationListItem'; -import useStyles from './styles'; +import React, { useRef, useState } from 'react'; import { Message, - NotificationsCallBackType, NotificationIds, -} from '../../../models/header'; + NotificationsCallBackType, +} from '../../models/header'; +import NotificationListItem from './NotificationListItem'; +import useStyles from './styles'; interface NotificationDropdownProps { messages: Message[]; @@ -61,7 +61,8 @@ const NotificationsDropdown: React.FC = ({ color="inherit" > diff --git a/litmus-portal/frontend/src/containers/layouts/Header/NotificationListItem.tsx b/litmus-portal/frontend/src/components/Header/NotificationListItem.tsx similarity index 97% rename from litmus-portal/frontend/src/containers/layouts/Header/NotificationListItem.tsx rename to litmus-portal/frontend/src/components/Header/NotificationListItem.tsx index d10990938..53585fc79 100644 --- a/litmus-portal/frontend/src/containers/layouts/Header/NotificationListItem.tsx +++ b/litmus-portal/frontend/src/components/Header/NotificationListItem.tsx @@ -1,17 +1,17 @@ +import { + IconButton, + ListItem, + ListItemSecondaryAction, + ListItemText, +} from '@material-ui/core'; +import ClearIcon from '@material-ui/icons/Clear'; +import formatDistance from 'date-fns/formatDistance'; import React, { useState } from 'react'; -import { - ListItem, - ListItemText, - ListItemSecondaryAction, - IconButton, -} from '@material-ui/core'; -import formatDistance from 'date-fns/formatDistance'; -import ClearIcon from '@material-ui/icons/Clear'; import { Message, - NotificationsCallBackType, NotificationIds, -} from '../../../models/header'; + NotificationsCallBackType, +} from '../../models/header'; import useStyles from './styles'; interface NotificationListItemProps { diff --git a/litmus-portal/frontend/src/containers/layouts/Header/ProfileDropdownItems.tsx b/litmus-portal/frontend/src/components/Header/ProfileDropdownItems.tsx similarity index 85% rename from litmus-portal/frontend/src/containers/layouts/Header/ProfileDropdownItems.tsx rename to litmus-portal/frontend/src/components/Header/ProfileDropdownItems.tsx index 6be3f2681..6c34386d9 100644 --- a/litmus-portal/frontend/src/containers/layouts/Header/ProfileDropdownItems.tsx +++ b/litmus-portal/frontend/src/components/Header/ProfileDropdownItems.tsx @@ -12,19 +12,20 @@ import { } from '@material-ui/core'; import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; -import config from '../../../config'; -import { GET_USER } from '../../../graphql'; +import config from '../../config'; +import { GET_USER } from '../../graphql'; import { CurrentUserDedtailsVars, CurrentUserDetails, Member, Project, -} from '../../../models/graphql/user'; -import { ProjectsCallBackType } from '../../../models/header'; -import useActions from '../../../redux/actions'; -import * as UserActions from '../../../redux/actions/user'; -import { RootState } from '../../../redux/reducers'; -import userAvatar from '../../../utils/user'; +} from '../../models/graphql/user'; +import { ProjectsCallBackType } from '../../models/header'; +import useActions from '../../redux/actions'; +import * as UserActions from '../../redux/actions/user'; +import { history } from '../../redux/configureStore'; +import { RootState } from '../../redux/reducers'; +import userAvatar from '../../utils/user'; import ProjectListItem from './ProjectListItem'; import useStyles from './styles'; @@ -62,11 +63,9 @@ const ProfileInfoDropdownItems: React.FC = ({ { variables: { username } } ); const projects = data?.getUser.projects ?? []; - const [switchableProjects, setSwitchableProjects] = useState( - projects - ); + const [switchableProjects, setSwitchableProjects] = useState([]); const [loggedOut, doLogout] = useState(false); - const { userData } = useSelector((state: RootState) => state); + const userData = useSelector((state: RootState) => state.userData); const logOut = () => { doLogout(true); @@ -88,8 +87,6 @@ const ProfileInfoDropdownItems: React.FC = ({ }); }; - const editProfile = () => {}; - const CallbackFromProjectListItem = (selectedProjectIDFromList: string) => { CallbackToSetSelectedProjectIDOnProfileDropdown(selectedProjectIDFromList); }; @@ -98,6 +95,7 @@ const ProfileInfoDropdownItems: React.FC = ({ const projectsAvailableForSwitching: Project[] = []; projects.forEach((project) => { const memberList: Member[] = project.members; + memberList.forEach((member) => { if (member.user_name === username && member.invitation === 'Accepted') { projectsAvailableForSwitching.push(project); @@ -105,10 +103,6 @@ const ProfileInfoDropdownItems: React.FC = ({ }); }); setSwitchableProjects(projectsAvailableForSwitching); - }, []); - - useEffect(() => { - setSwitchableProjects(projects); }, [data]); return ( @@ -157,14 +151,16 @@ const ProfileInfoDropdownItems: React.FC = ({ {email} - + {userData.userRole === 'Owner' && ( + + )}