mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56006] Convert ./components/discard_changes_modal.tsx from Class Component to Function Component (#25620)
* MM-56006: Converted to React FC * Update webapp/channels/src/components/discard_changes_modal.tsx Co-authored-by: Daniel Espino García <larkox@gmail.com> * lint changes --------- Co-authored-by: Daniel Espino García <larkox@gmail.com>
This commit is contained in:
parent
c008c95c93
commit
1dae805ee1
@ -12,45 +12,47 @@ type Props = {
|
||||
onCancel: (checked: boolean) => void;
|
||||
}
|
||||
|
||||
export default class DiscardChangesModal extends React.PureComponent<Props> {
|
||||
public render(): JSX.Element {
|
||||
const title: JSX.Element = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.title'
|
||||
defaultMessage='Discard Changes?'
|
||||
/>
|
||||
);
|
||||
const DiscardChangesModal = ({
|
||||
show,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
}: Props) => {
|
||||
const title = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.title'
|
||||
defaultMessage='Discard Changes?'
|
||||
/>
|
||||
);
|
||||
|
||||
const message: JSX.Element = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.message'
|
||||
defaultMessage='You have unsaved changes, are you sure you want to discard them?'
|
||||
/>
|
||||
);
|
||||
const message = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.message'
|
||||
defaultMessage='You have unsaved changes, are you sure you want to discard them?'
|
||||
/>
|
||||
);
|
||||
|
||||
const buttonClass = 'btn btn-primary';
|
||||
const button: JSX.Element = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.leave'
|
||||
defaultMessage='Yes, Discard'
|
||||
/>
|
||||
);
|
||||
const buttonClass = 'btn btn-primary';
|
||||
const button = (
|
||||
<FormattedMessage
|
||||
id='discard_changes_modal.leave'
|
||||
defaultMessage='Yes, Discard'
|
||||
/>
|
||||
);
|
||||
|
||||
const modalClass = 'discard-changes-modal';
|
||||
const modalClass = 'discard-changes-modal';
|
||||
|
||||
const {show, onConfirm, onCancel} = this.props;
|
||||
return (
|
||||
<ConfirmModal
|
||||
show={show}
|
||||
title={title}
|
||||
message={message}
|
||||
modalClass={modalClass}
|
||||
confirmButtonClass={buttonClass}
|
||||
confirmButtonText={button}
|
||||
onConfirm={onConfirm}
|
||||
onCancel={onCancel}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<ConfirmModal
|
||||
show={show}
|
||||
title={title}
|
||||
message={message}
|
||||
modalClass={modalClass}
|
||||
confirmButtonClass={buttonClass}
|
||||
confirmButtonText={button}
|
||||
onConfirm={onConfirm}
|
||||
onCancel={onCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default React.memo(DiscardChangesModal);
|
||||
|
Loading…
Reference in New Issue
Block a user