From 82d2ebdd1faddd797d9f674c8e68b0df25aa5915 Mon Sep 17 00:00:00 2001
From: Ankita Sahu <71656941+SAHU-01@users.noreply.github.com>
Date: Wed, 18 Sep 2024 19:10:29 +0530
Subject: [PATCH] Environments page MUI v5 update
Signed-off-by: Ankita Sahu <71656941+SAHU-01@users.noreply.github.com>
---
.../Environments/environment-card.js | 172 ++++---
ui/components/Lifecycle/Environments/index.js | 58 ++-
.../Lifecycle/Environments/styles.js | 460 ++++++++----------
ui/pages/management/environments.js | 11 +-
4 files changed, 344 insertions(+), 357 deletions(-)
diff --git a/ui/components/Lifecycle/Environments/environment-card.js b/ui/components/Lifecycle/Environments/environment-card.js
index 57745cc26c1..2c43746be6e 100644
--- a/ui/components/Lifecycle/Environments/environment-card.js
+++ b/ui/components/Lifecycle/Environments/environment-card.js
@@ -1,15 +1,30 @@
import React from 'react';
-import { Button, Card, Grid, Typography, Box } from '@material-ui/core';
+// import { Button, Card, Grid, Typography, Box } from '@material-ui/core';
import SyncAltIcon from '@mui/icons-material/SyncAlt';
-import { Delete, Edit } from '@material-ui/icons';
+import { Delete, Edit } from '@mui/icons-material';
import { FlipCard } from '../General';
import { useGetEnvironmentConnectionsQuery } from '../../../rtk-query/environments';
-import classNames from 'classnames';
+// import classNames from 'classnames';
import CAN from '@/utils/can';
import { keys } from '@/utils/permission_constants';
-import { Checkbox } from '@layer5/sistent';
+// import { Checkbox, Button, Card, Grid, Typography, Box } from '@layer5/sistent';
+import { Grid } from '@layer5/sistent';
import { UsesSistent } from '@/components/SistentWrapper';
+import {
+ PopupButton,
+ TabCount,
+ CardWrapper,
+ TabTitle,
+ Name,
+ IconButton,
+ EmptyDescription,
+ DescriptionLabel,
+ AllocationButton,
+ BulkSelectCheckbox,
+ CardTitle,
+ DateLabel,
+} from './styles';
export const formattoLongDate = (date) => {
return new Date(date).toLocaleDateString('en-US', {
@@ -19,21 +34,26 @@ export const formattoLongDate = (date) => {
});
};
-export const TransferButton = ({ title, count, onAssign, classes, disabled }) => {
+export const TransferButton = ({ title, count, onAssign, disabled }) => {
return (
-
+
+
+
+ {count}
+ {title}
+
+
+
+
);
};
@@ -60,7 +80,6 @@ const EnvironmentCard = ({
onEdit,
onSelect,
onAssignConnection,
- classes,
}) => {
const { data: environmentConnections } = useGetEnvironmentConnectionsQuery(
{
@@ -80,51 +99,46 @@ const EnvironmentCard = ({
: false
}
frontComponents={
-
-
- e.stopPropagation()}
- >
+
+ e.stopPropagation()}>
{environmentDetails?.name}
-
+
-
+
{environmentDetails.description ? (
- e.stopPropagation()}
- style={{ marginBottom: { xs: 2, sm: 0 }, paddingRight: { sm: 2, lg: 0 } }}
- >
- {environmentDetails.description}
-
+ e.stopPropagation()}
+ sx={{ marginBottom: { xs: 2, sm: 0 }, paddingRight: { sm: 2, lg: 0 }, marginTop:'0px' }}
+ >
+ {environmentDetails.description}
+
) : (
- e.stopPropagation()}
- style={{ color: 'rgba(122,132,142,1)' }}
+ sx={{ color: 'rgba(122,132,142,1)' }}
>
No description
-
+
)}
- e.stopPropagation()}>
+ e.stopPropagation()}>
-
+
{/* temporary disable workspace allocation button */}
{false && (
- e.stopPropagation()}>
+ e.stopPropagation()}>
-
+
)}
-
+
}
backComponents={
-
-
-
+
+
- e.stopPropagation()}
onChange={onSelect}
disabled={deleted ? true : false}
/>
- e.stopPropagation()}
>
{environmentDetails?.name}
-
+
-
-
+
+ id == environmentDetails.id).length === 1
@@ -215,31 +227,31 @@ const EnvironmentCard = ({
: !CAN(keys.DELETE_ENVIRONMENT.action, keys.DELETE_ENVIRONMENT.subject)
}
>
-
-
+
+
-
-
-
+
+ e.stopPropagation()}
>
Updated At: {formattoLongDate(environmentDetails?.updated_at)}
-
+
-
-
+ e.stopPropagation()}
>
Created At: {formattoLongDate(environmentDetails?.created_at)}
-
+
-
+
}
/>
);
diff --git a/ui/components/Lifecycle/Environments/index.js b/ui/components/Lifecycle/Environments/index.js
index b8949dae7ca..49d6e0dadf4 100644
--- a/ui/components/Lifecycle/Environments/index.js
+++ b/ui/components/Lifecycle/Environments/index.js
@@ -1,23 +1,22 @@
import { useEffect, useRef, useState } from 'react';
-import { Button, Grid, NoSsr, Typography, Box } from '@material-ui/core';
import { connect } from 'react-redux';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
-import { withStyles } from '@material-ui/core/styles';
import { Pagination, PaginationItem } from '@material-ui/lab';
import { withRouter } from 'next/router';
import { debounce } from 'lodash';
import { Delete } from '@material-ui/icons';
-import classNames from 'classnames';
-
+// import classNames from 'classnames';
+import { NoSsr } from '@mui/material';
+import { ToolWrapper, CreateButtonWrapper, BulkActionWrapper } from '../Workspaces/index.js';
import AddIconCircleBorder from '../../../assets/icons/AddIconCircleBorder';
import EnvironmentCard from './environment-card';
import EnvironmentIcon from '../../../assets/icons/Environment';
import { EVENT_TYPES } from '../../../lib/event-types';
import { updateProgress } from '../../../lib/store';
import { useNotification } from '../../../utils/hooks/useNotification';
-import useStyles from '../../../assets/styles/general/tool.styles';
-import SearchBar from '../../../utils/custom-search';
+// import useStyles from '../../../assets/styles/general/tool.styles';
+// import SearchBar from '../../../utils/custom-search';
import { RJSFModalWrapper } from '../../Modal';
import PromptComponent, { PROMPT_VARIANTS } from '../../PromptComponent';
import { EmptyState } from '../General';
@@ -30,6 +29,11 @@ import {
createAndEditEnvironmentSchema,
createAndEditEnvironmentUiSchema,
ErrorBoundary,
+ Button,
+ Grid,
+ Typography,
+ SearchBar,
+ // Box,
} from '@layer5/sistent';
import ConnectionIcon from '../../../assets/icons/Connection';
import { TRANSFER_COMPONENT } from '../../../utils/Enum';
@@ -42,7 +46,7 @@ import {
useUpdateEnvironmentMutation,
useDeleteEnvironmentMutation,
} from '../../../rtk-query/environments';
-import styles from './styles';
+// import styles from './styles';
import { keys } from '@/utils/permission_constants';
import CAN from '@/utils/can';
import DefaultError from '../../General/error-404/index';
@@ -53,7 +57,7 @@ const ACTION_TYPES = {
EDIT: 'edit',
};
-const Environments = ({ organization, classes }) => {
+const Environments = ({ organization }) => {
const [environmentModal, setEnvironmentModal] = useState({
open: false,
schema: {},
@@ -81,7 +85,7 @@ const Environments = ({ organization, classes }) => {
const modalRef = useRef(null);
const { notify } = useNotification();
- const StyleClass = useStyles();
+ // const StyleClass = useStyles();
const {
data: environmentsData,
@@ -445,25 +449,26 @@ const Environments = ({ organization, classes }) => {
{CAN(keys.VIEW_ENVIRONMENTS.action, keys.VIEW_ENVIRONMENTS.subject) ? (
<>
-
-
+
+
-
+
+
{
setSearch(value);
@@ -480,17 +486,18 @@ const Environments = ({ organization, classes }) => {
expanded={isSearchExpanded}
setExpanded={setIsSearchExpanded}
/>
-
+
+
{selectedEnvironments.length > 0 && (
-
+
{selectedEnvironments.length > 1
? `${selectedEnvironments.length} environments selected`
: `${selectedEnvironments.length} environment selected`}
-
+
)}
{environments.length > 0 ? (
<>
@@ -507,7 +514,7 @@ const Environments = ({ organization, classes }) => {
{environments.map((environment) => (
handleEnvironmentModalOpen(e, ACTION_TYPES.EDIT, environment)}
@@ -520,8 +527,7 @@ const Environments = ({ organization, classes }) => {
{
);
};
-export default withStyles(styles)(
- connect(mapStateToProps)(withRouter(EnvironmentsPageWithErrorBoundary)),
-);
+export default connect(mapStateToProps)(withRouter(EnvironmentsPageWithErrorBoundary));
diff --git a/ui/components/Lifecycle/Environments/styles.js b/ui/components/Lifecycle/Environments/styles.js
index 4de9e80d622..edb6d2e32d7 100644
--- a/ui/components/Lifecycle/Environments/styles.js
+++ b/ui/components/Lifecycle/Environments/styles.js
@@ -1,285 +1,255 @@
-import { styled } from '@material-ui/core';
-import { Colors } from '../../../themes/app';
+import { styled } from '@mui/material/styles';
+import { Checkbox, Typography, Button } from '@layer5/sistent';
-const styles = (theme) => ({
- /** Bulk action bar styles */
- bulkActionWrapper: {
- width: '100%',
- padding: '0.8rem',
- justifyContent: 'space-between',
- marginTop: '0.18rem',
- marginBottom: '1rem',
- borderRadius: '.25rem',
- display: 'flex',
- flexDirection: 'row',
- alignItems: 'center',
- },
-
- /** Card Styles */
- cardWrapper: {
- width: '100%',
- display: 'flex',
- flexDirection: 'column',
- padding: '20px',
- backgroundColor: theme.palette.secondary.white,
- '&:hover': {
- cursor: 'pointer',
- },
- },
-
- statistic: {
- display: 'flex',
- justifyContent: 'center',
- paddingX: '5px',
- fontWeight: '600',
- fontSize: '24px',
- textAlign: 'center',
- },
-
- statisticName: {
- display: 'flex',
- justifyContent: 'center',
- paddingX: '5px',
- fontWeight: '400',
- fontSize: '16px',
- textAlign: 'center',
- },
+/** Bulk action bar styles */
+export const BulkActionWrapper = styled('div')({
+ width: '100%',
+ padding: '0.8rem',
+ justifyContent: 'space-between',
+ marginTop: '0.18rem',
+ marginBottom: '1rem',
+ borderRadius: '.25rem',
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+});
- tabCardContent: {
- padding: '16px',
- display: 'flex',
- justifyContent: 'center',
- flexDirection: 'row',
+/** Card Styles */
+export const CardWrapper = styled('div')(() => ({
+ width: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ padding: '20px',
+ backgroundColor: '#ffffff',
+ '&:hover': {
+ cursor: 'pointer',
},
+}));
- tabIconBox: {
- display: 'flex',
- alignItems: 'center',
- border: `1px solid ${Colors.keppelGreen}`,
- borderRadius: '5px 0 0 5px',
- padding: '8px 16px',
- borderRight: '0',
- '&:hover': {
- cursor: 'default',
- },
- },
+export const Statistic = styled('div')({
+ display: 'flex',
+ justifyContent: 'center',
+ padding: '0 5px',
+ fontWeight: 600,
+ fontSize: '24px',
+ textAlign: 'center',
+});
- tabNameBox: {
- display: 'flex',
- alignItems: 'center',
- flexDirection: 'column',
- background: Colors.keppelGreen,
- color: theme.palette.secondary.white,
- p: '8px',
- border: `1px solid ${Colors.keppelGreen}`,
- borderRadius: '0 5px 5px 0',
- padding: '8px 16px',
- },
+export const StatisticName = styled('div')({
+ display: 'flex',
+ justifyContent: 'center',
+ padding: '0 5px',
+ fontWeight: 400,
+ fontSize: '16px',
+ textAlign: 'center',
+});
- tabTitle: {
- margin: '0',
- fontSize: '12px',
- fontWeight: '400',
- display: 'flex',
- },
+export const TabCardContent = styled('div')({
+ padding: '16px',
+ display: 'flex',
+ justifyContent: 'center',
+ flexDirection: 'row',
+});
- tabCount: {
- margin: '0',
- fontSize: '60px',
- fontWeight: '500',
- lineHeight: 1,
- marginBottom: '5px',
+export const TabIconBox = styled('div')({
+ display: 'flex',
+ alignItems: 'center',
+ border: `1px solid #00B39F`,
+ borderRadius: '5px 0 0 5px',
+ padding: '8px 16px',
+ borderRight: 0,
+ '&:hover': {
+ cursor: 'default',
},
+});
- allocationButton: {
- padding: '10px 10px 1px 10px',
- borderRadius: '4px',
- height: '100%',
- display: 'flex',
- width: '100%',
- background: theme.palette.secondary.focused,
- },
+export const TabNameBox = styled('div')(() => ({
+ display: 'flex',
+ alignItems: 'center',
+ flexDirection: 'column',
+ background: '#00B39F',
+ color: '#fff',
+ padding: '8px 16px',
+ border: `1px solid #00B39F`,
+ borderRadius: '0 5px 5px 0',
+}));
+
+export const TabTitle = styled('p')({
+ margin: 0,
+ fontSize: '12px',
+ fontWeight: 400,
+ display: 'flex',
+});
- allocationWorkspace: {
- display: 'flex',
- width: '100%',
- gap: '10px',
- ['@media (min-width : 600px)']: {
- flexDirection: 'column',
- gap: '0',
- },
- },
+export const TabCount = styled('p')({
+ margin: 0,
+ fontSize: '60px',
+ fontWeight: 500,
+ lineHeight: 1,
+ marginBottom: '5px',
+});
- popupButton: {
- width: '100%',
- borderRadius: '4px',
- boxShadow: '0px 4px 4px 0px rgba(0, 0, 0, 0.25)',
- marginBottom: '10px',
- padding: '20px 10px',
- backgroundColor: theme.palette.secondary.mainBackground2,
- color: theme.palette.secondary.penColorPrimary,
- '&:hover': {
- background: theme.palette.secondary.mainBackground2,
- },
- },
+export const AllocationButton = styled('div')(() => ({
+ padding: '10px 10px 1px 10px',
+ borderRadius: '4px',
+ height: '100%',
+ display: 'flex',
+ width: '100%',
+ background: '#607d8b',
+}));
- record: {
- borderBottom: `1px solid ${theme.palette.secondary.modalTabs}60`,
- display: 'flex',
- flexDirection: 'row',
- padding: '5px 0',
+export const AllocationWorkspace = styled('div')({
+ display: 'flex',
+ width: '100%',
+ gap: '10px',
+ '@media (min-width: 600px)': {
+ flexDirection: 'column',
+ gap: 0,
},
+});
- bulkSelectCheckbox: {
- padding: 0,
- marginRight: '0.5rem',
+export const PopupButton = styled(Button)(() => ({
+ width: '100%',
+ borderRadius: '4px',
+ boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)',
+ marginBottom: '10px',
+ padding: '20px 10px',
+}));
+
+export const Record = styled('div')(() => ({
+ // borderBottom: `1px solid ${theme.palette.secondary.modalTabs}60`,
+ display: 'flex',
+ flexDirection: 'row',
+ padding: '5px 0',
+}));
+
+export const BulkSelectCheckbox = styled(Checkbox)({
+ padding: 0,
+ marginRight: '0.5rem',
+ color: 'white',
+ '&:hover': {
color: 'white',
- '&:hover': {
- color: 'white',
- cursor: 'pointer',
- },
- '&.Mui-checked': {
- color: 'white',
- },
+ cursor: 'pointer',
},
-
- cardTitle: {
- fontSize: '1.25rem',
- fontWeight: 800,
- '&:hover': {
- cursor: 'default',
- },
- },
-
- organizationName: {
- fontSize: '0.9rem',
- display: 'flex',
- alignItems: 'end',
- padding: '0 5px',
- '&:hover': {
- cursor: 'default',
- },
+ '& .Mui-checked': {
+ color: 'white',
},
+});
- styledIconButton: {
- background: 'transparent',
- border: 'none',
- '&:hover': {
- cursor: 'default',
- },
+export const CardTitle = styled('h2')({
+ fontSize: '1.25rem',
+ fontWeight: 800,
+ '&:hover': {
+ cursor: 'default',
},
+});
- dateLabel: {
- fontStyle: 'italic',
- fontSize: '12px',
- '&:hover': {
- cursor: 'default',
- },
+export const OrganizationName = styled('p')({
+ fontSize: '0.9rem',
+ display: 'flex',
+ alignItems: 'end',
+ padding: '0 5px',
+ '&:hover': {
+ cursor: 'default',
},
+});
- emptyDescription: {
- fontSize: '0.9rem',
- textAlign: 'left',
- fontStyle: 'italic',
+export const StyledIconButton = styled('button')({
+ background: 'transparent',
+ border: 'none',
+ '&:hover': {
+ cursor: 'default',
},
+});
- descriptionLabel: {
- height: 'fit-content',
- fontStyle: 'italic',
- '&:hover': {
- cursor: 'default',
- },
+export const DateLabel = styled(Typography)({
+ fontStyle: 'italic',
+ fontSize: '12px',
+ '&:hover': {
+ cursor: 'default',
},
+});
- name: {
- height: 'fit-content',
- textAlign: 'left',
- fontWeight: 'bold',
- },
+export const EmptyDescription = styled('p')({
+ fontSize: '0.9rem',
+ textAlign: 'left',
+ fontStyle: 'italic',
+});
- status: {
- padding: '5px 20px',
- width: 'fit-content',
- border: '1px solid transparent',
- fontSize: '12px',
- '&:hover': {
- cursor: 'default',
- },
+export const DescriptionLabel = styled('p')({
+ height: 'fit-content',
+ fontStyle: 'italic',
+ '&:hover': {
+ cursor: 'default',
},
+});
- styledChip: {
- padding: '5px 6px !important',
- color: theme.palette.secondary.text,
- fontSize: '14px',
- textTransform: 'uppercase',
- fontWeight: 400,
- height: 'unset',
- borderRadius: '100px',
- border: `0.5px solid ${theme.palette.secondary.default}`,
- background: theme.palette.secondary.white,
- maxWidth: '230px',
- '.MuiChip-avatar': {
- margin: '0',
- },
- '&:hover': {
- cursor: 'default',
- },
- },
+export const Name = styled(Typography)({
+ height: 'fit-content',
+ textAlign: 'left',
+ fontWeight: 'bold',
+});
- createButtonWrapper: {
- display: 'flex',
- justifyContent: 'flex-start',
- alignItems: 'center',
- whiteSpace: 'nowrap',
+export const Status = styled('div')({
+ padding: '5px 20px',
+ width: 'fit-content',
+ border: '1px solid transparent',
+ fontSize: '12px',
+ '&:hover': {
+ cursor: 'default',
},
+});
- editButton: {
- backgroundColor: Colors.keppelGreen,
- '&:hover': {
- backgroundColor: Colors.caribbeanGreen,
- },
- '@media (max-width: 768px)': {
- minWidth: '50px',
- },
- },
+export const StyledChip = styled('div')(({ theme }) => ({
+ padding: '5px 6px',
+ color: theme.palette.secondary.text,
+ fontSize: '14px',
+ textTransform: 'uppercase',
+ fontWeight: 400,
+ height: 'unset',
+ borderRadius: '100px',
+ border: `0.5px solid ${theme.palette.secondary.default}`,
+ background: theme.palette.secondary.white,
+ maxWidth: '230px',
+ '& .MuiChip-avatar': {
+ margin: 0,
+ },
+ '&:hover': {
+ cursor: 'default',
+ },
+}));
+
+export const CreateButtonWrapper = styled('div')({
+ display: 'flex',
+ justifyContent: 'flex-start',
+ alignItems: 'center',
+ whiteSpace: 'nowrap',
+});
- textButton: {
- marginLeft: '0.5rem',
- display: 'block',
- '@media (max-width: 853px)': {
- display: 'none',
- },
+export const EditButton = styled('button')({
+ backgroundColor: '#00B39F',
+ '&:hover': {
+ backgroundColor: '#00D3a9',
},
-
- iconButton: {
- minWidth: 'fit-content',
- '&:hover': {
- background: 'transparent',
- },
- padding: 0,
+ '@media (max-width: 768px)': {
+ minWidth: '50px',
},
});
-// TODO: replace above makestyles with below styled components in code
-export const BulkActionWrapper = styled(`div`)({
- width: '100%',
- padding: '0.8rem',
- justifyContent: 'space-between',
- marginTop: '0.18rem',
- marginBottom: '1rem',
- borderRadius: '.25rem',
- display: 'flex',
- flexDirection: 'row',
- alignItems: 'center',
+export const TextButton = styled('button')({
+ marginLeft: '0.5rem',
+ display: 'block',
+ '@media (max-width: 853px)': {
+ display: 'none',
+ },
});
-export const Statistic = styled(`div`)({
- display: 'flex',
- justifyContent: 'center',
- paddingX: '5px',
- fontWeight: '400',
- fontSize: '16px',
- textAlign: 'center',
+export const IconButton = styled('button')({
+ minWidth: 'fit-content',
+ '&:hover': {
+ background: 'transparent',
+ },
+ padding: 0,
+ background: 'none',
+ border: 'none',
});
-
-export default styles;
diff --git a/ui/pages/management/environments.js b/ui/pages/management/environments.js
index 9be93f5e6c0..b63f4e17fd5 100644
--- a/ui/pages/management/environments.js
+++ b/ui/pages/management/environments.js
@@ -1,10 +1,9 @@
import React from 'react';
-import { NoSsr, withStyles } from '@material-ui/core';
+import { NoSsr } from '@mui/material';
import { connect } from 'react-redux';
import Head from 'next/head';
import { EnvironmentComponent } from '../../components/Lifecycle';
-
-const styles = { paper: { maxWidth: '90%', margin: 'auto', overflow: 'hidden' } };
+import { Box } from '@mui/material';
const Environments = () => {
return (
@@ -12,9 +11,11 @@ const Environments = () => {
Environments | Meshery
-
+
+
+
);
};
-export default withStyles(styles)(connect(null)(Environments));
+export default connect(null)(Environments);