@ -6,6 +6,7 @@ import globalMessages from '../../i18n/globalMessages';
import Badge from '../Common/Badge' ;
const messages = defineMessages ( {
status : '{status}' ,
status4k : '4K {status}' ,
} ) ;
@ -14,7 +15,7 @@ interface StatusBadgeProps {
is4k? : boolean ;
inProgress? : boolean ;
plexUrl? : string ;
plexUrl4k ?: string ;
serviceUrl ?: string ;
}
const StatusBadge : React.FC < StatusBadgeProps > = ( {
@ -22,158 +23,64 @@ const StatusBadge: React.FC<StatusBadgeProps> = ({
is4k = false ,
inProgress = false ,
plexUrl ,
plexUrl4k ,
serviceUrl ,
} ) = > {
const intl = useIntl ( ) ;
if ( is4k ) {
switch ( status ) {
case MediaStatus . AVAILABLE :
if ( plexUrl4k ) {
return (
< a href = { plexUrl4k } target = "_blank" rel = "noopener noreferrer" >
< Badge
badgeType = "success"
className = "transition !cursor-pointer hover:bg-green-400"
>
{ intl . formatMessage ( messages . status4k , {
status : intl.formatMessage ( globalMessages . available ) ,
} ) }
< / Badge >
< / a >
) ;
}
return (
< Badge badgeType = "success" >
{ intl . formatMessage ( messages . status4k , {
status : intl.formatMessage ( globalMessages . available ) ,
} ) }
< / Badge >
) ;
case MediaStatus . PARTIALLY_AVAILABLE :
if ( plexUrl4k ) {
return (
< a href = { plexUrl4k } target = "_blank" rel = "noopener noreferrer" >
< Badge
badgeType = "success"
className = "transition !cursor-pointer hover:bg-green-400"
>
{ intl . formatMessage ( messages . status4k , {
status : intl.formatMessage ( globalMessages . partiallyavailable ) ,
} ) }
< / Badge >
< / a >
) ;
}
return (
< Badge badgeType = "success" >
{ intl . formatMessage ( messages . status4k , {
status : intl.formatMessage ( globalMessages . partiallyavailable ) ,
} ) }
< / Badge >
) ;
case MediaStatus . PROCESSING :
return (
< Badge badgeType = "primary" >
< div className = "flex items-center" >
< span >
{ intl . formatMessage ( messages . status4k , {
status : inProgress
? intl . formatMessage ( globalMessages . processing )
: intl . formatMessage ( globalMessages . requested ) ,
} ) }
< / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
) ;
case MediaStatus . PENDING :
return (
< Badge badgeType = "warning" >
{ intl . formatMessage ( messages . status4k , {
status : intl.formatMessage ( globalMessages . pending ) ,
} ) }
< / Badge >
) ;
default :
return null ;
}
}
switch ( status ) {
case MediaStatus . AVAILABLE :
if ( plexUrl ) {
return (
< a href = { plexUrl } target = "_blank" rel = "noopener noreferrer" >
< Badge
badgeType = "success"
className = "transition !cursor-pointer hover:bg-green-400"
>
< div className = "flex items-center" >
< span > { intl . formatMessage ( globalMessages . available ) } < / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
< / a >
) ;
}
return (
< Badge badgeType = "success" >
< Badge badgeType = "success" url = { plexUrl } >
< div className = "flex items-center" >
< span > { intl . formatMessage ( globalMessages . available ) } < / span >
< span >
{ intl . formatMessage ( is4k ? messages.status4k : messages.status , {
status : intl.formatMessage ( globalMessages . available ) ,
} ) }
< / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
) ;
case MediaStatus . PARTIALLY_AVAILABLE :
if ( plexUrl ) {
return (
< a href = { plexUrl } target = "_blank" rel = "noopener noreferrer" >
< Badge
badgeType = "success"
className = "transition !cursor-pointer hover:bg-green-400"
>
< div className = "flex items-center" >
< span >
{ intl . formatMessage ( globalMessages . partiallyavailable ) }
< / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
< / a >
) ;
}
case MediaStatus . PARTIALLY_AVAILABLE :
return (
< Badge badgeType = "success" >
< Badge badgeType = "success" url = { plexUrl } >
< div className = "flex items-center" >
< span > { intl . formatMessage ( globalMessages . partiallyavailable ) } < / span >
< span >
{ intl . formatMessage ( is4k ? messages.status4k : messages.status , {
status : intl.formatMessage ( globalMessages . partiallyavailable ) ,
} ) }
< / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
) ;
case MediaStatus . PROCESSING :
return (
< Badge badgeType = "primary" >
< Badge badgeType = "primary" url = { serviceUrl } >
< div className = "flex items-center" >
< span >
{ inProgress
? intl . formatMessage ( globalMessages . processing )
: intl . formatMessage ( globalMessages . requested ) }
{ intl . formatMessage ( is4k ? messages.status4k : messages.status , {
status : inProgress
? intl . formatMessage ( globalMessages . processing )
: intl . formatMessage ( globalMessages . requested ) ,
} ) }
< / span >
{ inProgress && < Spinner className = "w-3 h-3 ml-1" / > }
< / div >
< / Badge >
) ;
case MediaStatus . PENDING :
return (
< Badge badgeType = "warning" >
{ intl . formatMessage ( globalMessages . pending ) }
{ intl . formatMessage ( is4k ? messages.status4k : messages.status , {
status : intl.formatMessage ( globalMessages . pending ) ,
} ) }
< / Badge >
) ;
default :
return null ;
}