generated from Brightscout/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MI-2049]: Added websocket support to detect user connection details … (
#31) * [MI-1986]: Create plugin API to fetch linked projects list * [MI-1987]: Integrated project list UI * [MI-1987]: Review fixes * [MI-2001]: [MI-2001]: Create plugin API to unlink project and integrate the UI * [MI-2001]: Review fixes * [MI-2002]: Created plugin API to fetch user details and UI integration with other changes * [MI-2002]: Review fixes * [MI-2002]: Updated API paths * [MI-2049]: Added websocket support to detect user connection details and a centralised check for root modals * [MI-1987]: Review fix * [MI-1987]: Review fixes * [MI-2001]: Review fixes * [MI-2001]: Review fixes * [MI-2002]: Review fixes * [MI-2049]: Review fixes * [MI-2049]: Fixed merge change * [MI-2049]: Refactored code * [MI-2049]: Review fix * [MI-2049]: Review fix Co-authored-by: Abhishek Verma <[email protected]>
- Loading branch information
Showing
26 changed files
with
248 additions
and
142 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,48 @@ | ||
import React from 'react'; | ||
import React, {useEffect} from 'react'; | ||
import {useDispatch} from 'react-redux'; | ||
|
||
import Rhs from 'containers/Rhs'; | ||
import usePluginApi from 'hooks/usePluginApi'; | ||
|
||
import {getGlobalModalState, getLinkModalState} from 'selectors'; | ||
|
||
import {toggleShowLinkModal} from 'reducers/linkModal'; | ||
import {resetGlobalModalState} from 'reducers/globalModal'; | ||
|
||
// Global styles | ||
import 'styles/main.scss'; | ||
|
||
/** | ||
* Mattermost plugin allows registering only one component in RHS | ||
* So, we would be grouping all the different components inside "Rhs" component to generate one final component for registration | ||
* This is a central component for adding account connection validation on all the modals registered in the root component | ||
*/ | ||
const App = (): JSX.Element => <Rhs/>; | ||
const App = (): JSX.Element => { | ||
const usePlugin = usePluginApi(); | ||
const dispatch = useDispatch(); | ||
|
||
/** | ||
* When a command is issued on the Mattermost to open any modal | ||
* then here we first check if the user's account is connected or not | ||
* If the account is connected, we dispatch the action to open the required modal | ||
* otherwise we reset the action and don't open any modal | ||
*/ | ||
useEffect(() => { | ||
const {modalId, commandArgs} = getGlobalModalState(usePlugin.state); | ||
|
||
if (usePlugin.isUserAccountConnected() && modalId) { | ||
switch (modalId) { | ||
case 'linkProject': | ||
dispatch(toggleShowLinkModal({isVisible: true, commandArgs})); | ||
break; | ||
} | ||
} else { | ||
dispatch(resetGlobalModalState()); | ||
} | ||
}, [getGlobalModalState(usePlugin.state).modalId]); | ||
|
||
useEffect(() => { | ||
dispatch(resetGlobalModalState()); | ||
}, [getLinkModalState(usePlugin.state).visibility]); | ||
|
||
return <></>; | ||
}; | ||
|
||
export default App; |
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
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
Oops, something went wrong.