The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/ConfirmOwnerChangeWarningMo...

81 lines
2.2 KiB

import { Box } from '@rocket.chat/fuselage';
import React, { FC } from 'react';
import { useTranslation } from '../contexts/TranslationContext';
import GenericModal from './GenericModal';
import RawText from './RawText';
type ConfirmOwnerChangeWarningModalProps = {
onConfirm: () => void;
onCancel: () => void;
shouldChangeOwner: Array<string>;
shouldBeRemoved: Array<string>;
contentTitle: string;
confirmLabel: string;
};
const ConfirmOwnerChangeWarningModal: FC<ConfirmOwnerChangeWarningModalProps> = ({
onConfirm,
onCancel,
contentTitle = '',
confirmLabel = '',
shouldChangeOwner,
shouldBeRemoved,
}) => {
const t = useTranslation();
let changeOwnerRooms = '';
if (shouldChangeOwner.length > 0) {
if (shouldChangeOwner.length === 1) {
changeOwnerRooms = t('A_new_owner_will_be_assigned_automatically_to_the__roomName__room', {
roomName: shouldChangeOwner.pop(),
});
} else if (shouldChangeOwner.length <= 5) {
changeOwnerRooms = t('A_new_owner_will_be_assigned_automatically_to_those__count__rooms__rooms__', {
count: shouldChangeOwner.length,
rooms: shouldChangeOwner.join(', '),
});
} else {
changeOwnerRooms = t('A_new_owner_will_be_assigned_automatically_to__count__rooms', {
count: shouldChangeOwner.length,
});
}
}
let removedRooms = '';
if (shouldBeRemoved.length > 0) {
if (shouldBeRemoved.length === 1) {
removedRooms = t('The_empty_room__roomName__will_be_removed_automatically', {
roomName: shouldBeRemoved.pop(),
});
} else if (shouldBeRemoved.length <= 5) {
removedRooms = t('__count__empty_rooms_will_be_removed_automatically__rooms__', {
count: shouldBeRemoved.length,
rooms: shouldBeRemoved.join(', '),
});
} else {
removedRooms = t('__count__empty_rooms_will_be_removed_automatically', {
count: shouldBeRemoved.length,
});
}
}
return (
<GenericModal variant='danger' onClose={onCancel} onCancel={onCancel} confirmText={confirmLabel} onConfirm={onConfirm}>
{contentTitle}
{changeOwnerRooms && (
<Box marginBlock='x16'>
<RawText>{changeOwnerRooms}</RawText>
</Box>
)}
{removedRooms && (
<Box marginBlock='x16'>
<RawText>{removedRooms}</RawText>
</Box>
)}
</GenericModal>
);
};
export default ConfirmOwnerChangeWarningModal;