Files
jitsi-meet/react/features/base/react/components/web/InlineDialogFailure.tsx

89 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-04-20 14:00:42 +03:00
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
2023-04-20 14:00:42 +03:00
import { makeStyles } from 'tss-react/mui';
2017-06-14 13:41:22 -05:00
import Button from '../../../ui/components/web/Button';
import { getSupportUrl } from '../../functions';
2023-04-20 14:00:42 +03:00
const useStyles = makeStyles()(theme => {
return {
dialog: {
backgroundColor: theme.palette.ui01,
border: `1px solid ${theme.palette.ui04}`,
borderRadius: `${Number(theme.shape.borderRadius)}px`,
boxShadow: '0px 1px 2px rgba(41, 41, 41, 0.25)',
color: theme.palette.text01,
...theme.typography.bodyShortRegular,
2023-04-20 14:00:42 +03:00
padding: `${theme.spacing(3)} 10`,
'& .retry-button': {
margin: '16px auto 0 auto'
}
}
};
});
2017-06-14 13:41:22 -05:00
/**
* The type of the React {@code Component} props of {@link InlineDialogFailure}.
2017-06-14 13:41:22 -05:00
*/
2023-04-20 14:00:42 +03:00
interface IProps {
2017-06-14 13:41:22 -05:00
/**
* Allows to retry the call that previously didn't succeed.
2017-06-14 13:41:22 -05:00
*/
onRetry: Function;
/**
2021-11-04 22:10:43 +01:00
* Indicates whether the support link should be shown in case of an error.
*/
showSupportLink: Boolean;
}
/**
* Inline dialog that represents a failure and allows a retry.
2023-04-20 14:00:42 +03:00
*
* @returns {Element}
*/
2023-04-20 14:00:42 +03:00
const InlineDialogFailure = ({
onRetry,
showSupportLink
}: IProps) => {
const { t } = useTranslation();
const { classes } = useStyles();
2017-06-14 13:41:22 -05:00
const supportLink = useSelector(getSupportUrl);
2023-04-20 14:00:42 +03:00
const supportString = t('inlineDialogFailure.supportMsg');
const supportLinkElem = supportLink && showSupportLink
? (
<div>
<span>{ supportString.padEnd(supportString.length + 1) }
</span>
<span>
<a
href = { supportLink }
rel = 'noopener noreferrer'
target = '_blank'>
{ t('inlineDialogFailure.support') }
</a>
</span>
<span>.</span>
</div>
)
: null;
2017-06-14 13:41:22 -05:00
2023-04-20 14:00:42 +03:00
return (
<div className = { classes.dialog }>
<div>
{ t('inlineDialogFailure.msg') }
2017-06-14 13:41:22 -05:00
</div>
2023-04-20 14:00:42 +03:00
{ supportLinkElem }
<Button
className = 'retry-button'
label = { t('inlineDialogFailure.retry') }
onClick = { onRetry } />
</div>
);
};
2017-06-14 13:41:22 -05:00
2023-04-20 14:00:42 +03:00
export default InlineDialogFailure;