mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-06 12:07:53 +02:00
remove redundancy, run prettier
This commit is contained in:
@@ -307,10 +307,9 @@ const reduceByBranchesSuccess = (state, payload) => {
|
||||
const byName = repoState.byName || {};
|
||||
repoState.byName = byName;
|
||||
|
||||
if(response._embedded) {
|
||||
if (response._embedded) {
|
||||
const branches = response._embedded.branches;
|
||||
const names = branches.map(b => b.name);
|
||||
response._embedded.branches = names;
|
||||
response._embedded.branches = branches.map(b => b.name);
|
||||
for (let branch of branches) {
|
||||
byName[branch.name] = branch;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
// @flow
|
||||
|
||||
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 type {Action, Branch, PagedCollection, Repository} from "@scm-manager/ui-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 type {
|
||||
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}`;
|
||||
|
||||
@@ -353,15 +353,13 @@ function normalizeByNamespaceAndName(
|
||||
|
||||
const reducerByNames = (state: Object, repository: Repository) => {
|
||||
const identifier = createIdentifier(repository);
|
||||
const newState = {
|
||||
return {
|
||||
...state,
|
||||
byNames: {
|
||||
...state.byNames,
|
||||
[identifier]: repository
|
||||
}
|
||||
};
|
||||
|
||||
return newState;
|
||||
};
|
||||
|
||||
export default function reducer(
|
||||
|
||||
@@ -49,10 +49,7 @@ export function shouldFetchRepositoryTypes(state: Object) {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (state.repositoryTypes && state.repositoryTypes.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(state.repositoryTypes && state.repositoryTypes.length > 0);
|
||||
}
|
||||
|
||||
export function fetchRepositoryTypesPending(): Action {
|
||||
|
||||
@@ -77,10 +77,18 @@ const CONTENT_TYPE = "application/vnd.scmm-repositoryPermission+json";
|
||||
|
||||
// fetch available permissions
|
||||
|
||||
export function fetchAvailablePermissionsIfNeeded(repositoryRolesLink: string, repositoryVerbsLink: string) {
|
||||
export function fetchAvailablePermissionsIfNeeded(
|
||||
repositoryRolesLink: string,
|
||||
repositoryVerbsLink: string
|
||||
) {
|
||||
return function(dispatch: any, getState: () => Object) {
|
||||
if (shouldFetchAvailablePermissions(getState())) {
|
||||
return fetchAvailablePermissions(dispatch, getState, repositoryRolesLink, repositoryVerbsLink);
|
||||
return fetchAvailablePermissions(
|
||||
dispatch,
|
||||
getState,
|
||||
repositoryRolesLink,
|
||||
repositoryVerbsLink
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -97,7 +105,8 @@ export function fetchAvailablePermissions(
|
||||
.then(repositoryRoles => repositoryRoles.json())
|
||||
.then(repositoryRoles => repositoryRoles._embedded.repositoryRoles)
|
||||
.then(repositoryRoles => {
|
||||
return apiClient.get(repositoryVerbsLink)
|
||||
return apiClient
|
||||
.get(repositoryVerbsLink)
|
||||
.then(repositoryVerbs => repositoryVerbs.json())
|
||||
.then(repositoryVerbs => repositoryVerbs.verbs)
|
||||
.then(repositoryVerbs => {
|
||||
@@ -577,8 +586,7 @@ export function getPermissionsOfRepo(
|
||||
repoName: string
|
||||
) {
|
||||
if (state.permissions && state.permissions[namespace + "/" + repoName]) {
|
||||
const permissions = state.permissions[namespace + "/" + repoName].entries;
|
||||
return permissions;
|
||||
return state.permissions[namespace + "/" + repoName].entries;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,9 +747,11 @@ export function findMatchingRoleName(
|
||||
if (!verbs) {
|
||||
return "";
|
||||
}
|
||||
const matchingRole = !! availableRoles && availableRoles.find(role => {
|
||||
return equalVerbs(role.verbs, verbs);
|
||||
});
|
||||
const matchingRole =
|
||||
!!availableRoles &&
|
||||
availableRoles.find(role => {
|
||||
return equalVerbs(role.verbs, verbs);
|
||||
});
|
||||
|
||||
if (matchingRole) {
|
||||
return matchingRole.name;
|
||||
|
||||
Reference in New Issue
Block a user