diff --git a/plugin.json b/plugin.json
index 539a1a67c..31d020232 100644
--- a/plugin.json
+++ b/plugin.json
@@ -171,6 +171,12 @@
"value": "UserPrincipalName"
}
]
+ },{
+ "key": "enableRhs",
+ "display_name": "Enable RHS",
+ "type": "bool",
+ "help_text": "When true, users will be able to view RHS (right hand sidebar).",
+ "default": false
},{
"key": "appManifestDownload",
"display_name": "Download Manifest",
diff --git a/server/api.go b/server/api.go
index 1876bd1b9..7d648b9bd 100644
--- a/server/api.go
+++ b/server/api.go
@@ -95,7 +95,7 @@ func NewAPI(p *Plugin, store store.Store) *API {
router.HandleFunc("/oauth-redirect", api.oauthRedirectHandler).Methods(http.MethodGet)
router.HandleFunc("/connected-users", api.getConnectedUsers).Methods(http.MethodGet)
router.HandleFunc("/connected-users/download", api.getConnectedUsersFile).Methods(http.MethodGet)
- router.HandleFunc("/whitelist-user", api.handleAuthRequired(api.whitelistUser)).Methods(http.MethodGet)
+ router.HandleFunc("/config", api.handleAuthRequired(api.getConfig)).Methods(http.MethodGet)
channelsRouter.HandleFunc("/link", api.handleAuthRequired(api.checkUserConnected(api.linkChannels))).Methods(http.MethodPost)
channelsRouter.HandleFunc(fmt.Sprintf("/{%s}/unlink", PathParamChannelID), api.handleAuthRequired(api.unlinkChannels)).Methods(http.MethodDelete)
@@ -892,17 +892,9 @@ func (a *API) getConnectedUsersFile(w http.ResponseWriter, r *http.Request) {
}
}
-func (a *API) whitelistUser(w http.ResponseWriter, r *http.Request) {
- userID := r.Header.Get(HeaderMattermostUserID)
- presentInWhitelist, err := a.p.store.IsUserPresentInWhitelist(userID)
- if err != nil {
- a.p.API.LogError("Error in checking if a user is present in whitelist", "UserID", userID, "Error", err.Error())
- http.Error(w, "error in checking if a user is present in whitelist", http.StatusInternalServerError)
- return
- }
-
+func (a *API) getConfig(w http.ResponseWriter, _ *http.Request) {
response := map[string]bool{
- "presentInWhitelist": presentInWhitelist,
+ "rhsEnabled": a.p.getConfiguration().EnableRHS,
}
w.Header().Set("Content-Type", "application/json")
diff --git a/server/api_test.go b/server/api_test.go
index e1d800698..140da408d 100644
--- a/server/api_test.go
+++ b/server/api_test.go
@@ -1813,64 +1813,36 @@ func TestUnlinkChannels(t *testing.T) {
}
}
-func TestWhitelistUser(t *testing.T) {
+func TestGetConfig(t *testing.T) {
for _, test := range []struct {
Name string
- SetupPlugin func(*plugintest.API)
- SetupStore func(*storemocks.Store)
- SetupMetrics func(*metricsmocks.Metrics)
+ SetupPlugin func(*Plugin)
ExpectedResult string
ExpectedStatusCode int
}{
{
- Name: "WhitelistUser: unable to check user in the whitelist",
- SetupPlugin: func(api *plugintest.API) {
- api.On("LogError", "Error in checking if a user is present in whitelist", "UserID", testutils.GetUserID(), "Error", "unable to check user in the whitelist").Times(1)
- },
- SetupStore: func(store *storemocks.Store) {
- store.On("IsUserPresentInWhitelist", testutils.GetUserID()).Return(false, errors.New("unable to check user in the whitelist")).Times(1)
- },
- SetupMetrics: func(mockmetrics *metricsmocks.Metrics) {
- mockmetrics.On("IncrementHTTPErrors").Times(1)
+ Name: "RhsEnabled: rhs is enabled",
+ SetupPlugin: func(p *Plugin) {
+ p.configuration.EnableRHS = true
},
- ExpectedResult: "error in checking if a user is present in whitelist\n",
- ExpectedStatusCode: http.StatusInternalServerError,
- },
- {
- Name: "WhitelistUser: user is not present in whitelist",
- SetupPlugin: func(api *plugintest.API) {},
- SetupStore: func(store *storemocks.Store) {
- store.On("IsUserPresentInWhitelist", testutils.GetUserID()).Return(false, nil).Times(1)
- },
- SetupMetrics: func(mockmetrics *metricsmocks.Metrics) {},
- ExpectedResult: `{"presentInWhitelist":false}`,
+ ExpectedResult: `{"rhsEnabled":true}`,
ExpectedStatusCode: http.StatusOK,
},
{
- Name: "WhitelistUser: user present in whitelist",
- SetupPlugin: func(api *plugintest.API) {},
- SetupStore: func(store *storemocks.Store) {
- store.On("IsUserPresentInWhitelist", testutils.GetUserID()).Return(true, nil).Times(1)
- },
- SetupMetrics: func(mockmetrics *metricsmocks.Metrics) {},
- ExpectedResult: `{"presentInWhitelist":true}`,
+ Name: "RhsEnabled: rhs is not enabled",
+ SetupPlugin: func(p *Plugin) {},
+ ExpectedResult: `{"rhsEnabled":false}`,
ExpectedStatusCode: http.StatusOK,
},
} {
t.Run(test.Name, func(t *testing.T) {
assert := assert.New(t)
plugin := newTestPlugin(t)
- mockAPI := &plugintest.API{}
- plugin.SetAPI(mockAPI)
- defer mockAPI.AssertExpectations(t)
-
- test.SetupPlugin(mockAPI)
- test.SetupStore(plugin.store.(*storemocks.Store))
- test.SetupMetrics(plugin.metricsService.(*metricsmocks.Metrics))
+ test.SetupPlugin(plugin)
w := httptest.NewRecorder()
- r := httptest.NewRequest(http.MethodGet, "/whitelist-user", nil)
+ r := httptest.NewRequest(http.MethodGet, "/config", nil)
r.Header.Add(HeaderMattermostUserID, testutils.GetUserID())
plugin.ServeHTTP(nil, w, r)
diff --git a/server/configuration.go b/server/configuration.go
index 702775c51..1fb391bc2 100644
--- a/server/configuration.go
+++ b/server/configuration.go
@@ -41,6 +41,7 @@ type configuration struct {
SyntheticUserAuthService string `json:"syntheticUserAuthService"`
SyntheticUserAuthData string `json:"syntheticUserAuthData"`
AutomaticallyPromoteSyntheticUsers bool `json:"automaticallyPromoteSyntheticUsers"`
+ EnableRHS bool `json:"enableRhs"`
}
func (c *configuration) ProcessConfiguration() {
diff --git a/webapp/src/App.tsx b/webapp/src/App.tsx
index 4fbe1d38a..7c4a3fbda 100644
--- a/webapp/src/App.tsx
+++ b/webapp/src/App.tsx
@@ -1,30 +1,37 @@
import React, {useEffect} from 'react';
+import {Action, Store} from 'redux';
import {useDispatch} from 'react-redux';
-import usePluginApi from 'hooks/usePluginApi';
+import {GlobalState} from 'mattermost-redux/types/store';
+
+import {RhsTitle} from 'components';
-//global styles
import {pluginApiServiceConfigs} from 'constants/apiService.constant';
+import {defaultPage, defaultPerPage, pluginTitle, rhsButtonId} from 'constants/common.constants';
+import {iconUrl} from 'constants/illustrations.constants';
+
+import {Rhs} from 'containers';
+
import useApiRequestCompletionState from 'hooks/useApiRequestCompletionState';
+import usePluginApi from 'hooks/usePluginApi';
import {setConnected} from 'reducers/connectedState';
-import {defaultPage, defaultPerPage} from 'constants/common.constants';
import {setIsRhsLoading} from 'reducers/spinner';
+// global styles
import 'styles/main.scss';
/**
* This is the main App component for the plugin
* @returns {JSX.Element}
*/
-const App = (): JSX.Element => {
+const App = ({registry, store}:{registry: PluginRegistry, store: Store{mattermostChannelName}
- {mattermostTeamName}
+ {msTeamsChannelName}
- {msTeamsTeamName}
+ {mattermostChannelName}
+ {mattermostTeamName}
+ {msTeamsChannelName}
+ {msTeamsTeamName}
+
+ mockMattermostChannelName
+
+
+ mockMattermostTeamName
+
+
+ mockMSTeamsChannelName
+
+
+ mockMSTeamsTeamName
+
+