mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-24 07:38:59 +01:00
fix: fixed bugs related to sequencing
This commit is contained in:
parent
d9ef1692fe
commit
7dd0d10a5d
@ -1,6 +1,7 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import trim from 'lodash/trim';
|
import trim from 'lodash/trim';
|
||||||
|
import filter from 'lodash/filter';
|
||||||
import { uuid } from 'utils/common';
|
import { uuid } from 'utils/common';
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import {
|
import {
|
||||||
@ -252,6 +253,8 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat
|
|||||||
if (!reqWithSameNameExists) {
|
if (!reqWithSameNameExists) {
|
||||||
const fullName = `${collection.pathname}${PATH_SEPARATOR}${filename}`;
|
const fullName = `${collection.pathname}${PATH_SEPARATOR}${filename}`;
|
||||||
const { ipcRenderer } = window;
|
const { ipcRenderer } = window;
|
||||||
|
const requestItems = filter(collection.items, (i) => i.type !== 'folder');
|
||||||
|
itemToSave.seq = requestItems ? (requestItems.length + 1) : 1;
|
||||||
|
|
||||||
itemSchema
|
itemSchema
|
||||||
.validate(itemToSave)
|
.validate(itemToSave)
|
||||||
@ -267,6 +270,8 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat
|
|||||||
const dirname = path.dirname(item.pathname);
|
const dirname = path.dirname(item.pathname);
|
||||||
const fullName = `${dirname}${PATH_SEPARATOR}${filename}`;
|
const fullName = `${dirname}${PATH_SEPARATOR}${filename}`;
|
||||||
const { ipcRenderer } = window;
|
const { ipcRenderer } = window;
|
||||||
|
const requestItems = filter(parentItem.items, (i) => i.type !== 'folder');
|
||||||
|
itemToSave.seq = requestItems ? (requestItems.length + 1) : 1;
|
||||||
|
|
||||||
itemSchema
|
itemSchema
|
||||||
.validate(itemToSave)
|
.validate(itemToSave)
|
||||||
@ -360,8 +365,6 @@ export const moveItem = (collectionUid, draggedItemUid, targetItemUid) => (dispa
|
|||||||
moveCollectionItem(collectionCopy, draggedItem, targetItem);
|
moveCollectionItem(collectionCopy, draggedItem, targetItem);
|
||||||
const itemsToResequence = getItemsToResequence(draggedItemParent, collectionCopy);
|
const itemsToResequence = getItemsToResequence(draggedItemParent, collectionCopy);
|
||||||
const itemsToResequence2 = getItemsToResequence(targetItemParent, collectionCopy);
|
const itemsToResequence2 = getItemsToResequence(targetItemParent, collectionCopy);
|
||||||
console.log('itemsToResequence', itemsToResequence);
|
|
||||||
console.log('itemsToResequence2', itemsToResequence2);
|
|
||||||
|
|
||||||
return ipcRenderer
|
return ipcRenderer
|
||||||
.invoke('renderer:move-file-item', draggedItemPathname, targetItemParent.pathname)
|
.invoke('renderer:move-file-item', draggedItemPathname, targetItemParent.pathname)
|
||||||
@ -455,6 +458,13 @@ export const moveItemToRootOfCollection = (collectionUid, draggedItemUid) => (di
|
|||||||
|
|
||||||
const draggedItemPathname = draggedItem.pathname;
|
const draggedItemPathname = draggedItem.pathname;
|
||||||
moveCollectionItemToRootOfCollection(collectionCopy, draggedItem);
|
moveCollectionItemToRootOfCollection(collectionCopy, draggedItem);
|
||||||
|
|
||||||
|
if(isItemAFolder(draggedItem)) {
|
||||||
|
return ipcRenderer
|
||||||
|
.invoke('renderer:move-folder-item', draggedItemPathname, collectionCopy.pathname)
|
||||||
|
.then(resolve)
|
||||||
|
.catch((error) => reject(error));
|
||||||
|
} else {
|
||||||
const itemsToResequence = getItemsToResequence(draggedItemParent, collectionCopy);
|
const itemsToResequence = getItemsToResequence(draggedItemParent, collectionCopy);
|
||||||
const itemsToResequence2 = getItemsToResequence(collectionCopy, collectionCopy);
|
const itemsToResequence2 = getItemsToResequence(collectionCopy, collectionCopy);
|
||||||
|
|
||||||
@ -464,6 +474,7 @@ export const moveItemToRootOfCollection = (collectionUid, draggedItemUid) => (di
|
|||||||
.then(() => ipcRenderer.invoke('renderer:resequence-items', itemsToResequence2))
|
.then(() => ipcRenderer.invoke('renderer:resequence-items', itemsToResequence2))
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch((error) => reject(error));
|
.catch((error) => reject(error));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -501,8 +512,8 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
|
|||||||
const filename = resolveRequestFilename(requestName);
|
const filename = resolveRequestFilename(requestName);
|
||||||
if (!itemUid) {
|
if (!itemUid) {
|
||||||
const reqWithSameNameExists = find(collection.items, (i) => i.type !== 'folder' && trim(i.filename) === trim(filename));
|
const reqWithSameNameExists = find(collection.items, (i) => i.type !== 'folder' && trim(i.filename) === trim(filename));
|
||||||
item.seq = collectionCopy.items ? collectionCopy.items.length : 1;
|
const requestItems = filter(collection.items, (i) => i.type !== 'folder');
|
||||||
item.seq = item.seq + 1;
|
item.seq = requestItems.length + 1;
|
||||||
|
|
||||||
if (!reqWithSameNameExists) {
|
if (!reqWithSameNameExists) {
|
||||||
const fullName = `${collection.pathname}${PATH_SEPARATOR}${filename}`;
|
const fullName = `${collection.pathname}${PATH_SEPARATOR}${filename}`;
|
||||||
@ -516,8 +527,8 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
|
|||||||
const currentItem = findItemInCollection(collection, itemUid);
|
const currentItem = findItemInCollection(collection, itemUid);
|
||||||
if (currentItem) {
|
if (currentItem) {
|
||||||
const reqWithSameNameExists = find(currentItem.items, (i) => i.type !== 'folder' && trim(i.filename) === trim(filename));
|
const reqWithSameNameExists = find(currentItem.items, (i) => i.type !== 'folder' && trim(i.filename) === trim(filename));
|
||||||
item.seq = currentItem.items ? currentItem.items.length : 1;
|
const requestItems = filter(currentItem.items, (i) => i.type !== 'folder');
|
||||||
item.seq = item.seq + 1;
|
item.seq = requestItems.length + 1;
|
||||||
if (!reqWithSameNameExists) {
|
if (!reqWithSameNameExists) {
|
||||||
const fullName = `${currentItem.pathname}${PATH_SEPARATOR}${filename}`;
|
const fullName = `${currentItem.pathname}${PATH_SEPARATOR}${filename}`;
|
||||||
const { ipcRenderer } = window;
|
const { ipcRenderer } = window;
|
||||||
|
@ -164,7 +164,11 @@ export const moveCollectionItemToRootOfCollection = (collection, draggedItem) =>
|
|||||||
|
|
||||||
draggedItemParent.items = filter(draggedItemParent.items, (i) => i.uid !== draggedItem.uid);
|
draggedItemParent.items = filter(draggedItemParent.items, (i) => i.uid !== draggedItem.uid);
|
||||||
collection.items.push(draggedItem);
|
collection.items.push(draggedItem);
|
||||||
|
if(draggedItem.type == 'folder') {
|
||||||
|
draggedItem.pathname = path.join(collection.pathname, draggedItem.name);
|
||||||
|
} else {
|
||||||
draggedItem.pathname = path.join(collection.pathname, draggedItem.filename);
|
draggedItem.pathname = path.join(collection.pathname, draggedItem.filename);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getItemsToResequence = (parent, collection) => {
|
export const getItemsToResequence = (parent, collection) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user