-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): added useShowModal that passes the application to the con…
…text in showModal
- Loading branch information
Rani
committed
Jun 20, 2021
1 parent
3274330
commit 7bdb869
Showing
8 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
app/scripts/modules/core/src/managed/config/ManagementWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/scripts/modules/core/src/presentation/hooks/useShowModal.hook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { IModalProps, showModal } from '../modal'; | ||
import { IModalComponentProps } from '../modal/showModal'; | ||
import { useApplicationContext } from './useApplicationContext.hook'; | ||
|
||
export const useShowModal = () => { | ||
const app = useApplicationContext(); | ||
const showModalWithApp = React.useCallback( | ||
<P, C = any, D = any>( | ||
ModalComponent: React.ComponentType<P & IModalComponentProps<C, D>>, | ||
componentProps?: P, | ||
modalProps?: Omit<IModalProps, 'isOpen' | 'onRequestClose' | 'onAfterClose' | 'children'>, | ||
) => { | ||
showModal(ModalComponent, componentProps, modalProps, app); | ||
}, | ||
[showModal, app], | ||
); | ||
return showModalWithApp; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters