mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
fix fetching available_repository_roles & available_repository_verbs
This commit is contained in:
@@ -127,6 +127,14 @@ export function getUsersLink(state: Object) {
|
|||||||
return getLink(state, "users");
|
return getLink(state, "users");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRepositoryRolesLink(state: Object) {
|
||||||
|
return getLink(state, "repositoryRoles");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRepositoryVerbsLink(state: Object) {
|
||||||
|
return getLink(state, "repositoryVerbs");
|
||||||
|
}
|
||||||
|
|
||||||
export function getGroupsLink(state: Object) {
|
export function getGroupsLink(state: Object) {
|
||||||
return getLink(state, "groups");
|
return getLink(state, "groups");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import RoleSelector from "../components/RoleSelector";
|
import RoleSelector from "../components/RoleSelector";
|
||||||
import type {
|
import type {
|
||||||
AvailableRepositoryPermissions,
|
RepositoryRole,
|
||||||
PermissionCollection,
|
PermissionCollection,
|
||||||
PermissionCreateEntry,
|
PermissionCreateEntry,
|
||||||
SelectValue
|
SelectValue
|
||||||
@@ -21,7 +21,8 @@ import AdvancedPermissionsDialog from "./AdvancedPermissionsDialog";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
t: string => string,
|
||||||
availablePermissions: AvailableRepositoryPermissions,
|
availableRoles: RepositoryRole[],
|
||||||
|
availableVerbs: string[],
|
||||||
createPermission: (permission: PermissionCreateEntry) => void,
|
createPermission: (permission: PermissionCreateEntry) => void,
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
currentPermissions: PermissionCollection,
|
currentPermissions: PermissionCollection,
|
||||||
@@ -44,7 +45,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
name: "",
|
name: "",
|
||||||
verbs: props.availablePermissions.availableRoles[0].verbs,
|
verbs: props.availableRoles[0].verbs,
|
||||||
groupPermission: false,
|
groupPermission: false,
|
||||||
valid: true,
|
valid: true,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
@@ -132,18 +133,18 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { t, availablePermissions, loading } = this.props;
|
const { t, availableRoles, availableVerbs, loading } = this.props;
|
||||||
|
|
||||||
const { verbs, showAdvancedDialog } = this.state;
|
const { verbs, showAdvancedDialog } = this.state;
|
||||||
|
|
||||||
const availableRoleNames = availablePermissions.availableRoles.map(
|
const availableRoleNames = availableRoles.map(
|
||||||
r => r.name
|
r => r.name
|
||||||
);
|
);
|
||||||
const matchingRole = findMatchingRoleName(availablePermissions, verbs);
|
const matchingRole = findMatchingRoleName(availableRoles, verbs);
|
||||||
|
|
||||||
const advancedDialog = showAdvancedDialog ? (
|
const advancedDialog = showAdvancedDialog ? (
|
||||||
<AdvancedPermissionsDialog
|
<AdvancedPermissionsDialog
|
||||||
availableVerbs={availablePermissions.availableVerbs}
|
availableVerbs={availableVerbs}
|
||||||
selectedVerbs={verbs}
|
selectedVerbs={verbs}
|
||||||
onClose={this.closeAdvancedPermissionsDialog}
|
onClose={this.closeAdvancedPermissionsDialog}
|
||||||
onSubmit={this.submitAdvancedPermissionsDialog}
|
onSubmit={this.submitAdvancedPermissionsDialog}
|
||||||
@@ -246,7 +247,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
removeState = () => {
|
removeState = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
name: "",
|
name: "",
|
||||||
verbs: this.props.availablePermissions.availableRoles[0].verbs,
|
verbs: this.props.availableRoles[0].verbs,
|
||||||
valid: true,
|
valid: true,
|
||||||
value: undefined
|
value: undefined
|
||||||
});
|
});
|
||||||
@@ -263,7 +264,7 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
findAvailableRole = (roleName: string) => {
|
findAvailableRole = (roleName: string) => {
|
||||||
return this.props.availablePermissions.availableRoles.find(
|
return this.props.availableRoles.find(
|
||||||
role => role.name === roleName
|
role => role.name === roleName
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
getDeletePermissionsFailure,
|
getDeletePermissionsFailure,
|
||||||
getModifyPermissionsFailure,
|
getModifyPermissionsFailure,
|
||||||
modifyPermissionReset,
|
modifyPermissionReset,
|
||||||
deletePermissionReset
|
deletePermissionReset, getAvailableRepositoryRoles, getAvailableRepositoryVerbs
|
||||||
} from "../modules/permissions";
|
} from "../modules/permissions";
|
||||||
import {
|
import {
|
||||||
Loading,
|
Loading,
|
||||||
@@ -28,22 +28,23 @@ import {
|
|||||||
LabelWithHelpIcon
|
LabelWithHelpIcon
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import type {
|
import type {
|
||||||
AvailableRepositoryPermissions,
|
|
||||||
Permission,
|
Permission,
|
||||||
PermissionCollection,
|
PermissionCollection,
|
||||||
PermissionCreateEntry
|
PermissionCreateEntry,
|
||||||
|
RepositoryRole
|
||||||
} from "@scm-manager/ui-types";
|
} from "@scm-manager/ui-types";
|
||||||
import SinglePermission from "./SinglePermission";
|
import SinglePermission from "./SinglePermission";
|
||||||
import CreatePermissionForm from "./CreatePermissionForm";
|
import CreatePermissionForm from "./CreatePermissionForm";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { getPermissionsLink } from "../../modules/repos";
|
import { getPermissionsLink } from "../../modules/repos";
|
||||||
import {
|
import {
|
||||||
getGroupAutoCompleteLink,
|
getGroupAutoCompleteLink, getRepositoryRolesLink, getRepositoryVerbsLink,
|
||||||
getUserAutoCompleteLink
|
getUserAutoCompleteLink
|
||||||
} from "../../../modules/indexResource";
|
} from "../../../modules/indexResource";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
availablePermissions: AvailableRepositoryPermissions,
|
availableRepositoryRoles: RepositoryRole[],
|
||||||
|
availableVerbs: string[],
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string,
|
repoName: string,
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
@@ -51,6 +52,8 @@ type Props = {
|
|||||||
permissions: PermissionCollection,
|
permissions: PermissionCollection,
|
||||||
hasPermissionToCreate: boolean,
|
hasPermissionToCreate: boolean,
|
||||||
loadingCreatePermission: boolean,
|
loadingCreatePermission: boolean,
|
||||||
|
repositoryRolesLink: string,
|
||||||
|
repositoryVerbsLink: string,
|
||||||
permissionsLink: string,
|
permissionsLink: string,
|
||||||
groupAutoCompleteLink: string,
|
groupAutoCompleteLink: string,
|
||||||
userAutoCompleteLink: string,
|
userAutoCompleteLink: string,
|
||||||
@@ -85,13 +88,15 @@ class Permissions extends React.Component<Props> {
|
|||||||
modifyPermissionReset,
|
modifyPermissionReset,
|
||||||
createPermissionReset,
|
createPermissionReset,
|
||||||
deletePermissionReset,
|
deletePermissionReset,
|
||||||
permissionsLink
|
permissionsLink,
|
||||||
|
repositoryRolesLink,
|
||||||
|
repositoryVerbsLink
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
createPermissionReset(namespace, repoName);
|
createPermissionReset(namespace, repoName);
|
||||||
modifyPermissionReset(namespace, repoName);
|
modifyPermissionReset(namespace, repoName);
|
||||||
deletePermissionReset(namespace, repoName);
|
deletePermissionReset(namespace, repoName);
|
||||||
fetchAvailablePermissionsIfNeeded();
|
fetchAvailablePermissionsIfNeeded(repositoryRolesLink, repositoryVerbsLink);
|
||||||
fetchPermissions(permissionsLink, namespace, repoName);
|
fetchPermissions(permissionsLink, namespace, repoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +112,8 @@ class Permissions extends React.Component<Props> {
|
|||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
availablePermissions,
|
availablePermissions,
|
||||||
|
availableRepositoryRoles,
|
||||||
|
availableVerbs,
|
||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
permissions,
|
permissions,
|
||||||
@@ -134,7 +141,8 @@ class Permissions extends React.Component<Props> {
|
|||||||
|
|
||||||
const createPermissionForm = hasPermissionToCreate ? (
|
const createPermissionForm = hasPermissionToCreate ? (
|
||||||
<CreatePermissionForm
|
<CreatePermissionForm
|
||||||
availablePermissions={availablePermissions}
|
availableRoles={availableRepositoryRoles}
|
||||||
|
availableVerbs={availableVerbs}
|
||||||
createPermission={permission => this.createPermission(permission)}
|
createPermission={permission => this.createPermission(permission)}
|
||||||
loading={loadingCreatePermission}
|
loading={loadingCreatePermission}
|
||||||
currentPermissions={permissions}
|
currentPermissions={permissions}
|
||||||
@@ -174,7 +182,8 @@ class Permissions extends React.Component<Props> {
|
|||||||
{permissions.map(permission => {
|
{permissions.map(permission => {
|
||||||
return (
|
return (
|
||||||
<SinglePermission
|
<SinglePermission
|
||||||
availablePermissions={availablePermissions}
|
availableRepositoryRoles={availableRepositoryRoles}
|
||||||
|
availableRepositoryVerbs={availableVerbs}
|
||||||
key={permission.name + permission.groupPermission.toString()}
|
key={permission.name + permission.groupPermission.toString()}
|
||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
repoName={repoName}
|
repoName={repoName}
|
||||||
@@ -209,14 +218,23 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
repoName
|
repoName
|
||||||
);
|
);
|
||||||
const hasPermissionToCreate = hasCreatePermission(state, namespace, repoName);
|
const hasPermissionToCreate = hasCreatePermission(state, namespace, repoName);
|
||||||
|
const repositoryRolesLink = getRepositoryRolesLink(state);
|
||||||
|
const repositoryVerbsLink = getRepositoryVerbsLink(state);
|
||||||
const permissionsLink = getPermissionsLink(state, namespace, repoName);
|
const permissionsLink = getPermissionsLink(state, namespace, repoName);
|
||||||
const groupAutoCompleteLink = getGroupAutoCompleteLink(state);
|
const groupAutoCompleteLink = getGroupAutoCompleteLink(state);
|
||||||
const userAutoCompleteLink = getUserAutoCompleteLink(state);
|
const userAutoCompleteLink = getUserAutoCompleteLink(state);
|
||||||
const availablePermissions = getAvailablePermissions(state);
|
const availablePermissions = getAvailablePermissions(state);
|
||||||
|
const availableRepositoryRoles = getAvailableRepositoryRoles(state);
|
||||||
|
const availableVerbs = getAvailableRepositoryVerbs(state);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
availablePermissions,
|
availablePermissions,
|
||||||
|
availableRepositoryRoles,
|
||||||
|
availableVerbs,
|
||||||
namespace,
|
namespace,
|
||||||
repoName,
|
repoName,
|
||||||
|
repositoryRolesLink,
|
||||||
|
repositoryVerbsLink,
|
||||||
error,
|
error,
|
||||||
loading,
|
loading,
|
||||||
permissions,
|
permissions,
|
||||||
@@ -233,8 +251,8 @@ const mapDispatchToProps = dispatch => {
|
|||||||
fetchPermissions: (link: string, namespace: string, repoName: string) => {
|
fetchPermissions: (link: string, namespace: string, repoName: string) => {
|
||||||
dispatch(fetchPermissions(link, namespace, repoName));
|
dispatch(fetchPermissions(link, namespace, repoName));
|
||||||
},
|
},
|
||||||
fetchAvailablePermissionsIfNeeded: () => {
|
fetchAvailablePermissionsIfNeeded: (repositoryRolesLink: string, repositoryVerbsLink: string) => {
|
||||||
dispatch(fetchAvailablePermissionsIfNeeded());
|
dispatch(fetchAvailablePermissionsIfNeeded(repositoryRolesLink, repositoryVerbsLink));
|
||||||
},
|
},
|
||||||
createPermission: (
|
createPermission: (
|
||||||
link: string,
|
link: string,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type {
|
import type {
|
||||||
AvailableRepositoryPermissions,
|
RepositoryRole,
|
||||||
Permission
|
Permission
|
||||||
} from "@scm-manager/ui-types";
|
} from "@scm-manager/ui-types";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
@@ -22,7 +22,8 @@ import classNames from "classnames";
|
|||||||
import injectSheet from "react-jss";
|
import injectSheet from "react-jss";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
availablePermissions: AvailableRepositoryPermissions,
|
availableRepositoryRoles: RepositoryRole[],
|
||||||
|
availableRepositoryVerbs: string[],
|
||||||
submitForm: Permission => void,
|
submitForm: Permission => void,
|
||||||
modifyPermission: (
|
modifyPermission: (
|
||||||
permission: Permission,
|
permission: Permission,
|
||||||
@@ -68,8 +69,8 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const defaultPermission = props.availablePermissions.availableRoles
|
const defaultPermission = props.availableRoles
|
||||||
? props.availablePermissions.availableRoles[0]
|
? props.availableRoles[0]
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -85,10 +86,10 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { availablePermissions, permission } = this.props;
|
const { availableRepositoryRoles, permission } = this.props;
|
||||||
|
|
||||||
const matchingRole = findMatchingRoleName(
|
const matchingRole = findMatchingRoleName(
|
||||||
availablePermissions,
|
availableRepositoryRoles,
|
||||||
permission.verbs
|
permission.verbs
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -117,13 +118,14 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
const { role, permission, showAdvancedDialog } = this.state;
|
const { role, permission, showAdvancedDialog } = this.state;
|
||||||
const {
|
const {
|
||||||
t,
|
t,
|
||||||
availablePermissions,
|
availableRepositoryRoles,
|
||||||
|
availableRepositoryVerbs,
|
||||||
loading,
|
loading,
|
||||||
namespace,
|
namespace,
|
||||||
repoName,
|
repoName,
|
||||||
classes
|
classes
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const availableRoleNames = availablePermissions.availableRoles.map(
|
const availableRoleNames = !!availableRepositoryRoles && availableRepositoryRoles.map(
|
||||||
r => r.name
|
r => r.name
|
||||||
);
|
);
|
||||||
const readOnly = !this.mayChangePermissions();
|
const readOnly = !this.mayChangePermissions();
|
||||||
@@ -143,7 +145,7 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
const advancedDialg = showAdvancedDialog ? (
|
const advancedDialg = showAdvancedDialog ? (
|
||||||
<AdvancedPermissionsDialog
|
<AdvancedPermissionsDialog
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
availableVerbs={availablePermissions.availableVerbs}
|
availableVerbs={availableRepositoryVerbs}
|
||||||
selectedVerbs={permission.verbs}
|
selectedVerbs={permission.verbs}
|
||||||
onClose={this.closeAdvancedPermissionsDialog}
|
onClose={this.closeAdvancedPermissionsDialog}
|
||||||
onSubmit={this.submitAdvancedPermissionsDialog}
|
onSubmit={this.submitAdvancedPermissionsDialog}
|
||||||
@@ -198,7 +200,7 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
submitAdvancedPermissionsDialog = (newVerbs: string[]) => {
|
submitAdvancedPermissionsDialog = (newVerbs: string[]) => {
|
||||||
const { permission } = this.state;
|
const { permission } = this.state;
|
||||||
const newRole = findMatchingRoleName(
|
const newRole = findMatchingRoleName(
|
||||||
this.props.availablePermissions,
|
this.props.availableRoles,
|
||||||
newVerbs
|
newVerbs
|
||||||
);
|
);
|
||||||
this.setState(
|
this.setState(
|
||||||
@@ -226,7 +228,8 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
findAvailableRole = (roleName: string) => {
|
findAvailableRole = (roleName: string) => {
|
||||||
return this.props.availablePermissions.availableRoles.find(
|
const { availableRepositoryRoles } = this.props;
|
||||||
|
return availableRepositoryRoles.find(
|
||||||
role => role.name === roleName
|
role => role.name === roleName
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { Action } from "@scm-manager/ui-components";
|
|||||||
import { apiClient } from "@scm-manager/ui-components";
|
import { apiClient } from "@scm-manager/ui-components";
|
||||||
import * as types from "../../../modules/types";
|
import * as types from "../../../modules/types";
|
||||||
import type {
|
import type {
|
||||||
AvailableRepositoryPermissions,
|
RepositoryRole,
|
||||||
Permission,
|
Permission,
|
||||||
PermissionCollection,
|
PermissionCollection,
|
||||||
PermissionCreateEntry
|
PermissionCreateEntry
|
||||||
@@ -12,7 +12,6 @@ import type {
|
|||||||
import { isPending } from "../../../modules/pending";
|
import { isPending } from "../../../modules/pending";
|
||||||
import { getFailure } from "../../../modules/failure";
|
import { getFailure } from "../../../modules/failure";
|
||||||
import { Dispatch } from "redux";
|
import { Dispatch } from "redux";
|
||||||
import { getLinks } from "../../../modules/indexResource";
|
|
||||||
|
|
||||||
export const FETCH_AVAILABLE = "scm/permissions/FETCH_AVAILABLE";
|
export const FETCH_AVAILABLE = "scm/permissions/FETCH_AVAILABLE";
|
||||||
export const FETCH_AVAILABLE_PENDING = `${FETCH_AVAILABLE}_${
|
export const FETCH_AVAILABLE_PENDING = `${FETCH_AVAILABLE}_${
|
||||||
@@ -78,22 +77,36 @@ const CONTENT_TYPE = "application/vnd.scmm-repositoryPermission+json";
|
|||||||
|
|
||||||
// fetch available permissions
|
// fetch available permissions
|
||||||
|
|
||||||
export function fetchAvailablePermissionsIfNeeded() {
|
export function fetchAvailablePermissionsIfNeeded(repositoryRolesLink: string, repositoryVerbsLink: string) {
|
||||||
return function(dispatch: any, getState: () => Object) {
|
return function(dispatch: any, getState: () => Object) {
|
||||||
if (shouldFetchAvailablePermissions(getState())) {
|
if (shouldFetchAvailablePermissions(getState())) {
|
||||||
return fetchAvailablePermissions(dispatch, getState);
|
return fetchAvailablePermissions(dispatch, getState, repositoryRolesLink, repositoryVerbsLink);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchAvailablePermissions(
|
export function fetchAvailablePermissions(
|
||||||
dispatch: any,
|
dispatch: any,
|
||||||
getState: () => Object
|
getState: () => Object,
|
||||||
|
repositoryRolesLink: string,
|
||||||
|
repositoryVerbsLink: string
|
||||||
) {
|
) {
|
||||||
dispatch(fetchAvailablePending());
|
dispatch(fetchAvailablePending());
|
||||||
return apiClient
|
return apiClient
|
||||||
.get(getLinks(getState()).availableRepositoryPermissions.href)
|
.get(repositoryRolesLink)
|
||||||
.then(response => response.json())
|
.then(repositoryRoles => repositoryRoles.json())
|
||||||
|
.then(repositoryRoles => repositoryRoles._embedded.repositoryRoles)
|
||||||
|
.then(repositoryRoles => {
|
||||||
|
return apiClient.get(repositoryVerbsLink)
|
||||||
|
.then(repositoryVerbs => repositoryVerbs.json())
|
||||||
|
.then(repositoryVerbs => repositoryVerbs.verbs)
|
||||||
|
.then(repositoryVerbs => {
|
||||||
|
return {
|
||||||
|
repositoryVerbs,
|
||||||
|
repositoryRoles
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
.then(available => {
|
.then(available => {
|
||||||
dispatch(fetchAvailableSuccess(available));
|
dispatch(fetchAvailableSuccess(available));
|
||||||
})
|
})
|
||||||
@@ -121,7 +134,7 @@ export function fetchAvailablePending(): Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fetchAvailableSuccess(
|
export function fetchAvailableSuccess(
|
||||||
available: AvailableRepositoryPermissions
|
available: [RepositoryRole[], string[]]
|
||||||
): Action {
|
): Action {
|
||||||
return {
|
return {
|
||||||
type: FETCH_AVAILABLE_SUCCESS,
|
type: FETCH_AVAILABLE_SUCCESS,
|
||||||
@@ -543,6 +556,21 @@ export function getAvailablePermissions(state: Object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAvailableRepositoryRoles(state: Object) {
|
||||||
|
return available(state).repositoryRoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAvailableRepositoryVerbs(state: Object) {
|
||||||
|
return available(state).repositoryVerbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function available(state: Object) {
|
||||||
|
if (state.permissions && state.permissions.available) {
|
||||||
|
return state.permissions.available;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
export function getPermissionsOfRepo(
|
export function getPermissionsOfRepo(
|
||||||
state: Object,
|
state: Object,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
@@ -705,13 +733,13 @@ export function getModifyPermissionsFailure(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function findMatchingRoleName(
|
export function findMatchingRoleName(
|
||||||
availablePermissions: AvailableRepositoryPermissions,
|
availableRoles: RepositoryRole[],
|
||||||
verbs: string[]
|
verbs: string[]
|
||||||
) {
|
) {
|
||||||
if (!verbs) {
|
if (!verbs) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
const matchingRole = availablePermissions.availableRoles.find(role => {
|
const matchingRole = !! availableRoles && availableRoles.find(role => {
|
||||||
return equalVerbs(role.verbs, verbs);
|
return equalVerbs(role.verbs, verbs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user