use index resources for groups

This commit is contained in:
Maren Süwer
2018-10-09 16:17:25 +02:00
parent ff5e7e6dbb
commit b93da611cd
9 changed files with 112 additions and 69 deletions

View File

@@ -6,7 +6,6 @@ import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
import { Dispatch } from "redux";
import type { Config } from "@scm-manager/ui-types";
import { getConfigLink } from "../../modules/indexResource";
export const FETCH_CONFIG = "scm/config/FETCH_CONFIG";
export const FETCH_CONFIG_PENDING = `${FETCH_CONFIG}_${types.PENDING_SUFFIX}`;
@@ -22,11 +21,11 @@ export const MODIFY_CONFIG_RESET = `${MODIFY_CONFIG}_${types.RESET_SUFFIX}`;
const CONTENT_TYPE_CONFIG = "application/vnd.scmm-config+json;v=2";
//fetch config
export function fetchConfig() {
return function(dispatch: any, getState: any) {
export function fetchConfig(link: string) {
return function(dispatch: any) {
dispatch(fetchConfigPending());
return apiClient
.get(getConfigLink(getState()))
.get(link)
.then(response => {
return response.json();
})

View File

@@ -125,7 +125,7 @@ describe("config fetch()", () => {
}
});
return store.dispatch(fetchConfig()).then(() => {
return store.dispatch(fetchConfig(CONFIG_URL)).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
@@ -144,7 +144,7 @@ describe("config fetch()", () => {
}
}
});
return store.dispatch(fetchConfig()).then(() => {
return store.dispatch(fetchConfig(CONFIG_URL)).then(() => {
const actions = store.getActions();
expect(actions[0].type).toEqual(FETCH_CONFIG_PENDING);
expect(actions[1].type).toEqual(FETCH_CONFIG_FAILURE);