mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-23 00:13:24 +01:00
commit
31c4d7ecfd
@ -21,7 +21,7 @@ import {
|
|||||||
} from 'utils/collections';
|
} from 'utils/collections';
|
||||||
import { collectionSchema, itemSchema, environmentSchema, environmentsSchema } from '@usebruno/schema';
|
import { collectionSchema, itemSchema, environmentSchema, environmentsSchema } from '@usebruno/schema';
|
||||||
import { waitForNextTick } from 'utils/common';
|
import { waitForNextTick } from 'utils/common';
|
||||||
import { getDirectoryName, isWindowsOS } from 'utils/common/platform';
|
import { getDirectoryName, isWindowsOS, PATH_SEPARATOR } from 'utils/common/platform';
|
||||||
import { sendNetworkRequest, cancelNetworkRequest } from 'utils/network';
|
import { sendNetworkRequest, cancelNetworkRequest } from 'utils/network';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -31,7 +31,6 @@ import {
|
|||||||
requestCancelled,
|
requestCancelled,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
newItem as _newItem,
|
newItem as _newItem,
|
||||||
renameItem as _renameItem,
|
|
||||||
cloneItem as _cloneItem,
|
cloneItem as _cloneItem,
|
||||||
deleteItem as _deleteItem,
|
deleteItem as _deleteItem,
|
||||||
saveRequest as _saveRequest,
|
saveRequest as _saveRequest,
|
||||||
@ -48,8 +47,6 @@ import { resolveRequestFilename } from 'utils/common/platform';
|
|||||||
import { parseQueryParams, splitOnFirst } from 'utils/url/index';
|
import { parseQueryParams, splitOnFirst } from 'utils/url/index';
|
||||||
import { each } from 'lodash';
|
import { each } from 'lodash';
|
||||||
|
|
||||||
const PATH_SEPARATOR = path.sep;
|
|
||||||
|
|
||||||
export const renameCollection = (newName, collectionUid) => (dispatch, getState) => {
|
export const renameCollection = (newName, collectionUid) => (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
||||||
@ -186,11 +183,7 @@ export const cancelRequest = (cancelTokenUid, item, collection) => (dispatch) =>
|
|||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo: this can be directly put inside the collections/index.js file
|
|
||||||
// the coding convention is to put only actions that need ipc in this file
|
|
||||||
export const sortCollections = (order) => (dispatch) => {
|
|
||||||
dispatch(_sortCollections(order));
|
|
||||||
};
|
|
||||||
export const runCollectionFolder = (collectionUid, folderUid, recursive) => (dispatch, getState) => {
|
export const runCollectionFolder = (collectionUid, folderUid, recursive) => (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
||||||
@ -308,19 +301,7 @@ export const renameItem = (newName, itemUid, collectionUid) => (dispatch, getSta
|
|||||||
}
|
}
|
||||||
const { ipcRenderer } = window;
|
const { ipcRenderer } = window;
|
||||||
|
|
||||||
ipcRenderer
|
ipcRenderer.invoke('renderer:rename-item', item.pathname, newPathname, newName).then(resolve).catch(reject);
|
||||||
.invoke('renderer:rename-item', item.pathname, newPathname, newName)
|
|
||||||
.then(() => {
|
|
||||||
// In case of Mac and Linux, we get the unlinkDir and addDir IPC events from electron which takes care of updating the state
|
|
||||||
// But in windows we don't get those events, so we need to update the state manually
|
|
||||||
// This looks like an issue in our watcher library chokidar
|
|
||||||
// GH: https://github.com/usebruno/bruno/issues/251
|
|
||||||
if (isWindowsOS()) {
|
|
||||||
dispatch(_renameItem({ newName, itemUid, collectionUid }));
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch(reject);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -405,14 +386,8 @@ export const deleteItem = (itemUid, collectionUid) => (dispatch, getState) => {
|
|||||||
ipcRenderer
|
ipcRenderer
|
||||||
.invoke('renderer:delete-item', item.pathname, item.type)
|
.invoke('renderer:delete-item', item.pathname, item.type)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// In case of Mac and Linux, we get the unlinkDir IPC event from electron which takes care of updating the state
|
dispatch(_deleteItem({ itemUid, collectionUid }))
|
||||||
// But in windows we don't get those events, so we need to update the state manually
|
resolve()
|
||||||
// This looks like an issue in our watcher library chokidar
|
|
||||||
// GH: https://github.com/usebruno/bruno/issues/265
|
|
||||||
if (isWindowsOS()) {
|
|
||||||
dispatch(_deleteItem({ itemUid, collectionUid }));
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
})
|
})
|
||||||
.catch((error) => reject(error));
|
.catch((error) => reject(error));
|
||||||
}
|
}
|
||||||
@ -420,6 +395,9 @@ export const deleteItem = (itemUid, collectionUid) => (dispatch, getState) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const sortCollections = () => (dispatch) => {
|
||||||
|
dispatch(_sortCollections())
|
||||||
|
}
|
||||||
export const moveItem = (collectionUid, draggedItemUid, targetItemUid) => (dispatch, getState) => {
|
export const moveItem = (collectionUid, draggedItemUid, targetItemUid) => (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import path from 'path';
|
|
||||||
import { uuid } from 'utils/common';
|
import { uuid } from 'utils/common';
|
||||||
import find from 'lodash/find';
|
import find from 'lodash/find';
|
||||||
import map from 'lodash/map';
|
import map from 'lodash/map';
|
||||||
@ -25,9 +24,7 @@ import {
|
|||||||
areItemsTheSameExceptSeqUpdate
|
areItemsTheSameExceptSeqUpdate
|
||||||
} from 'utils/collections';
|
} from 'utils/collections';
|
||||||
import { parseQueryParams, stringifyQueryParams } from 'utils/url';
|
import { parseQueryParams, stringifyQueryParams } from 'utils/url';
|
||||||
import { getSubdirectoriesFromRoot, getDirectoryName } from 'utils/common/platform';
|
import { getSubdirectoriesFromRoot, getDirectoryName, PATH_SEPARATOR } from 'utils/common/platform';
|
||||||
|
|
||||||
const PATH_SEPARATOR = path.sep;
|
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
collections: [],
|
collections: [],
|
||||||
|
@ -48,3 +48,5 @@ export const isMacOS = () => {
|
|||||||
|
|
||||||
return osFamily.includes('os x');
|
return osFamily.includes('os x');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';
|
||||||
|
Loading…
Reference in New Issue
Block a user