add check if links exists in order to update permissions directly before fetching

This commit is contained in:
Maren Süwer
2018-09-07 10:04:42 +02:00
parent 50d0769db0
commit 46132585e8
3 changed files with 7 additions and 6 deletions

View File

@@ -90,7 +90,7 @@ class SinglePermission extends React.Component<Props, State> {
render() {
const { permission } = this.state;
const { loading, error, namespace, repoName } = this.props;
const typeSelector = this.props.permission._links.update ? (
const typeSelector = this.props.permission._links && this.props.permission._links.update ? (
<td>
<TypeSelector
handleTypeChange={this.handleTypeChange}

View File

@@ -424,8 +424,8 @@ export default function reducer(
}
};
case CREATE_PERMISSION_SUCCESS:
return state;
/* const position = action.payload.position;
// return state;
const position = action.payload.position;
const permissions = state[action.payload.position].entries;
permissions.push(action.payload.permission);
return {
@@ -434,7 +434,7 @@ export default function reducer(
...state[position],
entries: permissions
}
};*/
};
case DELETE_PERMISSION_SUCCESS:
const permissionPosition = action.payload.position;
const new_Permissions = deletePermissionFromState(

View File

@@ -471,7 +471,8 @@ describe("permissions reducer", () => {
);
});
/*it("should add permission", () => { //changing state had to be removed because of errors
it("should add permission", () => {
//changing state had to be removed because of errors
const oldState = {
"hitchhiker/puzzle42": {
entries: [hitchhiker_puzzle42Permission_user_eins]
@@ -496,7 +497,7 @@ describe("permissions reducer", () => {
expect(newState["hitchhiker/puzzle42"]).toEqual(
expectedState["hitchhiker/puzzle42"]
);
});*/
});
});
describe("permissions selectors", () => {