mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
feat: detect changes in request url
This commit is contained in:
@@ -8,7 +8,9 @@ import {
|
||||
flattenItems,
|
||||
findItem,
|
||||
isItemARequest,
|
||||
itemIsOpenedInTabs
|
||||
itemIsOpenedInTabs,
|
||||
cloneItem,
|
||||
updateRequestTabAsChanged
|
||||
} from './utils';
|
||||
|
||||
const reducer = (state, action) => {
|
||||
@@ -42,7 +44,8 @@ const reducer = (state, action) => {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
method: item.request.method,
|
||||
collectionId: collection.id
|
||||
collectionId: collection.id,
|
||||
hasChanges: false
|
||||
});
|
||||
draft.activeRequestTabId = item.id;
|
||||
}
|
||||
@@ -79,7 +82,11 @@ const reducer = (state, action) => {
|
||||
let item = findItem(flattenedItems, action.requestTab.id);
|
||||
|
||||
if(item) {
|
||||
item.request.url = action.url;
|
||||
if(!item.draft) {
|
||||
item.draft = cloneItem(item);
|
||||
}
|
||||
item.draft.request.url = action.url;
|
||||
updateRequestTabAsChanged(draft.requestTabs, item.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import each from 'lodash/each';
|
||||
import find from 'lodash/find';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
|
||||
export const flattenItems = (items = []) => {
|
||||
const flattenedItems = [];
|
||||
@@ -30,3 +31,14 @@ export const isItemARequest = (item) => {
|
||||
export const itemIsOpenedInTabs = (item, tabs) => {
|
||||
return find(tabs, (t) => t.id === item.id);
|
||||
};
|
||||
|
||||
export const cloneItem = (item) => {
|
||||
return cloneDeep(item);
|
||||
};
|
||||
|
||||
export const updateRequestTabAsChanged = (requestTabs, itemId) => {
|
||||
let currentTab = find(requestTabs, (rt) => rt.id == itemId);
|
||||
if(currentTab) {
|
||||
currentTab.hasChanges = true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user