apply eslint and prettier rules

This commit is contained in:
Sebastian Sdorra
2019-10-21 10:57:56 +02:00
parent 85773186db
commit 4bb8e6153b
227 changed files with 1147 additions and 4076 deletions

View File

@@ -30,8 +30,7 @@ const branch = {
revision: "123",
_links: {
history: {
href:
"http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets"
href: "http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/changesets"
}
}
};
@@ -48,8 +47,7 @@ const repository = {
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"
href: "http://scm.hitchhicker.com/api/v2/repositories/foo/bar/branches/specific/branches"
}
}
};
@@ -58,10 +56,8 @@ const changesets = {};
describe("changesets", () => {
describe("fetching of changesets", () => {
const DEFAULT_BRANCH_URL =
"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";
const DEFAULT_BRANCH_URL = "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";
const mockStore = configureMockStore([thunk]);
@@ -92,11 +88,9 @@ describe("changesets", () => {
];
const store = mockStore({});
return store
.dispatch(fetchChangeset(repository, changesetId))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store.dispatch(fetchChangeset(repository, changesetId)).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
it("should fail fetching changeset on error", () => {
@@ -110,13 +104,11 @@ describe("changesets", () => {
];
const store = mockStore({});
return store
.dispatch(fetchChangeset(repository, changesetId))
.then(() => {
expect(store.getActions()[0]).toEqual(expectedActions[0]);
expect(store.getActions()[1].type).toEqual(FETCH_CHANGESET_FAILURE);
expect(store.getActions()[1].payload).toBeDefined();
});
return store.dispatch(fetchChangeset(repository, changesetId)).then(() => {
expect(store.getActions()[0]).toEqual(expectedActions[0]);
expect(store.getActions()[1].type).toEqual(FETCH_CHANGESET_FAILURE);
expect(store.getActions()[1].payload).toBeDefined();
});
});
it("should fetch changeset if needed", () => {
@@ -139,11 +131,9 @@ describe("changesets", () => {
];
const store = mockStore({});
return store
.dispatch(fetchChangesetIfNeeded(repository, "id3"))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store.dispatch(fetchChangesetIfNeeded(repository, "id3")).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
it("should not fetch changeset if not needed", () => {
@@ -165,9 +155,7 @@ describe("changesets", () => {
};
const store = mockStore(state);
return expect(
store.dispatch(fetchChangesetIfNeeded(repository, "id1"))
).toEqual(undefined);
return expect(store.dispatch(fetchChangesetIfNeeded(repository, "id1"))).toEqual(undefined);
});
it("should fetch changesets for default branch", () => {
@@ -279,11 +267,9 @@ describe("changesets", () => {
];
const store = mockStore({});
return store
.dispatch(fetchChangesets(repository, undefined, 5))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store.dispatch(fetchChangesets(repository, undefined, 5)).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
it("should fetch changesets by branch and page", () => {
@@ -344,14 +330,9 @@ describe("changesets", () => {
};
it("should set state to received changesets", () => {
const newState = reducer(
{},
fetchChangesetsSuccess(repository, undefined, responseBody)
);
const newState = reducer({}, 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({
@@ -365,17 +346,10 @@ describe("changesets", () => {
});
it("should store the changeset list to branch", () => {
const newState = reducer(
{},
fetchChangesetsSuccess(repository, branch, responseBody)
);
const newState = reducer({}, 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"].byBranch["specific"].entries).toEqual(["changeset1", "changeset2", "changeset3"]);
});
it("should not remove existing changesets", () => {
@@ -397,18 +371,11 @@ describe("changesets", () => {
}
};
const newState = reducer(
state,
fetchChangesetsSuccess(repository, undefined, responseBody)
);
const newState = reducer(state, fetchChangesetsSuccess(repository, undefined, responseBody));
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"
});
@@ -459,9 +426,7 @@ describe("changesets", () => {
);
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();

View File

@@ -1,17 +1,8 @@
import {
FAILURE_SUFFIX,
PENDING_SUFFIX,
SUCCESS_SUFFIX
} from "../../modules/types";
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";
import {
Action,
Branch,
PagedCollection,
Repository
} from "@scm-manager/ui-types";
import { Action, Branch, PagedCollection, Repository } from "@scm-manager/ui-types";
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
@@ -51,21 +42,14 @@ function createChangesetUrl(repository: Repository, id: string) {
return urls.concat(repository._links.changesets.href, id);
}
export function fetchChangesetPending(
repository: Repository,
id: string
): Action {
export function fetchChangesetPending(repository: Repository, id: string): Action {
return {
type: FETCH_CHANGESET_PENDING,
itemId: createChangesetItemId(repository, id)
};
}
export function fetchChangesetSuccess(
changeset: any,
repository: Repository,
id: string
): Action {
export function fetchChangesetSuccess(changeset: any, repository: Repository, id: string): Action {
return {
type: FETCH_CHANGESET_SUCCESS,
payload: {
@@ -77,11 +61,7 @@ export function fetchChangesetSuccess(
};
}
function fetchChangesetFailure(
repository: Repository,
id: string,
error: Error
): Action {
function fetchChangesetFailure(repository: Repository, id: string, error: Error): Action {
return {
type: FETCH_CHANGESET_FAILURE,
payload: {
@@ -93,11 +73,7 @@ function fetchChangesetFailure(
};
}
export function fetchChangesets(
repository: Repository,
branch?: Branch,
page?: number
) {
export function fetchChangesets(repository: Repository, branch?: Branch, page?: number) {
const link = createChangesetsLink(repository, branch, page);
return function(dispatch: any) {
@@ -114,11 +90,7 @@ export function fetchChangesets(
};
}
function createChangesetsLink(
repository: Repository,
branch?: Branch,
page?: number
) {
function createChangesetsLink(repository: Repository, branch?: Branch, page?: number) {
let link = repository._links.changesets.href;
if (branch) {
@@ -131,10 +103,7 @@ function createChangesetsLink(
return link;
}
export function fetchChangesetsPending(
repository: Repository,
branch?: Branch
): Action {
export function fetchChangesetsPending(repository: Repository, branch?: Branch): Action {
const itemId = createItemId(repository, branch);
return {
@@ -143,11 +112,7 @@ export function fetchChangesetsPending(
};
}
export function fetchChangesetsSuccess(
repository: Repository,
branch?: Branch,
changesets: any
): Action {
export function fetchChangesetsSuccess(repository: Repository, branch?: Branch, changesets: any): Action {
return {
type: FETCH_CHANGESETS_SUCCESS,
payload: {
@@ -159,11 +124,7 @@ export function fetchChangesetsSuccess(
};
}
function fetchChangesetsFailure(
repository: Repository,
branch?: Branch,
error: Error
): Action {
function fetchChangesetsFailure(repository: Repository, branch?: Branch, error: Error): Action {
return {
type: FETCH_CHANGESETS_FAILURE,
payload: {
@@ -270,7 +231,7 @@ export default function reducer(
function extractChangesetsByIds(changesets: any) {
const changesetsByIds = {};
for (let changeset of changesets) {
for (const changeset of changesets) {
changesetsByIds[changeset.id] = changeset;
}
@@ -278,11 +239,7 @@ function extractChangesetsByIds(changesets: any) {
}
//selectors
export function getChangesets(
state: object,
repository: Repository,
branch?: Branch
) {
export function getChangesets(state: object, repository: Repository, branch?: Branch) {
const repoKey = createItemId(repository);
const stateRoot = state.changesets[repoKey];
@@ -302,70 +259,35 @@ export function getChangesets(
});
}
export function getChangeset(
state: object,
repository: Repository,
id: string
) {
export function getChangeset(state: object, repository: Repository, id: string) {
const key = createItemId(repository);
const changesets =
state.changesets && state.changesets[key]
? state.changesets[key].byId
: null;
const changesets = state.changesets && state.changesets[key] ? state.changesets[key].byId : null;
if (changesets != null && changesets[id]) {
return changesets[id];
}
return null;
}
export function shouldFetchChangeset(
state: object,
repository: Repository,
id: string
) {
export function shouldFetchChangeset(state: object, repository: Repository, id: string) {
if (getChangeset(state, repository, id)) {
return false;
}
return true;
}
export function isFetchChangesetPending(
state: object,
repository: Repository,
id: string
) {
return isPending(
state,
FETCH_CHANGESET,
createChangesetItemId(repository, id)
);
export function isFetchChangesetPending(state: object, repository: Repository, id: string) {
return isPending(state, FETCH_CHANGESET, createChangesetItemId(repository, id));
}
export function getFetchChangesetFailure(
state: object,
repository: Repository,
id: string
) {
return getFailure(
state,
FETCH_CHANGESET,
createChangesetItemId(repository, id)
);
export function getFetchChangesetFailure(state: object, repository: Repository, id: string) {
return getFailure(state, FETCH_CHANGESET, createChangesetItemId(repository, id));
}
export function isFetchChangesetsPending(
state: object,
repository: Repository,
branch?: Branch
) {
export function isFetchChangesetsPending(state: object, repository: Repository, branch?: Branch) {
return isPending(state, FETCH_CHANGESETS, createItemId(repository, branch));
}
export function getFetchChangesetsFailure(
state: object,
repository: Repository,
branch?: Branch
) {
export function getFetchChangesetsFailure(state: object, repository: Repository, branch?: Branch) {
return getFailure(state, FETCH_CHANGESETS, createItemId(repository, branch));
}
@@ -383,11 +305,7 @@ const selectList = (state: object, repository: Repository, branch?: Branch) => {
return {};
};
const selectListEntry = (
state: object,
repository: Repository,
branch?: Branch
): object => {
const selectListEntry = (state: object, repository: Repository, branch?: Branch): object => {
const list = selectList(state, repository, branch);
if (list.entry) {
return list.entry;
@@ -395,10 +313,6 @@ const selectListEntry = (
return {};
};
export const selectListAsCollection = (
state: object,
repository: Repository,
branch?: Branch
): PagedCollection => {
export const selectListAsCollection = (state: object, repository: Repository, branch?: Branch): PagedCollection => {
return selectListEntry(state, repository, branch);
};

View File

@@ -67,24 +67,19 @@ const hitchhikerPuzzle42: Repository = {
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42"
},
permissions: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/permissions/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/permissions/"
},
tags: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/tags/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/tags/"
},
branches: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/branches/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/branches/"
},
changesets: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/changesets/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/changesets/"
},
sources: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/sources/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/puzzle42/sources/"
}
}
};
@@ -107,24 +102,19 @@ const hitchhikerRestatend: Repository = {
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend"
},
permissions: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/restatend/permissions/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend/permissions/"
},
tags: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/restatend/tags/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend/tags/"
},
branches: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/restatend/branches/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend/branches/"
},
changesets: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/restatend/changesets/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend/changesets/"
},
sources: {
href:
"http://localhost:8081/api/v2/repositories/hitchhiker/restatend/sources/"
href: "http://localhost:8081/api/v2/repositories/hitchhiker/restatend/sources/"
}
}
};
@@ -147,8 +137,7 @@ const slartiFjords: Repository = {
href: "http://localhost:8081/api/v2/repositories/slarti/fjords"
},
permissions: {
href:
"http://localhost:8081/api/v2/repositories/slarti/fjords/permissions/"
href: "http://localhost:8081/api/v2/repositories/slarti/fjords/permissions/"
},
tags: {
href: "http://localhost:8081/api/v2/repositories/slarti/fjords/tags/"
@@ -157,8 +146,7 @@ const slartiFjords: Repository = {
href: "http://localhost:8081/api/v2/repositories/slarti/fjords/branches/"
},
changesets: {
href:
"http://localhost:8081/api/v2/repositories/slarti/fjords/changesets/"
href: "http://localhost:8081/api/v2/repositories/slarti/fjords/changesets/"
},
sources: {
href: "http://localhost:8081/api/v2/repositories/slarti/fjords/sources/"
@@ -206,11 +194,7 @@ const repositoryCollectionWithNames: RepositoryCollection = {
}
},
_embedded: {
repositories: [
"hitchhiker/puzzle42",
"hitchhiker/restatend",
"slarti/fjords"
]
repositories: ["hitchhiker/puzzle42", "hitchhiker/restatend", "slarti/fjords"]
}
};
@@ -267,10 +251,7 @@ describe("repos fetch", () => {
});
it("should successfully fetch repos from link", () => {
fetchMock.getOnce(
REPOS_URL + "?" + SORT + "&page=42",
repositoryCollection
);
fetchMock.getOnce(REPOS_URL + "?" + SORT + "&page=42", repositoryCollection);
const expectedActions = [
{
@@ -283,20 +264,13 @@ describe("repos fetch", () => {
];
const store = mockStore({});
return store
.dispatch(
fetchReposByLink("/repositories?sortBy=namespaceAndName&page=42")
)
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
return store.dispatch(fetchReposByLink("/repositories?sortBy=namespaceAndName&page=42")).then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
it("should append sortby parameter and successfully fetch repos from link", () => {
fetchMock.getOnce(
"/api/v2/repositories?one=1&sortBy=namespaceAndName",
repositoryCollection
);
fetchMock.getOnce("/api/v2/repositories?one=1&sortBy=namespaceAndName", repositoryCollection);
const expectedActions = [
{
@@ -372,10 +346,7 @@ describe("repos fetch", () => {
});
it("should successfully fetch repo slarti/fjords", () => {
fetchMock.getOnce(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
slartiFjords
);
fetchMock.getOnce("http://localhost:8081/api/v2/repositories/slarti/fjords", slartiFjords);
const expectedActions = [
{
@@ -400,12 +371,9 @@ describe("repos fetch", () => {
});
it("should dispatch FETCH_REPO_FAILURE, it the request for slarti/fjords fails", () => {
fetchMock.getOnce(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 500
}
);
fetchMock.getOnce("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 500
});
const store = mockStore({});
return store.dispatch(fetchRepoByLink(slartiFjords)).then(() => {
@@ -482,12 +450,9 @@ describe("repos fetch", () => {
});
it("should successfully delete repo slarti/fjords", () => {
fetchMock.delete(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 204
}
);
fetchMock.delete("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 204
});
const expectedActions = [
{
@@ -509,12 +474,9 @@ describe("repos fetch", () => {
});
it("should successfully delete repo slarti/fjords and call the callback", () => {
fetchMock.delete(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 204
}
);
fetchMock.delete("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 204
});
let callMe = "not yet";
@@ -529,12 +491,9 @@ describe("repos fetch", () => {
});
it("should disapatch failure on delete, if server returns status code 500", () => {
fetchMock.delete(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 500
}
);
fetchMock.delete("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 500
});
const store = mockStore({});
return store.dispatch(deleteRepo(slartiFjords)).then(() => {
@@ -550,14 +509,11 @@ describe("repos fetch", () => {
fetchMock.putOnce(slartiFjords._links.update.href, {
status: 204
});
fetchMock.getOnce(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 500
}
);
fetchMock.getOnce("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 500
});
let editedFjords = {
const editedFjords = {
...slartiFjords
};
editedFjords.description = "coast of africa";
@@ -576,14 +532,11 @@ describe("repos fetch", () => {
fetchMock.putOnce(slartiFjords._links.update.href, {
status: 204
});
fetchMock.getOnce(
"http://localhost:8081/api/v2/repositories/slarti/fjords",
{
status: 500
}
);
fetchMock.getOnce("http://localhost:8081/api/v2/repositories/slarti/fjords", {
status: 500
});
let editedFjords = {
const editedFjords = {
...slartiFjords
};
editedFjords.description = "coast of africa";
@@ -609,7 +562,7 @@ describe("repos fetch", () => {
status: 500
});
let editedFjords = {
const editedFjords = {
...slartiFjords
};
editedFjords.description = "coast of africa";
@@ -737,9 +690,7 @@ describe("repos selectors", () => {
};
const link = getPermissionsLink(state, "slarti", "fjords");
expect(link).toEqual(
"http://localhost:8081/api/v2/repositories/slarti/fjords/permissions/"
);
expect(link).toEqual("http://localhost:8081/api/v2/repositories/slarti/fjords/permissions/");
});
it("should return true, when fetch repo is pending", () => {

View File

@@ -1,10 +1,6 @@
import { apiClient } from "@scm-manager/ui-components";
import * as types from "../../modules/types";
import {
Action,
Repository,
RepositoryCollection
} from "@scm-manager/ui-types";
import { Action, Repository, RepositoryCollection } from "@scm-manager/ui-types";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
@@ -47,9 +43,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)}`
);
return fetchReposByLink(`${link}?page=${page - 1}&q=${decodeURIComponent(filter)}`);
}
return fetchReposByLink(`${link}?page=${page - 1}`);
}
@@ -147,11 +141,7 @@ export function fetchRepoSuccess(repository: Repository): Action {
};
}
export function fetchRepoFailure(
namespace: string,
name: string,
error: Error
): Action {
export function fetchRepoFailure(namespace: string, name: string, error: Error): Action {
return {
type: FETCH_REPO_FAILURE,
payload: {
@@ -165,11 +155,7 @@ export function fetchRepoFailure(
// create repo
export function createRepo(
link: string,
repository: Repository,
callback?: (repo: Repository) => void
) {
export function createRepo(link: string, repository: Repository, callback?: (repo: Repository) => void) {
return function(dispatch: any) {
dispatch(createRepoPending());
return apiClient
@@ -255,10 +241,7 @@ export function modifyRepoSuccess(repository: Repository): Action {
};
}
export function modifyRepoFailure(
repository: Repository,
error: Error
): Action {
export function modifyRepoFailure(repository: Repository, error: Error): Action {
return {
type: MODIFY_REPO_FAILURE,
payload: {
@@ -314,10 +297,7 @@ export function deleteRepoSuccess(repository: Repository): Action {
};
}
export function deleteRepoFailure(
repository: Repository,
error: Error
): Action {
export function deleteRepoFailure(repository: Repository, error: Error): Action {
return {
type: DELETE_REPO_FAILURE,
payload: {
@@ -334,9 +314,7 @@ function createIdentifier(repository: Repository) {
return repository.namespace + "/" + repository.name;
}
function normalizeByNamespaceAndName(
repositoryCollection: RepositoryCollection
) {
function normalizeByNamespaceAndName(repositoryCollection: RepositoryCollection) {
const names = [];
const byNames = {};
for (const repository of repositoryCollection._embedded.repositories) {
@@ -391,7 +369,7 @@ export default function reducer(
export function getRepositoryCollection(state: object) {
if (state.repos && state.repos.list && state.repos.byNames) {
const repositories = [];
for (let repositoryName of state.repos.list._embedded.repositories) {
for (const repositoryName of state.repos.list._embedded.repositories) {
repositories.push(state.repos.byNames[repositoryName]);
}
return {
@@ -417,29 +395,16 @@ export function getRepository(state: object, namespace: string, name: string) {
}
}
export function isFetchRepoPending(
state: object,
namespace: string,
name: string
) {
export function isFetchRepoPending(state: object, namespace: string, name: string) {
return isPending(state, FETCH_REPO, namespace + "/" + name);
}
export function getFetchRepoFailure(
state: object,
namespace: string,
name: string
) {
export function getFetchRepoFailure(state: object, namespace: string, name: string) {
return getFailure(state, FETCH_REPO, namespace + "/" + name);
}
export function isAbleToCreateRepos(state: object) {
return !!(
state.repos &&
state.repos.list &&
state.repos.list._links &&
state.repos.list._links.create
);
return !!(state.repos && state.repos.list && state.repos.list._links && state.repos.list._links.create);
}
export function isCreateRepoPending(state: object) {
@@ -450,43 +415,23 @@ export function getCreateRepoFailure(state: object) {
return getFailure(state, CREATE_REPO);
}
export function isModifyRepoPending(
state: object,
namespace: string,
name: string
) {
export function isModifyRepoPending(state: object, namespace: string, name: string) {
return isPending(state, MODIFY_REPO, namespace + "/" + name);
}
export function getModifyRepoFailure(
state: object,
namespace: string,
name: string
) {
export function getModifyRepoFailure(state: object, namespace: string, name: string) {
return getFailure(state, MODIFY_REPO, namespace + "/" + name);
}
export function isDeleteRepoPending(
state: object,
namespace: string,
name: string
) {
export function isDeleteRepoPending(state: object, namespace: string, name: string) {
return isPending(state, DELETE_REPO, namespace + "/" + name);
}
export function getDeleteRepoFailure(
state: object,
namespace: string,
name: string
) {
export function getDeleteRepoFailure(state: object, namespace: string, name: string) {
return getFailure(state, DELETE_REPO, namespace + "/" + name);
}
export function getPermissionsLink(
state: object,
namespace: string,
name: string
) {
export function getPermissionsLink(state: object, namespace: string, name: string) {
const repo = getRepository(state, namespace, name);
return repo && repo._links ? repo._links.permissions.href : undefined;
}

View File

@@ -1,9 +1,5 @@
import * as types from "../../modules/types";
import {
Action,
RepositoryType,
RepositoryTypeCollection
} from "@scm-manager/ui-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";
@@ -35,10 +31,7 @@ function fetchRepositoryTypes(dispatch: any) {
}
export function shouldFetchRepositoryTypes(state: object) {
if (
isFetchRepositoryTypesPending(state) ||
getFetchRepositoryTypesFailure(state)
) {
if (isFetchRepositoryTypesPending(state) || getFetchRepositoryTypesFailure(state)) {
return false;
}
return !(state.repositoryTypes && state.repositoryTypes.length > 0);
@@ -50,9 +43,7 @@ export function fetchRepositoryTypesPending(): Action {
};
}
export function fetchRepositoryTypesSuccess(
repositoryTypes: RepositoryTypeCollection
): Action {
export function fetchRepositoryTypesSuccess(repositoryTypes: RepositoryTypeCollection): Action {
return {
type: FETCH_REPOSITORY_TYPES_SUCCESS,
payload: repositoryTypes