diff --git a/scm-ui/src/containers/App.js b/scm-ui/src/containers/App.js index 8042611d01..86de8bb90f 100644 --- a/scm-ui/src/containers/App.js +++ b/scm-ui/src/containers/App.js @@ -19,16 +19,23 @@ import { Footer, Header } from "@scm-manager/ui-components"; -import type { Me } from "@scm-manager/ui-types"; +import type { Me, IndexResources } from "@scm-manager/ui-types"; +import { + fetchIndexResources, + getFetchIndexResourcesFailure, + isFetchIndexResourcesPending +} from "../modules/indexResource"; type Props = { me: Me, authenticated: boolean, error: Error, loading: boolean, + indexResources: IndexResources, // dispatcher functions fetchMe: () => void, + fetchIndexResources: () => void, // context props t: string => string @@ -36,6 +43,7 @@ type Props = { class App extends Component { componentDidMount() { + this.props.fetchIndexResources(); this.props.fetchMe(); } @@ -70,15 +78,18 @@ class App extends Component { const mapDispatchToProps = (dispatch: any) => { return { - fetchMe: () => dispatch(fetchMe()) + fetchMe: () => dispatch(fetchMe()), + fetchIndexResources: () => dispatch(fetchIndexResources()) }; }; const mapStateToProps = state => { const authenticated = isAuthenticated(state); const me = getMe(state); - const loading = isFetchMePending(state); - const error = getFetchMeFailure(state); + const loading = + isFetchMePending(state) || isFetchIndexResourcesPending(state); + const error = + getFetchMeFailure(state) || getFetchIndexResourcesFailure(state); return { authenticated, me, diff --git a/scm-ui/src/modules/indexResource.js b/scm-ui/src/modules/indexResource.js index 03713675f2..e9bdcc452a 100644 --- a/scm-ui/src/modules/indexResource.js +++ b/scm-ui/src/modules/indexResource.js @@ -8,7 +8,7 @@ import { getFailure } from "./failure"; // Action -export const FETCH_INDEXRESOURCES = "scm/indexResource"; +export const FETCH_INDEXRESOURCES = "scm/INDEXRESOURCES"; export const FETCH_INDEXRESOURCES_PENDING = `${FETCH_INDEXRESOURCES}_${ types.PENDING_SUFFIX }`; @@ -86,6 +86,10 @@ export function getFetchIndexResourcesFailure(state: Object) { return getFailure(state, FETCH_INDEXRESOURCES); } +export function getLinks(state: Object){ + return state.indexResources.links; +} + export function getUiPluginsLink(state: Object) { return state.indexResources.links["uiPlugins"].href; } diff --git a/scm-ui/src/modules/indexResource.test.js b/scm-ui/src/modules/indexResource.test.js index ad75c5af89..956fe0c33f 100644 --- a/scm-ui/src/modules/indexResource.test.js +++ b/scm-ui/src/modules/indexResource.test.js @@ -19,7 +19,8 @@ import reducer, { getRepositoriesLink, getHgConfigLink, getGitConfigLink, - getSvnConfigLink + getSvnConfigLink, + getLinks } from "./indexResource"; const indexResourcesUnauthenticated = { @@ -187,6 +188,15 @@ describe("index resources selectors", () => { expect(getFetchIndexResourcesFailure({})).toBe(undefined); }); + it("should return all links", () => { + const state = { + indexResources: { + links: indexResourcesAuthenticated._links + } + }; + expect(getLinks(state)).toBe(indexResourcesAuthenticated._links); + }); + // ui plugins link it("should return ui plugins link when authenticated and has permission to see it", () => { const state = {