apply prettier, removed flow related config and added tsconfig

This commit is contained in:
Sebastian Sdorra
2019-10-20 18:02:52 +02:00
parent 0e017dcadd
commit 490418d06e
231 changed files with 5771 additions and 30386 deletions

View File

@@ -1,6 +1,6 @@
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import fetchMock from 'fetch-mock';
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
import fetchMock from "fetch-mock";
import reducer, {
FETCH_CHANGESET,
FETCH_CHANGESET_FAILURE,
@@ -22,46 +22,46 @@ import reducer, {
isFetchChangesetPending,
isFetchChangesetsPending,
selectListAsCollection,
shouldFetchChangeset,
} from './changesets';
shouldFetchChangeset
} from "./changesets";
const branch = {
name: 'specific',
revision: '123',
name: "specific",
revision: "123",
_links: {
history: {
href:
'http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets',
},
},
"http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets"
}
}
};
const repository = {
namespace: 'foo',
name: 'bar',
type: 'GIT',
namespace: "foo",
name: "bar",
type: "GIT",
_links: {
self: {
href: 'http://scm.hitchhicker.com/api/v2/repositories/foo/bar',
href: "http://scm.hitchhicker.com/api/v2/repositories/foo/bar"
},
changesets: {
href: 'http://scm.hitchhicker.com/api/v2/repositories/foo/bar/changesets',
href: "http://scm.hitchhicker.com/api/v2/repositories/foo/bar/changesets"
},
branches: {
href:
'http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/branches',
},
},
"http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/branches"
}
}
};
const changesets = {};
describe('changesets', () => {
describe('fetching of changesets', () => {
describe("changesets", () => {
describe("fetching of changesets", () => {
const DEFAULT_BRANCH_URL =
'http://scm.hitchhicker.com/api/v2/repositories/foo/bar/changesets';
"http://scm.hitchhicker.com/api/v2/repositories/foo/bar/changesets";
const SPECIFIC_BRANCH_URL =
'http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets';
"http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets";
const mockStore = configureMockStore([thunk]);
@@ -70,25 +70,25 @@ describe('changesets', () => {
fetchMock.restore();
});
const changesetId = 'aba876c0625d90a6aff1494f3d161aaa7008b958';
const changesetId = "aba876c0625d90a6aff1494f3d161aaa7008b958";
it('should fetch changeset', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + '/' + changesetId, '{}');
it("should fetch changeset", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + "/" + changesetId, "{}");
const expectedActions = [
{
type: FETCH_CHANGESET_PENDING,
itemId: 'foo/bar/' + changesetId,
itemId: "foo/bar/" + changesetId
},
{
type: FETCH_CHANGESET_SUCCESS,
payload: {
changeset: {},
id: changesetId,
repository: repository,
repository: repository
},
itemId: 'foo/bar/' + changesetId,
},
itemId: "foo/bar/" + changesetId
}
];
const store = mockStore({});
@@ -99,14 +99,14 @@ describe('changesets', () => {
});
});
it('should fail fetching changeset on error', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + '/' + changesetId, 500);
it("should fail fetching changeset on error", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + "/" + changesetId, 500);
const expectedActions = [
{
type: FETCH_CHANGESET_PENDING,
itemId: 'foo/bar/' + changesetId,
},
itemId: "foo/bar/" + changesetId
}
];
const store = mockStore({});
@@ -119,74 +119,74 @@ describe('changesets', () => {
});
});
it('should fetch changeset if needed', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + '/id3', '{}');
it("should fetch changeset if needed", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + "/id3", "{}");
const expectedActions = [
{
type: FETCH_CHANGESET_PENDING,
itemId: 'foo/bar/id3',
itemId: "foo/bar/id3"
},
{
type: FETCH_CHANGESET_SUCCESS,
payload: {
changeset: {},
id: 'id3',
repository: repository,
id: "id3",
repository: repository
},
itemId: 'foo/bar/id3',
},
itemId: "foo/bar/id3"
}
];
const store = mockStore({});
return store
.dispatch(fetchChangesetIfNeeded(repository, 'id3'))
.dispatch(fetchChangesetIfNeeded(repository, "id3"))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
it('should not fetch changeset if not needed', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + '/id1', 500);
it("should not fetch changeset if not needed", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + "/id1", 500);
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id1: {
id: 'id1',
id: "id1"
},
id2: {
id: 'id2',
},
},
},
},
id: "id2"
}
}
}
}
};
const store = mockStore(state);
return expect(
store.dispatch(fetchChangesetIfNeeded(repository, 'id1')),
store.dispatch(fetchChangesetIfNeeded(repository, "id1"))
).toEqual(undefined);
});
it('should fetch changesets for default branch', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL, '{}');
it("should fetch changesets for default branch", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL, "{}");
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId: 'foo/bar',
itemId: "foo/bar"
},
{
type: FETCH_CHANGESETS_SUCCESS,
payload: {
repository,
undefined,
changesets,
changesets
},
itemId: 'foo/bar',
},
itemId: "foo/bar"
}
];
const store = mockStore({});
@@ -195,24 +195,24 @@ describe('changesets', () => {
});
});
it('should fetch changesets for specific branch', () => {
const itemId = 'foo/bar/specific';
fetchMock.getOnce(SPECIFIC_BRANCH_URL, '{}');
it("should fetch changesets for specific branch", () => {
const itemId = "foo/bar/specific";
fetchMock.getOnce(SPECIFIC_BRANCH_URL, "{}");
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId,
itemId
},
{
type: FETCH_CHANGESETS_SUCCESS,
payload: {
repository,
branch,
changesets,
changesets
},
itemId,
},
itemId
}
];
const store = mockStore({});
@@ -221,15 +221,15 @@ describe('changesets', () => {
});
});
it('should fail fetching changesets on error', () => {
const itemId = 'foo/bar';
it("should fail fetching changesets on error", () => {
const itemId = "foo/bar";
fetchMock.getOnce(DEFAULT_BRANCH_URL, 500);
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId,
},
itemId
}
];
const store = mockStore({});
@@ -240,15 +240,15 @@ describe('changesets', () => {
});
});
it('should fail fetching changesets for specific branch on error', () => {
const itemId = 'foo/bar/specific';
it("should fail fetching changesets for specific branch on error", () => {
const itemId = "foo/bar/specific";
fetchMock.getOnce(SPECIFIC_BRANCH_URL, 500);
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId,
},
itemId
}
];
const store = mockStore({});
@@ -259,23 +259,23 @@ describe('changesets', () => {
});
});
it('should fetch changesets by page', () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + '?page=4', '{}');
it("should fetch changesets by page", () => {
fetchMock.getOnce(DEFAULT_BRANCH_URL + "?page=4", "{}");
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId: 'foo/bar',
itemId: "foo/bar"
},
{
type: FETCH_CHANGESETS_SUCCESS,
payload: {
repository,
undefined,
changesets,
changesets
},
itemId: 'foo/bar',
},
itemId: "foo/bar"
}
];
const store = mockStore({});
@@ -286,23 +286,23 @@ describe('changesets', () => {
});
});
it('should fetch changesets by branch and page', () => {
fetchMock.getOnce(SPECIFIC_BRANCH_URL + '?page=4', '{}');
it("should fetch changesets by branch and page", () => {
fetchMock.getOnce(SPECIFIC_BRANCH_URL + "?page=4", "{}");
const expectedActions = [
{
type: FETCH_CHANGESETS_PENDING,
itemId: 'foo/bar/specific',
itemId: "foo/bar/specific"
},
{
type: FETCH_CHANGESETS_SUCCESS,
payload: {
repository,
branch,
changesets,
changesets
},
itemId: 'foo/bar/specific',
},
itemId: "foo/bar/specific"
}
];
const store = mockStore({});
@@ -312,7 +312,7 @@ describe('changesets', () => {
});
});
describe('changesets reducer', () => {
describe("changesets reducer", () => {
const responseBody = {
page: 1,
pageTotal: 10,
@@ -320,354 +320,354 @@ describe('changesets', () => {
_embedded: {
changesets: [
{
id: 'changeset1',
id: "changeset1",
author: {
mail: 'z@phod.com',
name: 'zaphod',
},
mail: "z@phod.com",
name: "zaphod"
}
},
{
id: 'changeset2',
description: 'foo',
id: "changeset2",
description: "foo"
},
{
id: 'changeset3',
description: 'bar',
},
id: "changeset3",
description: "bar"
}
],
_embedded: {
tags: [],
branches: [],
parents: [],
},
},
parents: []
}
}
};
it('should set state to received changesets', () => {
it("should set state to received changesets", () => {
const newState = reducer(
{},
fetchChangesetsSuccess(repository, undefined, responseBody),
fetchChangesetsSuccess(repository, undefined, responseBody)
);
expect(newState).toBeDefined();
expect(newState['foo/bar'].byId['changeset1'].author.mail).toEqual(
'z@phod.com',
expect(newState["foo/bar"].byId["changeset1"].author.mail).toEqual(
"z@phod.com"
);
expect(newState['foo/bar'].byId['changeset2'].description).toEqual('foo');
expect(newState['foo/bar'].byId['changeset3'].description).toEqual('bar');
expect(newState['foo/bar'].byBranch['']).toEqual({
expect(newState["foo/bar"].byId["changeset2"].description).toEqual("foo");
expect(newState["foo/bar"].byId["changeset3"].description).toEqual("bar");
expect(newState["foo/bar"].byBranch[""]).toEqual({
entry: {
page: 1,
pageTotal: 10,
_links: {},
_links: {}
},
entries: ['changeset1', 'changeset2', 'changeset3'],
entries: ["changeset1", "changeset2", "changeset3"]
});
});
it('should store the changeset list to branch', () => {
it("should store the changeset list to branch", () => {
const newState = reducer(
{},
fetchChangesetsSuccess(repository, branch, responseBody),
fetchChangesetsSuccess(repository, branch, responseBody)
);
expect(newState['foo/bar'].byId['changeset1']).toBeDefined();
expect(newState['foo/bar'].byBranch['specific'].entries).toEqual([
'changeset1',
'changeset2',
'changeset3',
expect(newState["foo/bar"].byId["changeset1"]).toBeDefined();
expect(newState["foo/bar"].byBranch["specific"].entries).toEqual([
"changeset1",
"changeset2",
"changeset3"
]);
});
it('should not remove existing changesets', () => {
it("should not remove existing changesets", () => {
const state = {
'foo/bar': {
"foo/bar": {
byId: {
id2: {
id: 'id2',
id: "id2"
},
id1: {
id: 'id1',
},
id: "id1"
}
},
byBranch: {
'': {
entries: ['id1', 'id2'],
},
},
},
"": {
entries: ["id1", "id2"]
}
}
}
};
const newState = reducer(
state,
fetchChangesetsSuccess(repository, undefined, responseBody),
fetchChangesetsSuccess(repository, undefined, responseBody)
);
const fooBar = newState['foo/bar'];
const fooBar = newState["foo/bar"];
expect(fooBar.byBranch[''].entries).toEqual([
'changeset1',
'changeset2',
'changeset3',
expect(fooBar.byBranch[""].entries).toEqual([
"changeset1",
"changeset2",
"changeset3"
]);
expect(fooBar.byId['id2']).toEqual({
id: 'id2',
expect(fooBar.byId["id2"]).toEqual({
id: "id2"
});
expect(fooBar.byId['id1']).toEqual({
id: 'id1',
expect(fooBar.byId["id1"]).toEqual({
id: "id1"
});
});
const responseBodySingleChangeset = {
id: 'id3',
id: "id3",
author: {
mail: 'z@phod.com',
name: 'zaphod',
mail: "z@phod.com",
name: "zaphod"
},
date: '2018-09-13T08:46:22Z',
description: 'added testChangeset',
date: "2018-09-13T08:46:22Z",
description: "added testChangeset",
_links: {},
_embedded: {
tags: [],
branches: [],
},
branches: []
}
};
it('should add changeset to state', () => {
it("should add changeset to state", () => {
const newState = reducer(
{
'foo/bar': {
"foo/bar": {
byId: {
id2: {
id: 'id2',
id: "id2",
author: {
mail: 'mail@author.com',
name: 'author',
},
},
mail: "mail@author.com",
name: "author"
}
}
},
list: {
entry: {
page: 1,
pageTotal: 10,
_links: {},
_links: {}
},
entries: ['id2'],
},
},
entries: ["id2"]
}
}
},
fetchChangesetSuccess(responseBodySingleChangeset, repository, 'id3'),
fetchChangesetSuccess(responseBodySingleChangeset, repository, "id3")
);
expect(newState).toBeDefined();
expect(newState['foo/bar'].byId['id3'].description).toEqual(
'added testChangeset',
expect(newState["foo/bar"].byId["id3"].description).toEqual(
"added testChangeset"
);
expect(newState['foo/bar'].byId['id3'].author.mail).toEqual('z@phod.com');
expect(newState['foo/bar'].byId['id2']).toBeDefined();
expect(newState['foo/bar'].byId['id3']).toBeDefined();
expect(newState['foo/bar'].list).toEqual({
expect(newState["foo/bar"].byId["id3"].author.mail).toEqual("z@phod.com");
expect(newState["foo/bar"].byId["id2"]).toBeDefined();
expect(newState["foo/bar"].byId["id3"]).toBeDefined();
expect(newState["foo/bar"].list).toEqual({
entry: {
page: 1,
pageTotal: 10,
_links: {},
_links: {}
},
entries: ['id2'],
entries: ["id2"]
});
});
});
describe('changeset selectors', () => {
const error = new Error('Something went wrong');
describe("changeset selectors", () => {
const error = new Error("Something went wrong");
it('should return changeset', () => {
it("should return changeset", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id1: {
id: 'id1',
id: "id1"
},
id2: {
id: 'id2',
},
},
},
},
id: "id2"
}
}
}
}
};
const result = getChangeset(state, repository, 'id1');
const result = getChangeset(state, repository, "id1");
expect(result).toEqual({
id: 'id1',
id: "id1"
});
});
it('should return null if changeset does not exist', () => {
it("should return null if changeset does not exist", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id1: {
id: 'id1',
id: "id1"
},
id2: {
id: 'id2',
},
},
},
},
id: "id2"
}
}
}
}
};
const result = getChangeset(state, repository, 'id3');
const result = getChangeset(state, repository, "id3");
expect(result).toEqual(null);
});
it('should return true if changeset does not exist', () => {
it("should return true if changeset does not exist", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id1: {
id: 'id1',
id: "id1"
},
id2: {
id: 'id2',
},
},
},
},
id: "id2"
}
}
}
}
};
const result = shouldFetchChangeset(state, repository, 'id3');
const result = shouldFetchChangeset(state, repository, "id3");
expect(result).toEqual(true);
});
it('should return false if changeset exists', () => {
it("should return false if changeset exists", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id1: {
id: 'id1',
id: "id1"
},
id2: {
id: 'id2',
},
},
},
},
id: "id2"
}
}
}
}
};
const result = shouldFetchChangeset(state, repository, 'id2');
const result = shouldFetchChangeset(state, repository, "id2");
expect(result).toEqual(false);
});
it('should return true, when fetching changeset is pending', () => {
it("should return true, when fetching changeset is pending", () => {
const state = {
pending: {
[FETCH_CHANGESET + '/foo/bar/id1']: true,
},
[FETCH_CHANGESET + "/foo/bar/id1"]: true
}
};
expect(isFetchChangesetPending(state, repository, 'id1')).toBeTruthy();
expect(isFetchChangesetPending(state, repository, "id1")).toBeTruthy();
});
it('should return false, when fetching changeset is not pending', () => {
expect(isFetchChangesetPending({}, repository, 'id1')).toEqual(false);
it("should return false, when fetching changeset is not pending", () => {
expect(isFetchChangesetPending({}, repository, "id1")).toEqual(false);
});
it('should return error if fetching changeset failed', () => {
it("should return error if fetching changeset failed", () => {
const state = {
failure: {
[FETCH_CHANGESET + '/foo/bar/id1']: error,
},
[FETCH_CHANGESET + "/foo/bar/id1"]: error
}
};
expect(getFetchChangesetFailure(state, repository, 'id1')).toEqual(error);
expect(getFetchChangesetFailure(state, repository, "id1")).toEqual(error);
});
it('should return false if fetching changeset did not fail', () => {
expect(getFetchChangesetFailure({}, repository, 'id1')).toBeUndefined();
it("should return false if fetching changeset did not fail", () => {
expect(getFetchChangesetFailure({}, repository, "id1")).toBeUndefined();
});
it('should get all changesets for a given repository', () => {
it("should get all changesets for a given repository", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id2: {
id: 'id2',
id: "id2"
},
id1: {
id: 'id1',
},
id: "id1"
}
},
byBranch: {
'': {
entries: ['id1', 'id2'],
},
},
},
},
"": {
entries: ["id1", "id2"]
}
}
}
}
};
const result = getChangesets(state, repository);
expect(result).toEqual([
{
id: 'id1',
id: "id1"
},
{
id: 'id2',
},
id: "id2"
}
]);
});
it('should return true, when fetching changesets is pending', () => {
it("should return true, when fetching changesets is pending", () => {
const state = {
pending: {
[FETCH_CHANGESETS + '/foo/bar']: true,
},
[FETCH_CHANGESETS + "/foo/bar"]: true
}
};
expect(isFetchChangesetsPending(state, repository)).toBeTruthy();
});
it('should return false, when fetching changesets is not pending', () => {
it("should return false, when fetching changesets is not pending", () => {
expect(isFetchChangesetsPending({}, repository)).toEqual(false);
});
it('should return error if fetching changesets failed', () => {
it("should return error if fetching changesets failed", () => {
const state = {
failure: {
[FETCH_CHANGESETS + '/foo/bar']: error,
},
[FETCH_CHANGESETS + "/foo/bar"]: error
}
};
expect(getFetchChangesetsFailure(state, repository)).toEqual(error);
});
it('should return false if fetching changesets did not fail', () => {
it("should return false if fetching changesets did not fail", () => {
expect(getFetchChangesetsFailure({}, repository)).toBeUndefined();
});
it('should return list as collection for the default branch', () => {
it("should return list as collection for the default branch", () => {
const state = {
changesets: {
'foo/bar': {
"foo/bar": {
byId: {
id2: {
id: 'id2',
id: "id2"
},
id1: {
id: 'id1',
},
id: "id1"
}
},
byBranch: {
'': {
"": {
entry: {
page: 1,
pageTotal: 10,
_links: {},
_links: {}
},
entries: ['id1', 'id2'],
},
},
},
},
entries: ["id1", "id2"]
}
}
}
}
};
const collection = selectListAsCollection(state, repository);

View File

@@ -1,24 +1,24 @@
import {
FAILURE_SUFFIX,
PENDING_SUFFIX,
SUCCESS_SUFFIX,
} from '../../modules/types';
import { apiClient, urls } from '@scm-manager/ui-components';
import { isPending } from '../../modules/pending';
import { getFailure } from '../../modules/failure';
SUCCESS_SUFFIX
} from "../../modules/types";
import { apiClient, urls } from "@scm-manager/ui-components";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
import {
Action,
Branch,
PagedCollection,
Repository,
} from '@scm-manager/ui-types';
Repository
} from "@scm-manager/ui-types";
export const FETCH_CHANGESETS = 'scm/repos/FETCH_CHANGESETS';
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
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}`;
export const FETCH_CHANGESET = 'scm/repos/FETCH_CHANGESET';
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}`;
@@ -53,50 +53,50 @@ function createChangesetUrl(repository: Repository, id: string) {
export function fetchChangesetPending(
repository: Repository,
id: string,
id: string
): Action {
return {
type: FETCH_CHANGESET_PENDING,
itemId: createChangesetItemId(repository, id),
itemId: createChangesetItemId(repository, id)
};
}
export function fetchChangesetSuccess(
changeset: any,
repository: Repository,
id: string,
id: string
): Action {
return {
type: FETCH_CHANGESET_SUCCESS,
payload: {
changeset,
repository,
id,
id
},
itemId: createChangesetItemId(repository, id),
itemId: createChangesetItemId(repository, id)
};
}
function fetchChangesetFailure(
repository: Repository,
id: string,
error: Error,
error: Error
): Action {
return {
type: FETCH_CHANGESET_FAILURE,
payload: {
repository,
id,
error,
error
},
itemId: createChangesetItemId(repository, id),
itemId: createChangesetItemId(repository, id)
};
}
export function fetchChangesets(
repository: Repository,
branch?: Branch,
page?: number,
page?: number
) {
const link = createChangesetsLink(repository, branch, page);
@@ -117,7 +117,7 @@ export function fetchChangesets(
function createChangesetsLink(
repository: Repository,
branch?: Branch,
page?: number,
page?: number
) {
let link = repository._links.changesets.href;
@@ -133,58 +133,58 @@ function createChangesetsLink(
export function fetchChangesetsPending(
repository: Repository,
branch?: Branch,
branch?: Branch
): Action {
const itemId = createItemId(repository, branch);
return {
type: FETCH_CHANGESETS_PENDING,
itemId,
itemId
};
}
export function fetchChangesetsSuccess(
repository: Repository,
branch?: Branch,
changesets: any,
changesets: any
): Action {
return {
type: FETCH_CHANGESETS_SUCCESS,
payload: {
repository,
branch,
changesets,
changesets
},
itemId: createItemId(repository, branch),
itemId: createItemId(repository, branch)
};
}
function fetchChangesetsFailure(
repository: Repository,
branch?: Branch,
error: Error,
error: Error
): Action {
return {
type: FETCH_CHANGESETS_FAILURE,
payload: {
repository,
error,
branch,
branch
},
itemId: createItemId(repository, branch),
itemId: createItemId(repository, branch)
};
}
function createChangesetItemId(repository: Repository, id: string) {
const { namespace, name } = repository;
return namespace + '/' + name + '/' + id;
return namespace + "/" + name + "/" + id;
}
function createItemId(repository: Repository, branch?: Branch): string {
const { namespace, name } = repository;
let itemId = namespace + '/' + name;
let itemId = namespace + "/" + name;
if (branch) {
itemId = itemId + '/' + branch.name;
itemId = itemId + "/" + branch.name;
}
return itemId;
}
@@ -193,8 +193,8 @@ function createItemId(repository: Repository, branch?: Branch): string {
export default function reducer(
state: any = {},
action: Action = {
type: 'UNKNOWN',
},
type: "UNKNOWN"
}
): object {
if (!action.payload) {
return state;
@@ -218,9 +218,9 @@ export default function reducer(
...state[_key],
byId: {
..._oldByIds,
[changeset.id]: changeset,
},
},
[changeset.id]: changeset
}
}
};
case FETCH_CHANGESETS_SUCCESS:
@@ -239,7 +239,7 @@ export default function reducer(
oldState = state[repoId];
}
const branchName = payload.branch ? payload.branch.name : '';
const branchName = payload.branch ? payload.branch.name : "";
const byIds = extractChangesetsByIds(changesets);
return {
@@ -247,7 +247,7 @@ export default function reducer(
[repoId]: {
byId: {
...oldState.byId,
...byIds,
...byIds
},
byBranch: {
...oldState.byBranch,
@@ -256,11 +256,11 @@ export default function reducer(
entry: {
page: payload.changesets.page,
pageTotal: payload.changesets.pageTotal,
_links: payload.changesets._links,
},
},
},
},
_links: payload.changesets._links
}
}
}
}
};
default:
return state;
@@ -281,7 +281,7 @@ function extractChangesetsByIds(changesets: any) {
export function getChangesets(
state: object,
repository: Repository,
branch?: Branch,
branch?: Branch
) {
const repoKey = createItemId(repository);
@@ -290,7 +290,7 @@ export function getChangesets(
return null;
}
const branchName = branch ? branch.name : '';
const branchName = branch ? branch.name : "";
const changesets = stateRoot.byBranch[branchName];
if (!changesets) {
@@ -305,7 +305,7 @@ export function getChangesets(
export function getChangeset(
state: object,
repository: Repository,
id: string,
id: string
) {
const key = createItemId(repository);
const changesets =
@@ -321,7 +321,7 @@ export function getChangeset(
export function shouldFetchChangeset(
state: object,
repository: Repository,
id: string,
id: string
) {
if (getChangeset(state, repository, id)) {
return false;
@@ -332,31 +332,31 @@ export function shouldFetchChangeset(
export function isFetchChangesetPending(
state: object,
repository: Repository,
id: string,
id: string
) {
return isPending(
state,
FETCH_CHANGESET,
createChangesetItemId(repository, id),
createChangesetItemId(repository, id)
);
}
export function getFetchChangesetFailure(
state: object,
repository: Repository,
id: string,
id: string
) {
return getFailure(
state,
FETCH_CHANGESET,
createChangesetItemId(repository, id),
createChangesetItemId(repository, id)
);
}
export function isFetchChangesetsPending(
state: object,
repository: Repository,
branch?: Branch,
branch?: Branch
) {
return isPending(state, FETCH_CHANGESETS, createItemId(repository, branch));
}
@@ -364,7 +364,7 @@ export function isFetchChangesetsPending(
export function getFetchChangesetsFailure(
state: object,
repository: Repository,
branch?: Branch,
branch?: Branch
) {
return getFailure(state, FETCH_CHANGESETS, createItemId(repository, branch));
}
@@ -372,7 +372,7 @@ export function getFetchChangesetsFailure(
const selectList = (state: object, repository: Repository, branch?: Branch) => {
const repoId = createItemId(repository);
const branchName = branch ? branch.name : '';
const branchName = branch ? branch.name : "";
if (state.changesets[repoId]) {
const repoState = state.changesets[repoId];
@@ -386,7 +386,7 @@ const selectList = (state: object, repository: Repository, branch?: Branch) => {
const selectListEntry = (
state: object,
repository: Repository,
branch?: Branch,
branch?: Branch
): object => {
const list = selectList(state, repository, branch);
if (list.entry) {
@@ -398,7 +398,7 @@ const selectListEntry = (
export const selectListAsCollection = (
state: object,
repository: Repository,
branch?: Branch,
branch?: Branch
): PagedCollection => {
return selectListEntry(state, repository, branch);
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,45 +1,45 @@
import { apiClient } from '@scm-manager/ui-components';
import * as types from '../../modules/types';
import { apiClient } from "@scm-manager/ui-components";
import * as types from "../../modules/types";
import {
Action,
Repository,
RepositoryCollection,
} from '@scm-manager/ui-types';
import { isPending } from '../../modules/pending';
import { getFailure } from '../../modules/failure';
RepositoryCollection
} from "@scm-manager/ui-types";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
export const FETCH_REPOS = 'scm/repos/FETCH_REPOS';
export const FETCH_REPOS = "scm/repos/FETCH_REPOS";
export const FETCH_REPOS_PENDING = `${FETCH_REPOS}_${types.PENDING_SUFFIX}`;
export const FETCH_REPOS_SUCCESS = `${FETCH_REPOS}_${types.SUCCESS_SUFFIX}`;
export const FETCH_REPOS_FAILURE = `${FETCH_REPOS}_${types.FAILURE_SUFFIX}`;
export const FETCH_REPO = 'scm/repos/FETCH_REPO';
export const FETCH_REPO = "scm/repos/FETCH_REPO";
export const FETCH_REPO_PENDING = `${FETCH_REPO}_${types.PENDING_SUFFIX}`;
export const FETCH_REPO_SUCCESS = `${FETCH_REPO}_${types.SUCCESS_SUFFIX}`;
export const FETCH_REPO_FAILURE = `${FETCH_REPO}_${types.FAILURE_SUFFIX}`;
export const CREATE_REPO = 'scm/repos/CREATE_REPO';
export const CREATE_REPO = "scm/repos/CREATE_REPO";
export const CREATE_REPO_PENDING = `${CREATE_REPO}_${types.PENDING_SUFFIX}`;
export const CREATE_REPO_SUCCESS = `${CREATE_REPO}_${types.SUCCESS_SUFFIX}`;
export const CREATE_REPO_FAILURE = `${CREATE_REPO}_${types.FAILURE_SUFFIX}`;
export const CREATE_REPO_RESET = `${CREATE_REPO}_${types.RESET_SUFFIX}`;
export const MODIFY_REPO = 'scm/repos/MODIFY_REPO';
export const MODIFY_REPO = "scm/repos/MODIFY_REPO";
export const MODIFY_REPO_PENDING = `${MODIFY_REPO}_${types.PENDING_SUFFIX}`;
export const MODIFY_REPO_SUCCESS = `${MODIFY_REPO}_${types.SUCCESS_SUFFIX}`;
export const MODIFY_REPO_FAILURE = `${MODIFY_REPO}_${types.FAILURE_SUFFIX}`;
export const MODIFY_REPO_RESET = `${MODIFY_REPO}_${types.RESET_SUFFIX}`;
export const DELETE_REPO = 'scm/repos/DELETE_REPO';
export const DELETE_REPO = "scm/repos/DELETE_REPO";
export const DELETE_REPO_PENDING = `${DELETE_REPO}_${types.PENDING_SUFFIX}`;
export const DELETE_REPO_SUCCESS = `${DELETE_REPO}_${types.SUCCESS_SUFFIX}`;
export const DELETE_REPO_FAILURE = `${DELETE_REPO}_${types.FAILURE_SUFFIX}`;
const CONTENT_TYPE = 'application/vnd.scmm-repository+json;v=2';
const CONTENT_TYPE = "application/vnd.scmm-repository+json;v=2";
// fetch repos
const SORT_BY = 'sortBy=namespaceAndName';
const SORT_BY = "sortBy=namespaceAndName";
export function fetchRepos(link: string) {
return fetchReposByLink(link);
@@ -48,7 +48,7 @@ export function fetchRepos(link: string) {
export function fetchReposByPage(link: string, page: number, filter?: string) {
if (filter) {
return fetchReposByLink(
`${link}?page=${page - 1}&q=${decodeURIComponent(filter)}`,
`${link}?page=${page - 1}&q=${decodeURIComponent(filter)}`
);
}
return fetchReposByLink(`${link}?page=${page - 1}`);
@@ -59,10 +59,10 @@ function appendSortByLink(url: string) {
return url;
}
let urlWithSortBy = url;
if (url.includes('?')) {
urlWithSortBy += '&';
if (url.includes("?")) {
urlWithSortBy += "&";
} else {
urlWithSortBy += '?';
urlWithSortBy += "?";
}
return urlWithSortBy + SORT_BY;
}
@@ -85,21 +85,21 @@ export function fetchReposByLink(link: string) {
export function fetchReposPending(): Action {
return {
type: FETCH_REPOS_PENDING,
type: FETCH_REPOS_PENDING
};
}
export function fetchReposSuccess(repositories: RepositoryCollection): Action {
return {
type: FETCH_REPOS_SUCCESS,
payload: repositories,
payload: repositories
};
}
export function fetchReposFailure(err: Error): Action {
return {
type: FETCH_REPOS_FAILURE,
payload: err,
payload: err
};
}
@@ -109,7 +109,7 @@ export function fetchRepoByLink(repo: Repository) {
}
export function fetchRepoByName(link: string, namespace: string, name: string) {
const repoUrl = link.endsWith('/') ? link : link + '/';
const repoUrl = link.endsWith("/") ? link : link + "/";
return fetchRepo(`${repoUrl}${namespace}/${name}`, namespace, name);
}
@@ -133,9 +133,9 @@ export function fetchRepoPending(namespace: string, name: string): Action {
type: FETCH_REPO_PENDING,
payload: {
namespace,
name,
name
},
itemId: namespace + '/' + name,
itemId: namespace + "/" + name
};
}
@@ -143,23 +143,23 @@ export function fetchRepoSuccess(repository: Repository): Action {
return {
type: FETCH_REPO_SUCCESS,
payload: repository,
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
export function fetchRepoFailure(
namespace: string,
name: string,
error: Error,
error: Error
): Action {
return {
type: FETCH_REPO_FAILURE,
payload: {
namespace,
name,
error,
error
},
itemId: namespace + '/' + name,
itemId: namespace + "/" + name
};
}
@@ -168,14 +168,14 @@ export function fetchRepoFailure(
export function createRepo(
link: string,
repository: Repository,
callback?: (repo: Repository) => void,
callback?: (repo: Repository) => void
) {
return function(dispatch: any) {
dispatch(createRepoPending());
return apiClient
.post(link, repository, CONTENT_TYPE)
.then(response => {
const location = response.headers.get('Location');
const location = response.headers.get("Location");
dispatch(createRepoSuccess());
return apiClient.get(location);
})
@@ -193,26 +193,26 @@ export function createRepo(
export function createRepoPending(): Action {
return {
type: CREATE_REPO_PENDING,
type: CREATE_REPO_PENDING
};
}
export function createRepoSuccess(): Action {
return {
type: CREATE_REPO_SUCCESS,
type: CREATE_REPO_SUCCESS
};
}
export function createRepoFailure(err: Error): Action {
return {
type: CREATE_REPO_FAILURE,
payload: err,
payload: err
};
}
export function createRepoReset(): Action {
return {
type: CREATE_REPO_RESET,
type: CREATE_REPO_RESET
};
}
@@ -243,7 +243,7 @@ export function modifyRepoPending(repository: Repository): Action {
return {
type: MODIFY_REPO_PENDING,
payload: repository,
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
@@ -251,21 +251,21 @@ export function modifyRepoSuccess(repository: Repository): Action {
return {
type: MODIFY_REPO_SUCCESS,
payload: repository,
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
export function modifyRepoFailure(
repository: Repository,
error: Error,
error: Error
): Action {
return {
type: MODIFY_REPO_FAILURE,
payload: {
error,
repository,
repository
},
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
@@ -273,9 +273,9 @@ export function modifyRepoReset(repository: Repository): Action {
return {
type: MODIFY_REPO_RESET,
payload: {
repository,
repository
},
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
@@ -302,7 +302,7 @@ export function deleteRepoPending(repository: Repository): Action {
return {
type: DELETE_REPO_PENDING,
payload: repository,
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
@@ -310,32 +310,32 @@ export function deleteRepoSuccess(repository: Repository): Action {
return {
type: DELETE_REPO_SUCCESS,
payload: repository,
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
export function deleteRepoFailure(
repository: Repository,
error: Error,
error: Error
): Action {
return {
type: DELETE_REPO_FAILURE,
payload: {
error,
repository,
repository
},
itemId: createIdentifier(repository),
itemId: createIdentifier(repository)
};
}
// reducer
function createIdentifier(repository: Repository) {
return repository.namespace + '/' + repository.name;
return repository.namespace + "/" + repository.name;
}
function normalizeByNamespaceAndName(
repositoryCollection: RepositoryCollection,
repositoryCollection: RepositoryCollection
) {
const names = [];
const byNames = {};
@@ -348,10 +348,10 @@ function normalizeByNamespaceAndName(
list: {
...repositoryCollection,
_embedded: {
repositories: names,
},
repositories: names
}
},
byNames: byNames,
byNames: byNames
};
}
@@ -361,16 +361,16 @@ const reducerByNames = (state: object, repository: Repository) => {
...state,
byNames: {
...state.byNames,
[identifier]: repository,
},
[identifier]: repository
}
};
};
export default function reducer(
state: object = {},
action: Action = {
type: 'UNKNOWN',
},
type: "UNKNOWN"
}
): object {
if (!action.payload) {
return state;
@@ -397,8 +397,8 @@ export function getRepositoryCollection(state: object) {
return {
...state.repos.list,
_embedded: {
repositories,
},
repositories
}
};
}
}
@@ -413,24 +413,24 @@ export function getFetchReposFailure(state: object) {
export function getRepository(state: object, namespace: string, name: string) {
if (state.repos && state.repos.byNames) {
return state.repos.byNames[namespace + '/' + name];
return state.repos.byNames[namespace + "/" + name];
}
}
export function isFetchRepoPending(
state: object,
namespace: string,
name: string,
name: string
) {
return isPending(state, FETCH_REPO, namespace + '/' + name);
return isPending(state, FETCH_REPO, namespace + "/" + name);
}
export function getFetchRepoFailure(
state: object,
namespace: string,
name: string,
name: string
) {
return getFailure(state, FETCH_REPO, namespace + '/' + name);
return getFailure(state, FETCH_REPO, namespace + "/" + name);
}
export function isAbleToCreateRepos(state: object) {
@@ -453,39 +453,39 @@ export function getCreateRepoFailure(state: object) {
export function isModifyRepoPending(
state: object,
namespace: string,
name: string,
name: string
) {
return isPending(state, MODIFY_REPO, namespace + '/' + name);
return isPending(state, MODIFY_REPO, namespace + "/" + name);
}
export function getModifyRepoFailure(
state: object,
namespace: string,
name: string,
name: string
) {
return getFailure(state, MODIFY_REPO, namespace + '/' + name);
return getFailure(state, MODIFY_REPO, namespace + "/" + name);
}
export function isDeleteRepoPending(
state: object,
namespace: string,
name: string,
name: string
) {
return isPending(state, DELETE_REPO, namespace + '/' + name);
return isPending(state, DELETE_REPO, namespace + "/" + name);
}
export function getDeleteRepoFailure(
state: object,
namespace: string,
name: string,
name: string
) {
return getFailure(state, DELETE_REPO, namespace + '/' + name);
return getFailure(state, DELETE_REPO, namespace + "/" + name);
}
export function getPermissionsLink(
state: object,
namespace: string,
name: string,
name: string
) {
const repo = getRepository(state, namespace, name);
return repo && repo._links ? repo._links.permissions.href : undefined;

View File

@@ -1,6 +1,6 @@
import fetchMock from 'fetch-mock';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import fetchMock from "fetch-mock";
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
import {
FETCH_REPOSITORY_TYPES,
FETCH_REPOSITORY_TYPES_FAILURE,
@@ -11,91 +11,91 @@ import {
getFetchRepositoryTypesFailure,
getRepositoryTypes,
isFetchRepositoryTypesPending,
shouldFetchRepositoryTypes,
} from './repositoryTypes';
import reducer from './repositoryTypes';
shouldFetchRepositoryTypes
} from "./repositoryTypes";
import reducer from "./repositoryTypes";
const git = {
name: 'git',
displayName: 'Git',
name: "git",
displayName: "Git",
_links: {
self: {
href: 'http://localhost:8081/api/v2/repositoryTypes/git',
},
},
href: "http://localhost:8081/api/v2/repositoryTypes/git"
}
}
};
const hg = {
name: 'hg',
displayName: 'Mercurial',
name: "hg",
displayName: "Mercurial",
_links: {
self: {
href: 'http://localhost:8081/api/v2/repositoryTypes/hg',
},
},
href: "http://localhost:8081/api/v2/repositoryTypes/hg"
}
}
};
const svn = {
name: 'svn',
displayName: 'Subversion',
name: "svn",
displayName: "Subversion",
_links: {
self: {
href: 'http://localhost:8081/api/v2/repositoryTypes/svn',
},
},
href: "http://localhost:8081/api/v2/repositoryTypes/svn"
}
}
};
const collection = {
_embedded: {
repositoryTypes: [git, hg, svn],
repositoryTypes: [git, hg, svn]
},
_links: {
self: {
href: 'http://localhost:8081/api/v2/repositoryTypes',
},
},
href: "http://localhost:8081/api/v2/repositoryTypes"
}
}
};
describe('repository types caching', () => {
it('should fetch repository types, on empty state', () => {
describe("repository types caching", () => {
it("should fetch repository types, on empty state", () => {
expect(shouldFetchRepositoryTypes({})).toBe(true);
});
it('should fetch repository types, if the state contains an empty array', () => {
it("should fetch repository types, if the state contains an empty array", () => {
const state = {
repositoryTypes: [],
repositoryTypes: []
};
expect(shouldFetchRepositoryTypes(state)).toBe(true);
});
it('should not fetch repository types, on pending state', () => {
it("should not fetch repository types, on pending state", () => {
const state = {
pending: {
[FETCH_REPOSITORY_TYPES]: true,
},
[FETCH_REPOSITORY_TYPES]: true
}
};
expect(shouldFetchRepositoryTypes(state)).toBe(false);
});
it('should not fetch repository types, on failure state', () => {
it("should not fetch repository types, on failure state", () => {
const state = {
failure: {
[FETCH_REPOSITORY_TYPES]: new Error('no...'),
},
[FETCH_REPOSITORY_TYPES]: new Error("no...")
}
};
expect(shouldFetchRepositoryTypes(state)).toBe(false);
});
it('should not fetch repository types, if they are already fetched', () => {
it("should not fetch repository types, if they are already fetched", () => {
const state = {
repositoryTypes: [git, hg, svn],
repositoryTypes: [git, hg, svn]
};
expect(shouldFetchRepositoryTypes(state)).toBe(false);
});
});
describe('repository types fetch', () => {
const URL = '/api/v2/repositoryTypes';
describe("repository types fetch", () => {
const URL = "/api/v2/repositoryTypes";
const mockStore = configureMockStore([thunk]);
afterEach(() => {
@@ -103,17 +103,17 @@ describe('repository types fetch', () => {
fetchMock.restore();
});
it('should successfully fetch repository types', () => {
it("should successfully fetch repository types", () => {
fetchMock.getOnce(URL, collection);
const expectedActions = [
{
type: FETCH_REPOSITORY_TYPES_PENDING,
type: FETCH_REPOSITORY_TYPES_PENDING
},
{
type: FETCH_REPOSITORY_TYPES_SUCCESS,
payload: collection,
},
payload: collection
}
];
const store = mockStore({});
@@ -122,9 +122,9 @@ describe('repository types fetch', () => {
});
});
it('should dispatch FETCH_REPOSITORY_TYPES_FAILURE on server error', () => {
it("should dispatch FETCH_REPOSITORY_TYPES_FAILURE on server error", () => {
fetchMock.getOnce(URL, {
status: 500,
status: 500
});
const store = mockStore({});
@@ -136,63 +136,63 @@ describe('repository types fetch', () => {
});
});
it('should dispatch not dispatch any action, if the repository types are already fetched', () => {
it("should dispatch not dispatch any action, if the repository types are already fetched", () => {
const store = mockStore({
repositoryTypes: [git, hg, svn],
repositoryTypes: [git, hg, svn]
});
store.dispatch(fetchRepositoryTypesIfNeeded());
expect(store.getActions().length).toBe(0);
});
});
describe('repository types reducer', () => {
it('should return unmodified state on unknown action', () => {
describe("repository types reducer", () => {
it("should return unmodified state on unknown action", () => {
const state = [];
expect(reducer(state)).toBe(state);
});
it('should store the repository types on FETCH_REPOSITORY_TYPES_SUCCESS', () => {
it("should store the repository types on FETCH_REPOSITORY_TYPES_SUCCESS", () => {
const newState = reducer([], fetchRepositoryTypesSuccess(collection));
expect(newState).toEqual([git, hg, svn]);
});
});
describe('repository types selectors', () => {
const error = new Error('The end of the universe');
describe("repository types selectors", () => {
const error = new Error("The end of the universe");
it('should return an emtpy array', () => {
it("should return an emtpy array", () => {
expect(getRepositoryTypes({})).toEqual([]);
});
it('should return the repository types', () => {
it("should return the repository types", () => {
const state = {
repositoryTypes: [git, hg, svn],
repositoryTypes: [git, hg, svn]
};
expect(getRepositoryTypes(state)).toEqual([git, hg, svn]);
});
it('should return true, when fetch repository types is pending', () => {
it("should return true, when fetch repository types is pending", () => {
const state = {
pending: {
[FETCH_REPOSITORY_TYPES]: true,
},
[FETCH_REPOSITORY_TYPES]: true
}
};
expect(isFetchRepositoryTypesPending(state)).toEqual(true);
});
it('should return false, when fetch repos is not pending', () => {
it("should return false, when fetch repos is not pending", () => {
expect(isFetchRepositoryTypesPending({})).toEqual(false);
});
it('should return error when fetch repository types did fail', () => {
it("should return error when fetch repository types did fail", () => {
const state = {
failure: {
[FETCH_REPOSITORY_TYPES]: error,
},
[FETCH_REPOSITORY_TYPES]: error
}
};
expect(getFetchRepositoryTypesFailure(state)).toEqual(error);
});
it('should return undefined when fetch repos did not fail', () => {
it("should return undefined when fetch repos did not fail", () => {
expect(getFetchRepositoryTypesFailure({})).toBe(undefined);
});
});

View File

@@ -1,14 +1,14 @@
import * as types from '../../modules/types';
import * as types from "../../modules/types";
import {
Action,
RepositoryType,
RepositoryTypeCollection,
} from '@scm-manager/ui-types';
import { apiClient } from '@scm-manager/ui-components';
import { isPending } from '../../modules/pending';
import { getFailure } from '../../modules/failure';
RepositoryTypeCollection
} from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
export const FETCH_REPOSITORY_TYPES = 'scm/repos/FETCH_REPOSITORY_TYPES';
export const FETCH_REPOSITORY_TYPES = "scm/repos/FETCH_REPOSITORY_TYPES";
export const FETCH_REPOSITORY_TYPES_PENDING = `${FETCH_REPOSITORY_TYPES}_${types.PENDING_SUFFIX}`;
export const FETCH_REPOSITORY_TYPES_SUCCESS = `${FETCH_REPOSITORY_TYPES}_${types.SUCCESS_SUFFIX}`;
export const FETCH_REPOSITORY_TYPES_FAILURE = `${FETCH_REPOSITORY_TYPES}_${types.FAILURE_SUFFIX}`;
@@ -24,7 +24,7 @@ export function fetchRepositoryTypesIfNeeded() {
function fetchRepositoryTypes(dispatch: any) {
dispatch(fetchRepositoryTypesPending());
return apiClient
.get('repositoryTypes')
.get("repositoryTypes")
.then(response => response.json())
.then(repositoryTypes => {
dispatch(fetchRepositoryTypesSuccess(repositoryTypes));
@@ -46,23 +46,23 @@ export function shouldFetchRepositoryTypes(state: object) {
export function fetchRepositoryTypesPending(): Action {
return {
type: FETCH_REPOSITORY_TYPES_PENDING,
type: FETCH_REPOSITORY_TYPES_PENDING
};
}
export function fetchRepositoryTypesSuccess(
repositoryTypes: RepositoryTypeCollection,
repositoryTypes: RepositoryTypeCollection
): Action {
return {
type: FETCH_REPOSITORY_TYPES_SUCCESS,
payload: repositoryTypes,
payload: repositoryTypes
};
}
export function fetchRepositoryTypesFailure(error: Error): Action {
return {
type: FETCH_REPOSITORY_TYPES_FAILURE,
payload: error,
payload: error
};
}
@@ -71,11 +71,11 @@ export function fetchRepositoryTypesFailure(error: Error): Action {
export default function reducer(
state: RepositoryType[] = [],
action: Action = {
type: 'UNKNOWN',
},
type: "UNKNOWN"
}
): RepositoryType[] {
if (action.type === FETCH_REPOSITORY_TYPES_SUCCESS && action.payload) {
return action.payload._embedded['repositoryTypes'];
return action.payload._embedded["repositoryTypes"];
}
return state;
}