aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/marketplace
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/marketplace')
-rw-r--r--server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx25
-rw-r--r--server/sonar-web/src/main/js/apps/marketplace/__tests__/AppContainer-test.tsx9
2 files changed, 18 insertions, 16 deletions
diff --git a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx
index 7ba8b943083..379c082bfe8 100644
--- a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx
@@ -20,38 +20,47 @@
import * as React from 'react';
import { connect } from 'react-redux';
import AdminContext from '../../app/components/AdminContext';
-import { getAppState, getGlobalSettingValue, Store } from '../../store/rootReducer';
+import withAppStateContext from '../../app/components/app-state/withAppStateContext';
+import { getGlobalSettingValue, Store } from '../../store/rootReducer';
import { EditionKey } from '../../types/editions';
-import { RawQuery } from '../../types/types';
+import { AppState, RawQuery } from '../../types/types';
import App from './App';
interface OwnProps {
location: { pathname: string; query: RawQuery };
+ appState: AppState;
}
interface StateToProps {
- currentEdition?: EditionKey;
- standaloneMode?: boolean;
updateCenterActive: boolean;
}
const mapStateToProps = (state: Store) => {
const updateCenterActive = getGlobalSettingValue(state, 'sonar.updatecenter.activate');
return {
- currentEdition: getAppState(state).edition as EditionKey, // TODO: Fix once AppState is no longer ambiant.
- standaloneMode: getAppState(state).standalone,
updateCenterActive: Boolean(updateCenterActive && updateCenterActive.value === 'true')
};
};
function WithAdminContext(props: StateToProps & OwnProps) {
+ const propsToPass = {
+ location: props.location,
+ updateCenterActive: props.updateCenterActive,
+ currentEdition: props.appState.edition as EditionKey,
+ standaloneMode: props.appState.standalone
+ };
+
return (
<AdminContext.Consumer>
{({ fetchPendingPlugins, pendingPlugins }) => (
- <App fetchPendingPlugins={fetchPendingPlugins} pendingPlugins={pendingPlugins} {...props} />
+ <App
+ fetchPendingPlugins={fetchPendingPlugins}
+ pendingPlugins={pendingPlugins}
+ {...propsToPass}
+ />
)}
</AdminContext.Consumer>
);
}
-export default connect(mapStateToProps)(WithAdminContext);
+export default connect(mapStateToProps)(withAppStateContext(WithAdminContext));
diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/AppContainer-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/AppContainer-test.tsx
index fbafb1047d8..d306400526f 100644
--- a/server/sonar-web/src/main/js/apps/marketplace/__tests__/AppContainer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/AppContainer-test.tsx
@@ -19,8 +19,7 @@
*/
import { connect } from 'react-redux';
import { mockStore } from '../../../helpers/testMocks';
-import { getAppState, getGlobalSettingValue } from '../../../store/rootReducer';
-import { EditionKey } from '../../../types/editions';
+import { getGlobalSettingValue } from '../../../store/rootReducer';
import '../AppContainer';
jest.mock('react-redux', () => ({
@@ -29,7 +28,6 @@ jest.mock('react-redux', () => ({
jest.mock('../../../store/rootReducer', () => {
return {
- getAppState: jest.fn(),
getGlobalSettingValue: jest.fn()
};
});
@@ -37,10 +35,7 @@ jest.mock('../../../store/rootReducer', () => {
describe('redux', () => {
it('should correctly map state and dispatch props', () => {
const store = mockStore();
- const edition = EditionKey.developer;
- const standalone = true;
const updateCenterActive = true;
- (getAppState as jest.Mock).mockReturnValue({ edition, standalone });
(getGlobalSettingValue as jest.Mock).mockReturnValueOnce({
value: `${updateCenterActive}`
});
@@ -49,8 +44,6 @@ describe('redux', () => {
const props = mapStateToProps(store);
expect(props).toEqual({
- currentEdition: edition,
- standaloneMode: standalone,
updateCenterActive
});