mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56850] Convert ./components/modal_controller/modal_controller.tsx
from Class Component to Function Component (#26259)
* [MM-56850] Convert `./components/modal_controller/modal_controller.tsx` from Class Component to Function Component * fix: failing type check
This commit is contained in:
parent
782f81d22f
commit
48117fb21f
@ -32,39 +32,38 @@ type Props = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ModalController extends React.PureComponent<Props> {
|
const ModalController = ({
|
||||||
public render(): React.ReactNode {
|
modals,
|
||||||
const {modals, ...props} = this.props;
|
actions,
|
||||||
const {modalState} = modals;
|
}: Props) => {
|
||||||
|
if (!modals) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!modals) {
|
const {modalState} = modals;
|
||||||
return null;
|
const modalOutput = [];
|
||||||
}
|
|
||||||
|
|
||||||
const modalOutput = [];
|
for (const modalId in modalState) {
|
||||||
|
if (modalState.hasOwnProperty(modalId)) {
|
||||||
|
const modal = modalState[modalId];
|
||||||
|
if (modal.open) {
|
||||||
|
const modalComponent = React.createElement(modal.dialogType, Object.assign({}, modal.dialogProps, {
|
||||||
|
onExited: () => {
|
||||||
|
actions.closeModal(modalId);
|
||||||
|
|
||||||
for (const modalId in modalState) {
|
// Call any onExited prop provided by whoever opened the modal, if one was provided
|
||||||
if (modalState.hasOwnProperty(modalId)) {
|
modal.dialogProps?.onExited?.();
|
||||||
const modal = modalState[modalId];
|
},
|
||||||
if (modal.open) {
|
onHide: actions.closeModal.bind(this, modalId),
|
||||||
const modalComponent = React.createElement(modal.dialogType, Object.assign({}, modal.dialogProps, {
|
key: `${modalId}_modal`,
|
||||||
onExited: () => {
|
}));
|
||||||
props.actions.closeModal(modalId);
|
|
||||||
|
|
||||||
// Call any onExited prop provided by whoever opened the modal, if one was provided
|
modalOutput.push(modalComponent);
|
||||||
modal.dialogProps?.onExited?.();
|
|
||||||
},
|
|
||||||
onHide: props.actions.closeModal.bind(this, modalId),
|
|
||||||
key: `${modalId}_modal`,
|
|
||||||
}));
|
|
||||||
|
|
||||||
modalOutput.push(modalComponent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
|
||||||
modalOutput
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return <>{modalOutput}</>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ModalController;
|
||||||
|
Loading…
Reference in New Issue
Block a user