This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding admin console plugins (#2794)
* Adding admin console plugins * Adding some unit tests * Fixing tests * Fixing typos and mark the register function as low level * Moving the admin definitions selector to redux * Some extra fixes * Fixing tests * Addressing PR comments * Update plugins/index.js Co-Authored-By: Jesse Hallam <[email protected]> * Fixing tests * Addressing PR review comments * Fixing linter * Fixing linter and tests
- Loading branch information
1 parent
aa9c297
commit fa23e39
Showing
19 changed files
with
230 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import * as Actions from 'actions/admin_actions.jsx'; | ||
import configureStore from 'store'; | ||
|
||
describe('Actions.Admin', () => { | ||
let store; | ||
beforeEach(async () => { | ||
store = await configureStore(); | ||
}); | ||
|
||
test('Register a plugin adds the plugin to the state', async () => { | ||
const func = jest.fn(); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({}); | ||
store.dispatch(Actions.registerAdminConsolePlugin('plugin-id', func)); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({'plugin-id': func}); | ||
}); | ||
|
||
test('Unregister a plugin removes an existing plugin from the state', async () => { | ||
const func = jest.fn(); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({}); | ||
store.dispatch(Actions.registerAdminConsolePlugin('plugin-id', func)); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({'plugin-id': func}); | ||
|
||
store.dispatch(Actions.unregisterAdminConsolePlugin('plugin-id')); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({}); | ||
}); | ||
|
||
test('Unregister an unexisting plugin do nothing', async () => { | ||
const func = jest.fn(); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({}); | ||
store.dispatch(Actions.registerAdminConsolePlugin('plugin-id', func)); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({'plugin-id': func}); | ||
|
||
store.dispatch(Actions.unregisterAdminConsolePlugin('invalid-plugin-id')); | ||
expect(store.getState().plugins.adminConsoleReducers).toEqual({'plugin-id': func}); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {createSelector} from 'reselect'; | ||
import {cloneDeep} from 'lodash'; | ||
|
||
import AdminDefinition from 'components/admin_console/admin_definition.jsx'; | ||
|
||
export const getAdminDefinition = createSelector( | ||
() => AdminDefinition, | ||
(state) => state.plugins.adminConsoleReducers, | ||
(adminDefinition, reducers) => { | ||
let result = cloneDeep(AdminDefinition); | ||
for (const reducer of Object.values(reducers)) { | ||
result = reducer(result); | ||
} | ||
return result; | ||
} | ||
); |
Oops, something went wrong.