mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
add create permission possibility
This commit is contained in:
@@ -20,5 +20,9 @@
|
|||||||
"submit": "Yes",
|
"submit": "Yes",
|
||||||
"cancel": "No"
|
"cancel": "No"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"add-permission": {
|
||||||
|
"add-permission-heading": "Add new Permission",
|
||||||
|
"submit-button": "Submit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { Permission } from "../types/Permissions";
|
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
|
import { Checkbox, InputField } from "../../components/forms";
|
||||||
|
import TypeSelector from "./TypeSelector";
|
||||||
|
import type { Permission } from "../types/Permissions";
|
||||||
|
import { SubmitButton } from "../../components/buttons";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string
|
t: string => string,
|
||||||
|
createPermission: (permission: Permission) => void
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
permission: Permission
|
name: string,
|
||||||
|
type: string,
|
||||||
|
groupPermission: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
class CreatePermissionForm extends React.Component<Props, State> {
|
class CreatePermissionForm extends React.Component<Props, State> {
|
||||||
@@ -16,18 +22,84 @@ class CreatePermissionForm extends React.Component<Props, State> {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
permission: {
|
|
||||||
name: "",
|
name: "",
|
||||||
type: "READ",
|
type: "READ",
|
||||||
groupPermission: false,
|
groupPermission: false
|
||||||
_links: {}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return "Show Permissions here!";
|
const { t } = this.props;
|
||||||
|
const { name, type, groupPermission } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2 className="subtitle">
|
||||||
|
{t("add-permission.add-permission-heading")}
|
||||||
|
</h2>
|
||||||
|
<table className="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{t("permission.name")}</td>
|
||||||
|
<td>
|
||||||
|
<InputField
|
||||||
|
value={name ? name : ""}
|
||||||
|
onChange={this.handleNameChange}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("permission.group-permission")}</td>
|
||||||
|
<td>
|
||||||
|
<Checkbox
|
||||||
|
checked={groupPermission ? groupPermission : false}
|
||||||
|
onChange={this.handleGroupPermissionChange}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("permission.type")}</td>
|
||||||
|
<td>
|
||||||
|
<TypeSelector
|
||||||
|
handleTypeChange={this.handleTypeChange}
|
||||||
|
type={type ? type : "READ"}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<SubmitButton
|
||||||
|
label={t("add-permission.submit-button")}
|
||||||
|
action={this.submit}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
submit = () => {
|
||||||
|
this.props.createPermission({
|
||||||
|
name: this.state.name,
|
||||||
|
type: this.state.type,
|
||||||
|
groupPermission: this.state.groupPermission
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleTypeChange = (type: string) => {
|
||||||
|
this.setState({
|
||||||
|
type: type
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleNameChange = (name: string) => {
|
||||||
|
this.setState({
|
||||||
|
name: name
|
||||||
|
});
|
||||||
|
};
|
||||||
|
handleGroupPermissionChange = (groupPermission: boolean) => {
|
||||||
|
this.setState({
|
||||||
|
groupPermission: groupPermission
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translate("permissions")(CreatePermissionForm);
|
export default translate("permissions")(CreatePermissionForm);
|
||||||
|
|||||||
39
scm-ui/src/permissions/components/TypeSelector.js
Normal file
39
scm-ui/src/permissions/components/TypeSelector.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// @flow
|
||||||
|
import React from "react";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import { Select } from "../../components/forms";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
t: string => string,
|
||||||
|
handleTypeChange: string => void,
|
||||||
|
type: string,
|
||||||
|
loading?: boolean
|
||||||
|
};
|
||||||
|
|
||||||
|
class TypeSelector extends React.Component<Props> {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { t, type, handleTypeChange, loading } = this.props;
|
||||||
|
const types = ["READ", "OWNER", "GROUP"];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
onChange={handleTypeChange}
|
||||||
|
value={type ? type : ""}
|
||||||
|
options={this.createSelectOptions(types)}
|
||||||
|
loading={loading}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
createSelectOptions(types: string[]) {
|
||||||
|
return types.map(type => {
|
||||||
|
return {
|
||||||
|
label: type,
|
||||||
|
value: type
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("permissions")(TypeSelector);
|
||||||
@@ -7,11 +7,12 @@ import {
|
|||||||
getFetchPermissionsFailure,
|
getFetchPermissionsFailure,
|
||||||
isFetchPermissionsPending,
|
isFetchPermissionsPending,
|
||||||
getPermissionsOfRepo,
|
getPermissionsOfRepo,
|
||||||
hasCreatePermission
|
hasCreatePermission,
|
||||||
|
createPermission
|
||||||
} from "../modules/permissions";
|
} from "../modules/permissions";
|
||||||
import Loading from "../../components/Loading";
|
import Loading from "../../components/Loading";
|
||||||
import ErrorPage from "../../components/ErrorPage";
|
import ErrorPage from "../../components/ErrorPage";
|
||||||
import type { PermissionCollection } from "../types/Permissions";
|
import type { Permission, PermissionCollection } from "../types/Permissions";
|
||||||
import SinglePermission from "./SinglePermission";
|
import SinglePermission from "./SinglePermission";
|
||||||
import CreatePermissionForm from "../components/CreatePermissionForm";
|
import CreatePermissionForm from "../components/CreatePermissionForm";
|
||||||
|
|
||||||
@@ -25,6 +26,11 @@ type Props = {
|
|||||||
|
|
||||||
//dispatch functions
|
//dispatch functions
|
||||||
fetchPermissions: (namespace: string, name: string) => void,
|
fetchPermissions: (namespace: string, name: string) => void,
|
||||||
|
createPermission: (
|
||||||
|
permission: Permission,
|
||||||
|
namespace: string,
|
||||||
|
name: string
|
||||||
|
) => void,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
t: string => string,
|
t: string => string,
|
||||||
@@ -64,7 +70,11 @@ class Permissions extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createPermissionForm = createPermission ? (
|
const createPermissionForm = createPermission ? (
|
||||||
<CreatePermissionForm />
|
<CreatePermissionForm
|
||||||
|
createPermission={permission =>
|
||||||
|
this.props.createPermission(permission, namespace, name)
|
||||||
|
}
|
||||||
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
if (permissions.length > 0)
|
if (permissions.length > 0)
|
||||||
@@ -105,6 +115,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const error = getFetchPermissionsFailure(state, namespace, name);
|
const error = getFetchPermissionsFailure(state, namespace, name);
|
||||||
const loading = isFetchPermissionsPending(state, namespace, name);
|
const loading = isFetchPermissionsPending(state, namespace, name);
|
||||||
const permissions = getPermissionsOfRepo(state, namespace, name);
|
const permissions = getPermissionsOfRepo(state, namespace, name);
|
||||||
|
console.log(permissions);
|
||||||
const createPermission = hasCreatePermission(state, namespace, name);
|
const createPermission = hasCreatePermission(state, namespace, name);
|
||||||
return {
|
return {
|
||||||
namespace,
|
namespace,
|
||||||
@@ -120,6 +131,13 @@ const mapDispatchToProps = dispatch => {
|
|||||||
return {
|
return {
|
||||||
fetchPermissions: (namespace: string, name: string) => {
|
fetchPermissions: (namespace: string, name: string) => {
|
||||||
dispatch(fetchPermissions(namespace, name));
|
dispatch(fetchPermissions(namespace, name));
|
||||||
|
},
|
||||||
|
createPermission: (
|
||||||
|
permission: Permission,
|
||||||
|
namespace: string,
|
||||||
|
name: string
|
||||||
|
) => {
|
||||||
|
dispatch(createPermission(permission, namespace, name));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ import {
|
|||||||
isModifyPermissionPending,
|
isModifyPermissionPending,
|
||||||
getModifyPermissionFailure,
|
getModifyPermissionFailure,
|
||||||
modifyPermissionReset,
|
modifyPermissionReset,
|
||||||
deletePermission
|
deletePermission,
|
||||||
|
getDeletePermissionFailure,
|
||||||
|
isDeletePermissionPending
|
||||||
} from "../modules/permissions";
|
} from "../modules/permissions";
|
||||||
import connect from "react-redux/es/connect/connect";
|
import connect from "react-redux/es/connect/connect";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import ErrorNotification from "../../components/ErrorNotification";
|
import ErrorNotification from "../../components/ErrorNotification";
|
||||||
import DeletePermissionButton from "../components/buttons/DeletePermissionButton";
|
import DeletePermissionButton from "../components/buttons/DeletePermissionButton";
|
||||||
|
import TypeSelector from "../components/TypeSelector";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
submitForm: Permission => void,
|
submitForm: Permission => void,
|
||||||
@@ -29,7 +32,8 @@ type Props = {
|
|||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
error: Error,
|
||||||
permissionReset: (string, string, string) => void,
|
permissionReset: (string, string, string) => void,
|
||||||
deletePermission: (Permission, string, string, (void) => void) => void
|
deletePermission: (Permission, string, string) => void,
|
||||||
|
deleteLoading: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@@ -69,18 +73,11 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionDeleted = () => {
|
|
||||||
this.props.history.push(
|
|
||||||
"/repo/" + this.props.namespace + "/" + this.props.name + "/permissions"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
deletePermission = () => {
|
deletePermission = () => {
|
||||||
this.props.deletePermission(
|
this.props.deletePermission(
|
||||||
this.props.permission,
|
this.props.permission,
|
||||||
this.props.namespace,
|
this.props.namespace,
|
||||||
this.props.name,
|
this.props.name
|
||||||
this.permissionDeleted
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,10 +88,9 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
|
|
||||||
const typeSelector = this.props.permission._links.update ? (
|
const typeSelector = this.props.permission._links.update ? (
|
||||||
<td>
|
<td>
|
||||||
<Select
|
<TypeSelector
|
||||||
onChange={this.handleTypeChange}
|
handleTypeChange={this.handleTypeChange}
|
||||||
value={permission.type ? permission.type : ""}
|
type={permission.type ? permission.type : "READ"}
|
||||||
options={this.createSelectOptions(types)}
|
|
||||||
loading={loading}
|
loading={loading}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
@@ -119,6 +115,7 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
name={name}
|
name={name}
|
||||||
deletePermission={this.deletePermission}
|
deletePermission={this.deletePermission}
|
||||||
|
loading={this.props.deleteLoading}
|
||||||
/>
|
/>
|
||||||
{errorNotification}
|
{errorNotification}
|
||||||
</td>
|
</td>
|
||||||
@@ -158,20 +155,34 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const permission = ownProps.permission;
|
const permission = ownProps.permission;
|
||||||
|
console.log(permission);
|
||||||
const loading = isModifyPermissionPending(
|
const loading = isModifyPermissionPending(
|
||||||
state,
|
state,
|
||||||
ownProps.namespace,
|
ownProps.namespace,
|
||||||
ownProps.name,
|
ownProps.name,
|
||||||
permission.name
|
permission.name
|
||||||
);
|
);
|
||||||
const error = getModifyPermissionFailure(
|
const error =
|
||||||
|
getModifyPermissionFailure(
|
||||||
|
state,
|
||||||
|
ownProps.namespace,
|
||||||
|
ownProps.name,
|
||||||
|
permission.name
|
||||||
|
) ||
|
||||||
|
getDeletePermissionFailure(
|
||||||
|
state,
|
||||||
|
ownProps.namespace,
|
||||||
|
ownProps.name,
|
||||||
|
permission.name
|
||||||
|
);
|
||||||
|
const deleteLoading = isDeletePermissionPending(
|
||||||
state,
|
state,
|
||||||
ownProps.namespace,
|
ownProps.namespace,
|
||||||
ownProps.name,
|
ownProps.name,
|
||||||
permission.name
|
permission.name
|
||||||
);
|
);
|
||||||
|
|
||||||
return { loading, error };
|
return { loading, error, deleteLoading };
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
@@ -193,10 +204,9 @@ const mapDispatchToProps = dispatch => {
|
|||||||
deletePermission: (
|
deletePermission: (
|
||||||
permission: Permission,
|
permission: Permission,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
name: string,
|
name: string
|
||||||
callback: () => void
|
|
||||||
) => {
|
) => {
|
||||||
dispatch(deletePermission(permission, namespace, name, callback));
|
dispatch(deletePermission(permission, namespace, name));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export function createPermission(
|
|||||||
CONTENT_TYPE
|
CONTENT_TYPE
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(createPermissionSuccess(namespace, name));
|
dispatch(createPermissionSuccess(permission, namespace, name));
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@@ -252,11 +252,16 @@ export function createPermissionPending(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createPermissionSuccess(
|
export function createPermissionSuccess(
|
||||||
|
permission: Permission,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
name: string
|
name: string
|
||||||
): Action {
|
): Action {
|
||||||
return {
|
return {
|
||||||
type: CREATE_PERMISSION_SUCCESS,
|
type: CREATE_PERMISSION_SUCCESS,
|
||||||
|
payload: {
|
||||||
|
permission,
|
||||||
|
position: namespace + "/" + name
|
||||||
|
},
|
||||||
itemId: namespace + "/" + name
|
itemId: namespace + "/" + name
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -386,6 +391,17 @@ export default function reducer(
|
|||||||
entries: newPermission
|
entries: newPermission
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case CREATE_PERMISSION_SUCCESS:
|
||||||
|
const position = action.payload.position;
|
||||||
|
const permissions = state[action.payload.position].entries;
|
||||||
|
permissions.push(action.payload.permission);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
[position]: {
|
||||||
|
...state[position],
|
||||||
|
entries: permissions
|
||||||
|
}
|
||||||
|
};
|
||||||
case DELETE_PERMISSION_SUCCESS:
|
case DELETE_PERMISSION_SUCCESS:
|
||||||
const permissionPosition = action.payload.position;
|
const permissionPosition = action.payload.position;
|
||||||
const new_Permissions = deletePermissionFromState(
|
const new_Permissions = deletePermissionFromState(
|
||||||
@@ -468,3 +484,29 @@ export function hasCreatePermission(
|
|||||||
return state.permissions[namespace + "/" + name].createPermission;
|
return state.permissions[namespace + "/" + name].createPermission;
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isDeletePermissionPending(
|
||||||
|
state: Object,
|
||||||
|
namespace: string,
|
||||||
|
name: string,
|
||||||
|
permissionname: string
|
||||||
|
) {
|
||||||
|
return isPending(
|
||||||
|
state,
|
||||||
|
DELETE_PERMISSION,
|
||||||
|
namespace + "/" + name + "/" + permissionname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDeletePermissionFailure(
|
||||||
|
state: Object,
|
||||||
|
namespace: string,
|
||||||
|
name: string,
|
||||||
|
permissionname: string
|
||||||
|
) {
|
||||||
|
return getFailure(
|
||||||
|
state,
|
||||||
|
DELETE_PERMISSION,
|
||||||
|
namespace + "/" + name + "/" + permissionname
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import reducer, {
|
|||||||
hasCreatePermission,
|
hasCreatePermission,
|
||||||
deletePermission,
|
deletePermission,
|
||||||
deletePermissionSuccess,
|
deletePermissionSuccess,
|
||||||
|
getDeletePermissionFailure,
|
||||||
|
isDeletePermissionPending,
|
||||||
MODIFY_PERMISSION_FAILURE,
|
MODIFY_PERMISSION_FAILURE,
|
||||||
MODIFY_PERMISSION_PENDING,
|
MODIFY_PERMISSION_PENDING,
|
||||||
FETCH_PERMISSIONS,
|
FETCH_PERMISSIONS,
|
||||||
@@ -27,9 +29,11 @@ import reducer, {
|
|||||||
CREATE_PERMISSION_PENDING,
|
CREATE_PERMISSION_PENDING,
|
||||||
CREATE_PERMISSION_SUCCESS,
|
CREATE_PERMISSION_SUCCESS,
|
||||||
CREATE_PERMISSION_FAILURE,
|
CREATE_PERMISSION_FAILURE,
|
||||||
|
DELETE_PERMISSION,
|
||||||
DELETE_PERMISSION_PENDING,
|
DELETE_PERMISSION_PENDING,
|
||||||
DELETE_PERMISSION_SUCCESS,
|
DELETE_PERMISSION_SUCCESS,
|
||||||
DELETE_PERMISSION_FAILURE
|
DELETE_PERMISSION_FAILURE,
|
||||||
|
createPermissionSuccess
|
||||||
} from "./permissions";
|
} from "./permissions";
|
||||||
import type { Permission, PermissionCollection } from "../types/Permissions";
|
import type { Permission, PermissionCollection } from "../types/Permissions";
|
||||||
|
|
||||||
@@ -460,6 +464,33 @@ describe("permissions reducer", () => {
|
|||||||
expectedState["hitchhiker/puzzle42"]
|
expectedState["hitchhiker/puzzle42"]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should add permission", () => {
|
||||||
|
const oldState = {
|
||||||
|
"hitchhiker/puzzle42": {
|
||||||
|
entries: [hitchhiker_puzzle42Permission_user_eins]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let expectedState = {
|
||||||
|
"hitchhiker/puzzle42": {
|
||||||
|
entries: [
|
||||||
|
hitchhiker_puzzle42Permission_user_eins,
|
||||||
|
hitchhiker_puzzle42Permission_user_zwei
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const newState = reducer(
|
||||||
|
oldState,
|
||||||
|
createPermissionSuccess(
|
||||||
|
hitchhiker_puzzle42Permission_user_zwei,
|
||||||
|
"hitchhiker",
|
||||||
|
"puzzle42"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(newState["hitchhiker/puzzle42"]).toEqual(
|
||||||
|
expectedState["hitchhiker/puzzle42"]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("permissions selectors", () => {
|
describe("permissions selectors", () => {
|
||||||
@@ -571,4 +602,38 @@ describe("permissions selectors", () => {
|
|||||||
};
|
};
|
||||||
expect(hasCreatePermission(state, "hitchhiker", "puzzle42")).toEqual(false);
|
expect(hasCreatePermission(state, "hitchhiker", "puzzle42")).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return true, when delete permission is pending", () => {
|
||||||
|
const state = {
|
||||||
|
pending: {
|
||||||
|
[DELETE_PERMISSION + "/hitchhiker/puzzle42/user_eins"]: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(
|
||||||
|
isDeletePermissionPending(state, "hitchhiker", "puzzle42", "user_eins")
|
||||||
|
).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false, when delete permissions is not pending", () => {
|
||||||
|
expect(
|
||||||
|
isDeletePermissionPending({}, "hitchiker", "puzzle42", "user_eins")
|
||||||
|
).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return error when delete permissions did fail", () => {
|
||||||
|
const state = {
|
||||||
|
failure: {
|
||||||
|
[DELETE_PERMISSION + "/hitchhiker/puzzle42/user_eins"]: error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
expect(
|
||||||
|
getDeletePermissionFailure(state, "hitchhiker", "puzzle42", "user_eins")
|
||||||
|
).toEqual(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return undefined when delete permissions did not fail", () => {
|
||||||
|
expect(
|
||||||
|
getDeletePermissionFailure({}, "hitchhiker", "puzzle42", "user_eins")
|
||||||
|
).toBe(undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export type Permission = {
|
|||||||
name: string,
|
name: string,
|
||||||
type: string,
|
type: string,
|
||||||
groupPermission: boolean,
|
groupPermission: boolean,
|
||||||
_links: Links
|
_links?: Links
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PermissionCollection = Permission[];
|
export type PermissionCollection = Permission[];
|
||||||
|
|||||||
Reference in New Issue
Block a user