fixed changeset urls without slash at the end

This commit is contained in:
Sebastian Sdorra
2018-10-18 11:13:14 +02:00
parent 4f647cb9e9
commit 978af39c43
4 changed files with 58 additions and 47 deletions

View File

@@ -5,7 +5,7 @@ import {
PENDING_SUFFIX,
SUCCESS_SUFFIX
} from "../../modules/types";
import { apiClient } from "@scm-manager/ui-components";
import { apiClient, urls } from "@scm-manager/ui-components";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
import type {
@@ -20,20 +20,14 @@ export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
export const FETCH_CHANGESETS_SUCCESS = `${FETCH_CHANGESETS}_${SUCCESS_SUFFIX}`;
export const FETCH_CHANGESETS_FAILURE = `${FETCH_CHANGESETS}_${FAILURE_SUFFIX}`;
//********added for detailed view of changesets
export const FETCH_CHANGESET = "scm/repos/FETCH_CHANGESET";
export const FETCH_CHANGESET_PENDING = `${FETCH_CHANGESET}_${PENDING_SUFFIX}`;
export const FETCH_CHANGESET_SUCCESS = `${FETCH_CHANGESET}_${SUCCESS_SUFFIX}`;
export const FETCH_CHANGESET_FAILURE = `${FETCH_CHANGESET}_${FAILURE_SUFFIX}`;
//********end of detailed view add
// actions
//TODO: Content type
//********added for detailed view of changesets
export function fetchChangesetIfNeeded(repository: Repository, id: string) {
return (dispatch: any, getState: any) => {
if (shouldFetchChangeset(getState(), repository, id)) {
@@ -46,7 +40,7 @@ export function fetchChangeset(repository: Repository, id: string) {
return function(dispatch: any) {
dispatch(fetchChangesetPending(repository, id));
return apiClient
.get(repository._links.changesets.href + id)
.get(createChangesetUrl(repository, id))
.then(response => response.json())
.then(data => dispatch(fetchChangesetSuccess(data, repository, id)))
.catch(err => {
@@ -55,6 +49,10 @@ export function fetchChangeset(repository: Repository, id: string) {
};
}
function createChangesetUrl(repository: Repository, id: string) {
return urls.concat(repository._links.changesets.href, id);
}
export function fetchChangesetPending(
repository: Repository,
id: string
@@ -93,8 +91,6 @@ function fetchChangesetFailure(
};
}
//********end of detailed view add
export function fetchChangesets(
repository: Repository,
branch?: Branch,
@@ -266,21 +262,6 @@ function extractChangesetsByIds(changesets: any) {
return changesetsByIds;
}
//********added for detailed view of changesets
function addChangesetToChangesets(data: any, oldChangesetsByIds: any) {
const changeset = data;
const changesetsByIds = {};
changesetsByIds[changeset.id] = changeset;
for (let id in oldChangesetsByIds) {
changesetsByIds[id] = oldChangesetsByIds[id];
}
return changesetsByIds;
}
//********end of added for detailed view of changesets
//selectors
export function getChangesets(
@@ -291,15 +272,15 @@ export function getChangesets(
const key = createItemId(repository, branch);
const changesets = state.changesets[key];
if (!changesets) {
if (!changesets || !changesets.list) {
return null;
}
return changesets.list.entries.map((id: string) => {
return changesets.byId[id];
});
}
//********added for detailed view of changesets
export function getChangeset(
state: Object,
repository: Repository,
@@ -350,7 +331,6 @@ export function getFetchChangesetFailure(
createChangesetItemId(repository, id)
);
}
//********end of added for detailed view of changesets
export function isFetchChangesetsPending(
state: Object,