From 8b935dc3c85fbe4030564301820d946effa78426 Mon Sep 17 00:00:00 2001 From: Guilherme Caponetto <638737+caponetto@users.noreply.github.com> Date: Tue, 28 May 2024 12:48:10 -0300 Subject: [PATCH] fix(orchestrator): upgrade to mui v5 (#1727) * fix(orchestrator): upgrade to mui v5 * fix leftover --- plugins/orchestrator/package.json | 6 +- .../ExecuteWorkflowPage.tsx | 2 +- .../ExecuteWorkflowPage/JsonTextAreaForm.tsx | 11 +- .../ExecuteWorkflowPage/StepperForm.tsx | 18 +- .../src/components/InfoDialog.stories.tsx | 2 +- .../src/components/InfoDialog.tsx | 57 ++---- .../src/components/OrchestratorIcon.tsx | 2 +- .../orchestrator/src/components/Paragraph.tsx | 9 +- .../orchestrator/src/components/Selector.tsx | 47 +++-- .../src/components/SubmitButton.tsx | 3 +- .../WorkflowDefinitionDetailsCard.tsx | 19 +- .../WorkflowDefinitionViewerPage.tsx | 5 +- .../components/WorkflowDescriptionModal.tsx | 71 +++---- .../src/components/WorkflowDialog.tsx | 52 +++-- .../src/components/WorkflowInstancePage.tsx | 3 +- .../WorkflowInstancePageContent.tsx | 184 +++++++++--------- .../WorkflowInstanceStatusIndicator.tsx | 4 +- .../src/components/WorkflowProgressNode.tsx | 10 +- .../components/WorkflowRunDetails.stories.tsx | 28 +-- .../src/components/WorkflowRunDetails.tsx | 17 +- .../src/components/WorkflowRunsTabContent.tsx | 2 +- .../components/WorkflowVariablesViewer.tsx | 4 +- .../src/components/WorkflowsTabContent.tsx | 2 +- .../src/components/WorkflowsTable.tsx | 8 +- .../components/ui/OverrideBackstageTable.tsx | 15 +- .../hooks/useWorkflowInstanceStatusColors.ts | 38 ++-- yarn.lock | 2 +- 27 files changed, 267 insertions(+), 354 deletions(-) diff --git a/plugins/orchestrator/package.json b/plugins/orchestrator/package.json index f544f85004..f5611f1dad 100644 --- a/plugins/orchestrator/package.json +++ b/plugins/orchestrator/package.json @@ -51,11 +51,9 @@ "@kie-tools/serverless-workflow-combined-editor": "^0.32.0", "@kie-tools/serverless-workflow-language-service": "^0.32.0", "@kie-tools/serverless-workflow-service-catalog": "^0.32.0", - "@material-ui/core": "^4.12.4", - "@material-ui/icons": "^4.11.3", - "@material-ui/lab": "^4.0.0-alpha.45", "@monaco-editor/react": "^4.6.0", - "@mui/icons-material": "^5.15.3", + "@mui/icons-material": "^5.15.18", + "@mui/material": "^5.15.18", "@rjsf/core": "^5.18.4", "@rjsf/mui": "^5.18.4", "@rjsf/utils": "^5.18.4", diff --git a/plugins/orchestrator/src/components/ExecuteWorkflowPage/ExecuteWorkflowPage.tsx b/plugins/orchestrator/src/components/ExecuteWorkflowPage/ExecuteWorkflowPage.tsx index 1b34dda596..20f60a5ef9 100644 --- a/plugins/orchestrator/src/components/ExecuteWorkflowPage/ExecuteWorkflowPage.tsx +++ b/plugins/orchestrator/src/components/ExecuteWorkflowPage/ExecuteWorkflowPage.tsx @@ -15,7 +15,7 @@ import { } from '@backstage/core-plugin-api'; import { JsonObject } from '@backstage/types'; -import { Grid } from '@material-ui/core'; +import Grid from '@mui/material/Grid'; import { QUERY_PARAM_ASSESSMENT_INSTANCE_ID, diff --git a/plugins/orchestrator/src/components/ExecuteWorkflowPage/JsonTextAreaForm.tsx b/plugins/orchestrator/src/components/ExecuteWorkflowPage/JsonTextAreaForm.tsx index 26bb073040..299865bf4a 100644 --- a/plugins/orchestrator/src/components/ExecuteWorkflowPage/JsonTextAreaForm.tsx +++ b/plugins/orchestrator/src/components/ExecuteWorkflowPage/JsonTextAreaForm.tsx @@ -2,9 +2,12 @@ import React from 'react'; import { JsonObject } from '@backstage/types'; -import { Box, Grid, useTheme } from '@material-ui/core'; -import { Alert, AlertTitle } from '@material-ui/lab'; import { Editor } from '@monaco-editor/react'; +import Alert from '@mui/material/Alert'; +import AlertTitle from '@mui/material/AlertTitle'; +import Box from '@mui/material/Box'; +import Grid from '@mui/material/Grid'; +import { useTheme } from '@mui/material/styles'; import SubmitButton from '../SubmitButton'; @@ -40,13 +43,13 @@ const JsonTextAreaForm = ({ - + setJsonText(value ?? '')} height="30rem" - theme={theme.palette.type === 'dark' ? 'vs-dark' : 'light'} + theme={theme.palette.mode === 'dark' ? 'vs-dark' : 'light'} options={{ minimap: { enabled: false }, }} diff --git a/plugins/orchestrator/src/components/ExecuteWorkflowPage/StepperForm.tsx b/plugins/orchestrator/src/components/ExecuteWorkflowPage/StepperForm.tsx index e5ab9c5607..e3f5ff9332 100644 --- a/plugins/orchestrator/src/components/ExecuteWorkflowPage/StepperForm.tsx +++ b/plugins/orchestrator/src/components/ExecuteWorkflowPage/StepperForm.tsx @@ -3,16 +3,14 @@ import React from 'react'; import { Content, StructuredMetadataTable } from '@backstage/core-components'; import { JsonObject } from '@backstage/types'; -import { - Box, - Button, - Paper, - Step, - StepContent, - StepLabel, - Stepper, - Typography, -} from '@material-ui/core'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Paper from '@mui/material/Paper'; +import Step from '@mui/material/Step'; +import StepContent from '@mui/material/StepContent'; +import StepLabel from '@mui/material/StepLabel'; +import Stepper from '@mui/material/Stepper'; +import Typography from '@mui/material/Typography'; import { FormProps } from '@rjsf/core'; import Form from '@rjsf/mui'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; diff --git a/plugins/orchestrator/src/components/InfoDialog.stories.tsx b/plugins/orchestrator/src/components/InfoDialog.stories.tsx index 9c0ea98116..6fc3227a38 100644 --- a/plugins/orchestrator/src/components/InfoDialog.stories.tsx +++ b/plugins/orchestrator/src/components/InfoDialog.stories.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Button } from '@material-ui/core'; +import Button from '@mui/material/Button'; import { useArgs } from '@storybook/preview-api'; import { Meta, StoryObj } from '@storybook/react'; diff --git a/plugins/orchestrator/src/components/InfoDialog.tsx b/plugins/orchestrator/src/components/InfoDialog.tsx index 3813b21679..12d7f963be 100644 --- a/plugins/orchestrator/src/components/InfoDialog.tsx +++ b/plugins/orchestrator/src/components/InfoDialog.tsx @@ -1,16 +1,15 @@ -import React, { forwardRef, ForwardRefRenderFunction } from 'react'; +import React from 'react'; -import { - Box, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - IconButton, - makeStyles, - Typography, -} from '@material-ui/core'; -import CloseIcon from '@material-ui/icons/Close'; +import CloseIcon from '@mui/icons-material/Close'; +import Box from '@mui/material/Box'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; +import IconButton from '@mui/material/IconButton'; +import { styled } from '@mui/material/styles'; +import Typography from '@mui/material/Typography'; export type InfoDialogProps = { title: string; @@ -20,43 +19,29 @@ export type InfoDialogProps = { children?: React.ReactNode; }; -export type ParentComponentRef = HTMLElement; +const CloseButton = styled(IconButton)({ + position: 'absolute', + right: 8, + top: 8, +}); -const useStyles = makeStyles(_theme => ({ - closeBtn: { - position: 'absolute', - right: 8, - top: 8, - }, -})); - -export const RefForwardingInfoDialog: ForwardRefRenderFunction< - ParentComponentRef, - InfoDialogProps -> = (props, forwardedRef): JSX.Element | null => { +export const InfoDialog = (props: InfoDialogProps) => { const { title, open = false, onClose, children, dialogActions } = props; - const classes = useStyles(); return ( - onClose} open={open} ref={forwardedRef}> + onClose} open={open}> {title} - + - + - {children} + {children} {dialogActions} ); }; - -export const InfoDialog = forwardRef(RefForwardingInfoDialog); diff --git a/plugins/orchestrator/src/components/OrchestratorIcon.tsx b/plugins/orchestrator/src/components/OrchestratorIcon.tsx index 8b688e192b..1f608dc29b 100644 --- a/plugins/orchestrator/src/components/OrchestratorIcon.tsx +++ b/plugins/orchestrator/src/components/OrchestratorIcon.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { SvgIcon, SvgIconProps } from '@material-ui/core'; +import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'; const OrchestratorIcon = (props: SvgIconProps) => ( diff --git a/plugins/orchestrator/src/components/Paragraph.tsx b/plugins/orchestrator/src/components/Paragraph.tsx index f2b8921a3c..4eb97dbeaf 100644 --- a/plugins/orchestrator/src/components/Paragraph.tsx +++ b/plugins/orchestrator/src/components/Paragraph.tsx @@ -1,15 +1,12 @@ import React, { PropsWithChildren } from 'react'; -import { Typography } from '@material-ui/core'; -import { Variant } from '@material-ui/core/styles/createTypography'; +import Typography from '@mui/material/Typography'; -export const Paragraph = ( - props: PropsWithChildren<{ variant?: Variant | 'inherit' }>, -) => { +export const Paragraph = (props: PropsWithChildren<{}>) => { return ( {props.children} diff --git a/plugins/orchestrator/src/components/Selector.tsx b/plugins/orchestrator/src/components/Selector.tsx index ab70bea053..776c6d66b1 100644 --- a/plugins/orchestrator/src/components/Selector.tsx +++ b/plugins/orchestrator/src/components/Selector.tsx @@ -2,25 +2,26 @@ import React from 'react'; import { Select, SelectedItems } from '@backstage/core-components'; -import { makeStyles, Typography } from '@material-ui/core'; +import { styled } from '@mui/material/styles'; +import Typography from '@mui/material/Typography'; -const useStyles = makeStyles(theme => ({ - root: { - display: 'flex', - alignItems: 'baseline', - '& label + div': { - marginTop: '0px', - }, - }, - select: { - width: '10rem', - }, - label: { - color: theme.palette.text.primary, - fontSize: theme.typography.fontSize, - paddingRight: '0.5rem', - fontWeight: 'bold', +const RootDiv = styled('div')({ + display: 'flex', + alignItems: 'baseline', + '& label + div': { + marginTop: '0px', }, +}); + +const SelectDiv = styled('div')({ + width: '10rem', +}); + +const StyledLabel = styled(Typography)(({ theme }) => ({ + color: theme.palette.text.primary, + fontSize: theme.typography.fontSize, + paddingRight: '0.5rem', + fontWeight: 'bold', })); const ALL_ITEMS = '___all___'; @@ -35,8 +36,6 @@ export const Selector = ({ includeAll = true, ...otherProps }: SelectorProps) => { - const styles = useStyles(); - const selectItems = React.useMemo( () => includeAll @@ -51,9 +50,9 @@ export const Selector = ({ ); return ( -
- {otherProps.label} -
+ + {otherProps.label} +