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() { render() {
const { permission } = this.state; const { permission } = this.state;
const { loading, error, namespace, repoName } = this.props; 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> <td>
<TypeSelector <TypeSelector
handleTypeChange={this.handleTypeChange} handleTypeChange={this.handleTypeChange}

View File

@@ -424,8 +424,8 @@ export default function reducer(
} }
}; };
case CREATE_PERMISSION_SUCCESS: case CREATE_PERMISSION_SUCCESS:
return state; // return state;
/* const position = action.payload.position; const position = action.payload.position;
const permissions = state[action.payload.position].entries; const permissions = state[action.payload.position].entries;
permissions.push(action.payload.permission); permissions.push(action.payload.permission);
return { return {
@@ -434,7 +434,7 @@ export default function reducer(
...state[position], ...state[position],
entries: permissions 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(

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 = { const oldState = {
"hitchhiker/puzzle42": { "hitchhiker/puzzle42": {
entries: [hitchhiker_puzzle42Permission_user_eins] entries: [hitchhiker_puzzle42Permission_user_eins]
@@ -496,7 +497,7 @@ describe("permissions reducer", () => {
expect(newState["hitchhiker/puzzle42"]).toEqual( expect(newState["hitchhiker/puzzle42"]).toEqual(
expectedState["hitchhiker/puzzle42"] expectedState["hitchhiker/puzzle42"]
); );
});*/ });
}); });
describe("permissions selectors", () => { describe("permissions selectors", () => {