Fix request duplication

This commit is contained in:
Gregory Schier 2016-08-17 14:05:14 -07:00
parent 30272b0c0c
commit 55ecd5581b
2 changed files with 9 additions and 4 deletions

View File

@ -31,7 +31,7 @@ class RequestActionsDropdown extends Component {
</button>
<ul>
<li>
<button onClick={e => db.requestCopy(request)}>
<button onClick={e => db.requestDuplicate(request)}>
<i className="fa fa-copy"></i> Duplicate
<DropdownHint char="D"></DropdownHint>
</button>

View File

@ -334,7 +334,7 @@ export function requestCreateAndActivate (workspace, patch = {}) {
}
export function requestCopyAndActivate (workspace, request) {
return requestCopy(request).then(r => {
return requestDuplicate(request).then(r => {
workspaceUpdate(workspace, {metaActiveRequestId: r._id});
})
}
@ -377,9 +377,14 @@ export function requestUpdateContentType (request, contentType) {
return docUpdate(request, {headers});
}
export function requestCopy (request) {
export function requestDuplicate (request) {
const name = `${request.name} (Copy)`;
return requestCreate(Object.assign({}, request, {name}));
const newRequest = Object.assign({}, request, {name});
// Remove the old Id
delete newRequest._id;
return requestCreate(newRequest);
}
export function requestRemove (request) {