Skip to content

Commit

Permalink
Fix #377, #378: Allow dropping edited resource properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Feb 1, 2017
1 parent a227fd2 commit be155ce
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react-breadcrumbs": "^1.3.16",
"react-codemirror": "^0.2.3",
"react-dom": "^15.2.0",
"react-jsonschema-form": "^0.41.2",
"react-jsonschema-form": "^0.42.0",
"react-redux": "^4.0.0",
"react-router": "^2.7.0",
"react-router-redux": "4.0.5",
Expand Down
3 changes: 2 additions & 1 deletion src/components/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { Component } from "react";

import Spinner from "./Spinner";
import AuthForm from "./AuthForm";
import { isObject } from "../utils";


function ServerProps({node}: {node: Object}) {
Expand All @@ -17,7 +18,7 @@ function ServerProps({node}: {node: Object}) {
<tr key={i}>
<th>{key}</th>
<td style={{width: "100%"}}>{
typeof childNode === "object" ?
isObject(childNode) ?
<ServerProps node={childNode} /> :
typeof childNode === "string" && childNode.startsWith("http") ?
<a href={childNode} target="_blank">{childNode}</a> :
Expand Down
10 changes: 2 additions & 8 deletions src/sagas/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function* updateBucket(getState: GetStateFn, action: ActionType<typeof ac
if (data) {
const updatedBucket = {...data, last_modified};
yield call([bucket, bucket.setData], updatedBucket, {
patch: true,
safe: true,
});
yield put(redirectTo("bucket:attributes", {bid}));
Expand Down Expand Up @@ -102,9 +101,7 @@ export function* updateCollection(getState: GetStateFn, action: ActionType<typeo
const coll = getCollection(bid, cid);
if (data) {
const updatedCollection = {...data, last_modified};
yield call([coll, coll.setData], updatedCollection, {
patch: true,
safe: true});
yield call([coll, coll.setData], updatedCollection, {safe: true});
yield put(redirectTo("collection:records", {bid, cid}));
yield put(notifySuccess("Collection attributes updated."));
} else if (permissions) {
Expand Down Expand Up @@ -222,10 +219,7 @@ export function* updateGroup(getState: GetStateFn, action: ActionType<typeof act
const bucket = getBucket(bid);
if (data) {
const updatedGroup = {...data, id: gid, last_modified};
yield call([bucket, bucket.updateGroup], updatedGroup, {
patch: true,
safe: true,
});
yield call([bucket, bucket.updateGroup], updatedGroup, {safe: true});
yield put(redirectTo("group:attributes", {bid, gid}));
yield put(notifySuccess("Group attributes updated."));
} else if (permissions) {
Expand Down
4 changes: 1 addition & 3 deletions src/sagas/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ export function* updateRecord(getState: GetStateFn, action: ActionType<typeof ac
const attachmentOptions = getAttachmentOptions(attachmentCapability, collection.data);
yield call([coll, coll.addAttachment], attachment, updatedRecord, attachmentOptions);
} else {
// Note: We update using PATCH to keep existing record attributes possibly
// not defined by the JSON schema, if any.
yield call([coll, coll.updateRecord], updatedRecord, {patch: true, safe: true});
yield call([coll, coll.updateRecord], updatedRecord, {safe: true});
}
yield put(resetRecord());
yield put(redirectTo("collection:records", {bid, cid}));
Expand Down
7 changes: 4 additions & 3 deletions test/sagas/bucket_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ describe("bucket sagas", () => {
it("should post new bucket data", () => {
expect(updateBucket.next().value)
.eql(call([bucket, bucket.setData], {a: 1, last_modified: 42}, {
patch: true, safe: true}));
safe: true,
}));
});

it("should update the route path", () => {
Expand Down Expand Up @@ -374,7 +375,7 @@ describe("bucket sagas", () => {
.eql(call([collection, collection.setData], {
...collectionData,
last_modified: 42,
}, {patch: true, safe: true}));
}, {safe: true}));
});

it("should update the route path", () => {
Expand Down Expand Up @@ -733,7 +734,7 @@ describe("bucket sagas", () => {
.eql(call([bucket, bucket.updateGroup], {
...groupData,
last_modified: 42
}, {patch: true, safe: true}));
}, {safe: true}));
});

it("should update the route path", () => {
Expand Down
1 change: 0 additions & 1 deletion test/sagas/collection_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ describe("collection sagas", () => {
...record,
last_modified: 42
}, {
patch: true,
safe: true
}));
});
Expand Down

0 comments on commit be155ce

Please sign in to comment.