summaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/store
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/store')
-rw-r--r--server/sonar-web/src/main/js/store/marketplace/actions.ts25
-rw-r--r--server/sonar-web/src/main/js/store/marketplace/reducer.ts12
-rw-r--r--server/sonar-web/src/main/js/store/rootReducer.js3
3 files changed, 38 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/store/marketplace/actions.ts b/server/sonar-web/src/main/js/store/marketplace/actions.ts
index dfc5f8da834..894c74f2398 100644
--- a/server/sonar-web/src/main/js/store/marketplace/actions.ts
+++ b/server/sonar-web/src/main/js/store/marketplace/actions.ts
@@ -20,12 +20,18 @@
import { Dispatch } from 'react-redux';
import { getEditionsForVersion, getEditionsForLastVersion } from './utils';
import { Edition, EditionStatus, getEditionStatus, getEditionsList } from '../../api/marketplace';
+import { getPendingPlugins, PluginPendingResult } from '../../api/plugins';
interface LoadEditionsAction {
type: 'LOAD_EDITIONS';
loading: boolean;
}
+interface SetPendingPluginsAction {
+ type: 'SET_PENDING_PLUGINS';
+ pending: PluginPendingResult;
+}
+
interface SetEditionsAction {
type: 'SET_EDITIONS';
editions: Edition[];
@@ -37,12 +43,20 @@ interface SetEditionStatusAction {
status: EditionStatus;
}
-export type Action = LoadEditionsAction | SetEditionsAction | SetEditionStatusAction;
+export type Action =
+ | LoadEditionsAction
+ | SetEditionsAction
+ | SetEditionStatusAction
+ | SetPendingPluginsAction;
export function loadEditions(loading = true): LoadEditionsAction {
return { type: 'LOAD_EDITIONS', loading };
}
+export function setPendingPlugins(pending: PluginPendingResult): SetPendingPluginsAction {
+ return { type: 'SET_PENDING_PLUGINS', pending };
+}
+
export function setEditions(editions: Edition[], readOnly?: boolean): SetEditionsAction {
return { type: 'SET_EDITIONS', editions, readOnly: !!readOnly };
}
@@ -62,6 +76,15 @@ export const setEditionStatus = (status: EditionStatus) => (dispatch: Dispatch<A
}
};
+export const fetchPendingPlugins = () => (dispatch: Dispatch<Action>) => {
+ getPendingPlugins().then(
+ pending => {
+ dispatch(setPendingPlugins(pending));
+ },
+ () => {}
+ );
+};
+
export const fetchEditions = (url: string, version: string) => (dispatch: Dispatch<Action>) => {
dispatch(loadEditions(true));
getEditionsList(url).then(
diff --git a/server/sonar-web/src/main/js/store/marketplace/reducer.ts b/server/sonar-web/src/main/js/store/marketplace/reducer.ts
index 2afdef1e678..11c5e28d7f5 100644
--- a/server/sonar-web/src/main/js/store/marketplace/reducer.ts
+++ b/server/sonar-web/src/main/js/store/marketplace/reducer.ts
@@ -19,17 +19,20 @@
*/
import { Action } from './actions';
import { Edition, EditionStatus } from '../../api/marketplace';
+import { PluginPendingResult } from '../../api/plugins';
interface State {
editions?: Edition[];
loading: boolean;
status?: EditionStatus;
readOnly: boolean;
+ pending: PluginPendingResult;
}
const defaultState: State = {
loading: true,
- readOnly: false
+ readOnly: false,
+ pending: { installing: [], removing: [], updating: [] }
};
export default function(state: State = defaultState, action: Action): State {
@@ -39,6 +42,12 @@ export default function(state: State = defaultState, action: Action): State {
if (action.type === 'LOAD_EDITIONS') {
return { ...state, loading: action.loading };
}
+ if (action.type === 'SET_PENDING_PLUGINS') {
+ return {
+ ...state,
+ pending: action.pending
+ };
+ }
if (action.type === 'SET_EDITION_STATUS') {
const hasChanged = Object.keys(action.status).some(
(key: keyof EditionStatus) => !state.status || state.status[key] !== action.status[key]
@@ -53,3 +62,4 @@ export default function(state: State = defaultState, action: Action): State {
export const getEditions = (state: State) => state.editions;
export const getEditionStatus = (state: State) => state.status;
+export const getPendingPlugins = (state: State) => state.pending;
diff --git a/server/sonar-web/src/main/js/store/rootReducer.js b/server/sonar-web/src/main/js/store/rootReducer.js
index 1a8ca7d54e6..51ea1ad9971 100644
--- a/server/sonar-web/src/main/js/store/rootReducer.js
+++ b/server/sonar-web/src/main/js/store/rootReducer.js
@@ -82,6 +82,9 @@ export const getMarketplaceEditions = state => fromMarketplace.getEditions(state
export const getMarketplaceEditionStatus = state =>
fromMarketplace.getEditionStatus(state.marketplace);
+export const getMarketplacePendingPlugins = state =>
+ fromMarketplace.getPendingPlugins(state.marketplace);
+
export const getMetrics = state => fromMetrics.getMetrics(state.metrics);
export const getMetricByKey = (state, key) => fromMetrics.getMetricByKey(state.metrics, key);