mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
Don't restore name/folder on history change (Fixes #786)
This commit is contained in:
parent
676ac58b8b
commit
88286bbf94
@ -180,8 +180,8 @@ describe('migrate()', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'foo', value: 'bar', disabled: false},
|
{name: 'foo', value: 'bar'},
|
||||||
{name: 'baz', value: '{{ hello }}', disabled: false}
|
{name: 'baz', value: '{{ hello }}'}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
url: ''
|
url: ''
|
||||||
@ -201,8 +201,8 @@ describe('migrate()', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'foo', value: 'bar', disabled: false},
|
{name: 'foo', value: 'bar'},
|
||||||
{name: 'baz', value: '{{ hello }}', disabled: false}
|
{name: 'baz', value: '{{ hello }}'}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
url: ''
|
url: ''
|
||||||
@ -222,7 +222,7 @@ describe('migrate()', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: '{"foo": "bar"}', value: '', disabled: false}
|
{name: '{"foo": "bar"}', value: ''}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
url: ''
|
url: ''
|
||||||
|
@ -7,13 +7,14 @@ export const type = 'RequestVersion';
|
|||||||
export const prefix = 'rvr';
|
export const prefix = 'rvr';
|
||||||
export const canDuplicate = false;
|
export const canDuplicate = false;
|
||||||
|
|
||||||
const FIELDS_TO_IGNORE_IN_REQUEST_DIFF = [
|
const FIELDS_TO_IGNORE = [
|
||||||
'_id',
|
'_id',
|
||||||
'type',
|
'type',
|
||||||
'created',
|
'created',
|
||||||
'modified',
|
'modified',
|
||||||
'metaSortKey',
|
'metaSortKey',
|
||||||
'description',
|
'description',
|
||||||
|
'parentId',
|
||||||
'name'
|
'name'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -65,8 +66,15 @@ export async function restore (requestVersionId) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = decompressObject(requestVersion.compressedRequest);
|
const requestPatch = decompressObject(requestVersion.compressedRequest);
|
||||||
return models.request.update(request);
|
const originalRequest = await models.request.getById(requestPatch._id);
|
||||||
|
|
||||||
|
// Only restore fields that aren't blacklisted
|
||||||
|
for (const field of FIELDS_TO_IGNORE) {
|
||||||
|
delete requestPatch[field];
|
||||||
|
}
|
||||||
|
|
||||||
|
return models.request.update(originalRequest, requestPatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _diffRequests (rOld, rNew) {
|
function _diffRequests (rOld, rNew) {
|
||||||
@ -76,7 +84,7 @@ function _diffRequests (rOld, rNew) {
|
|||||||
|
|
||||||
for (const key of Object.keys(rOld)) {
|
for (const key of Object.keys(rOld)) {
|
||||||
// Skip fields that aren't useful
|
// Skip fields that aren't useful
|
||||||
if (FIELDS_TO_IGNORE_IN_REQUEST_DIFF.includes(key)) {
|
if (FIELDS_TO_IGNORE.includes(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +52,10 @@ describe('authorization_code', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'authorization_code', disabled: false},
|
{name: 'grant_type', value: 'authorization_code'},
|
||||||
{name: 'code', value: 'code_123', disabled: false},
|
{name: 'code', value: 'code_123'},
|
||||||
{name: 'redirect_uri', value: REDIRECT_URI, disabled: false},
|
{name: 'redirect_uri', value: REDIRECT_URI},
|
||||||
{name: 'state', value: STATE, disabled: false}
|
{name: 'state', value: STATE}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
@ -113,12 +113,12 @@ describe('authorization_code', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'authorization_code', disabled: false},
|
{name: 'grant_type', value: 'authorization_code'},
|
||||||
{name: 'code', value: 'code_123', disabled: false},
|
{name: 'code', value: 'code_123'},
|
||||||
{name: 'redirect_uri', value: REDIRECT_URI, disabled: false},
|
{name: 'redirect_uri', value: REDIRECT_URI},
|
||||||
{name: 'state', value: STATE, disabled: false},
|
{name: 'state', value: STATE},
|
||||||
{name: 'client_id', value: CLIENT_ID, disabled: false},
|
{name: 'client_id', value: CLIENT_ID},
|
||||||
{name: 'client_secret', value: CLIENT_SECRET, disabled: false}
|
{name: 'client_secret', value: CLIENT_SECRET}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
|
@ -44,8 +44,8 @@ describe('client_credentials', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'client_credentials', disabled: false},
|
{name: 'grant_type', value: 'client_credentials'},
|
||||||
{name: 'scope', value: SCOPE, disabled: false}
|
{name: 'scope', value: SCOPE}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
@ -98,10 +98,10 @@ describe('client_credentials', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'client_credentials', disabled: false},
|
{name: 'grant_type', value: 'client_credentials'},
|
||||||
{name: 'scope', value: SCOPE, disabled: false},
|
{name: 'scope', value: SCOPE},
|
||||||
{name: 'client_id', value: CLIENT_ID, disabled: false},
|
{name: 'client_id', value: CLIENT_ID},
|
||||||
{name: 'client_secret', value: CLIENT_SECRET, disabled: false}
|
{name: 'client_secret', value: CLIENT_SECRET}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
|
@ -48,10 +48,10 @@ describe('password', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'password', disabled: false},
|
{name: 'grant_type', value: 'password'},
|
||||||
{name: 'username', value: USERNAME, disabled: false},
|
{name: 'username', value: USERNAME},
|
||||||
{name: 'password', value: PASSWORD, disabled: false},
|
{name: 'password', value: PASSWORD},
|
||||||
{name: 'scope', value: SCOPE, disabled: false}
|
{name: 'scope', value: SCOPE}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
@ -107,12 +107,12 @@ describe('password', () => {
|
|||||||
body: {
|
body: {
|
||||||
mimeType: 'application/x-www-form-urlencoded',
|
mimeType: 'application/x-www-form-urlencoded',
|
||||||
params: [
|
params: [
|
||||||
{name: 'grant_type', value: 'password', disabled: false},
|
{name: 'grant_type', value: 'password'},
|
||||||
{name: 'username', value: USERNAME, disabled: false},
|
{name: 'username', value: USERNAME},
|
||||||
{name: 'password', value: PASSWORD, disabled: false},
|
{name: 'password', value: PASSWORD},
|
||||||
{name: 'scope', value: SCOPE, disabled: false},
|
{name: 'scope', value: SCOPE},
|
||||||
{name: 'client_id', value: CLIENT_ID, disabled: false},
|
{name: 'client_id', value: CLIENT_ID},
|
||||||
{name: 'client_secret', value: CLIENT_SECRET, disabled: false}
|
{name: 'client_secret', value: CLIENT_SECRET}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
|
Loading…
Reference in New Issue
Block a user