1414// You should have received a copy of the GNU Affero General Public License
1515// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17- import React , { Fragment } from "react" ;
18- import { styled } from "@mui/material/styles" ;
19- import LinearProgress , {
20- linearProgressClasses ,
21- LinearProgressProps ,
22- } from "@mui/material/LinearProgress" ;
23- import Box from "@mui/material/Box" ;
17+ import React from "react" ;
18+ import { ProgressBar , ProgressBarProps } from "mds" ;
2419
2520interface IProgressBarWrapper {
2621 value : number ;
@@ -30,62 +25,28 @@ interface IProgressBarWrapper {
3025 size ?: string ;
3126 error ?: boolean ;
3227 cancelled ?: boolean ;
28+ notificationLabel ?: string ;
3329}
3430
35- const BorderLinearProgress = styled ( LinearProgress ) ( ( ) => ( {
36- height : 10 ,
37- borderRadius : 5 ,
38- [ `&.${ linearProgressClasses . colorPrimary } ` ] : {
39- backgroundColor : "#f1f1f1" ,
40- } ,
41- [ `& .${ linearProgressClasses . bar } ` ] : {
42- borderRadius : 5 ,
43- } ,
44- } ) ) ;
45- const SmallBorderLinearProgress = styled ( BorderLinearProgress ) ( ( ) => ( {
46- height : 6 ,
47- borderRadius : 3 ,
48- [ `& .${ linearProgressClasses . bar } ` ] : {
49- borderRadius : 3 ,
50- } ,
51- } ) ) ;
52-
5331function LinearProgressWithLabel (
54- props : { error : boolean ; cancelled : boolean } & LinearProgressProps ,
32+ props : { error : boolean ; cancelled : boolean } & ProgressBarProps ,
5533) {
56- let color = "#000" ;
57- let size = 18 ;
34+ let label = "" ;
5835
5936 if ( props . error ) {
60- color = "#C83B51" ;
61- size = 14 ;
37+ label = `Error: ${ props . notificationLabel || "" } ` ;
6238 } else if ( props . cancelled ) {
63- color = "#FFBD62" ;
64- size = 14 ;
39+ label = `Cancelled` ;
6540 }
6641
6742 return (
68- < Box sx = { { display : "flex" , alignItems : "center" } } >
69- < Box sx = { { width : "100%" , mr : 3 } } >
70- < BorderLinearProgress variant = "determinate" { ...props } />
71- </ Box >
72- < Box
73- sx = { {
74- minWidth : 35 ,
75- fontSize : size ,
76- color : color ,
77- } }
78- className = { "value" }
79- >
80- { props . cancelled ? (
81- "Cancelled"
82- ) : (
83- < Fragment >
84- { props . error ? "Failed" : `${ Math . round ( props . value || 0 ) } %` }
85- </ Fragment >
86- ) }
87- </ Box >
88- </ Box >
43+ < ProgressBar
44+ variant = { "determinate" }
45+ value = { props . value }
46+ color = { props . color }
47+ progressLabel
48+ notificationLabel = { label }
49+ />
8950 ) ;
9051}
9152
@@ -97,22 +58,24 @@ const ProgressBarWrapper = ({
9758 size = "regular" ,
9859 error,
9960 cancelled,
61+ notificationLabel,
10062} : IProgressBarWrapper ) => {
10163 let color : any ;
10264 if ( error ) {
103- color = "error " ;
65+ color = "red " ;
10466 } else if ( cancelled ) {
105- color = "warning " ;
67+ color = "orange " ;
10668 } else if ( value === 100 && ready ) {
107- color = "success " ;
69+ color = "green " ;
10870 } else {
109- color = "primary " ;
71+ color = "blue " ;
11072 }
111- const propsComponent : LinearProgressProps = {
73+ const propsComponent : ProgressBarProps = {
11274 variant :
11375 indeterminate && ! ready && ! cancelled ? "indeterminate" : "determinate" ,
11476 value : ready ? 100 : value ,
11577 color : color ,
78+ notificationLabel : notificationLabel || "" ,
11679 } ;
11780 if ( withLabel ) {
11881 return (
@@ -124,10 +87,12 @@ const ProgressBarWrapper = ({
12487 ) ;
12588 }
12689 if ( size === "small" ) {
127- return < SmallBorderLinearProgress { ...propsComponent } /> ;
90+ return (
91+ < ProgressBar { ...propsComponent } sx = { { height : 6 , borderRadius : 6 } } />
92+ ) ;
12893 }
12994
130- return < BorderLinearProgress { ...propsComponent } /> ;
95+ return < ProgressBar { ...propsComponent } /> ;
13196} ;
13297
13398export default ProgressBarWrapper ;
0 commit comments