mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-21 04:08:01 +02:00
added feat/-#220
This commit is contained in:
parent
e83c2da798
commit
b83da46f12
@ -1,21 +1,28 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { IconSearch, IconFolders } from '@tabler/icons';
|
import { IconSearch, IconFolders, IconSortAZ } from '@tabler/icons';
|
||||||
import Collection from '../Collections/Collection';
|
import Collection from '../Collections/Collection';
|
||||||
import CreateCollection from '../CreateCollection';
|
import CreateCollection from '../CreateCollection';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
import CreateOrOpenCollection from './CreateOrOpenCollection';
|
import CreateOrOpenCollection from './CreateOrOpenCollection';
|
||||||
import { DndProvider } from 'react-dnd';
|
import { DndProvider } from 'react-dnd';
|
||||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||||
|
import { sortCollections } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
|
|
||||||
const CollectionsBadge = () => {
|
const CollectionsBadge = () => {
|
||||||
|
const dispatch = useDispatch()
|
||||||
return (
|
return (
|
||||||
<div className="items-center mt-2 relative">
|
<div className="items-center mt-2 relative">
|
||||||
<div className="collections-badge flex items-center pl-2 pr-2 py-1 select-none">
|
<div className='collections-badge flex items-center justify-between px-2' >
|
||||||
<span className="mr-2">
|
<div className="flex items-center py-1 select-none">
|
||||||
<IconFolders size={18} strokeWidth={1.5} />
|
<span className="mr-2">
|
||||||
</span>
|
<IconFolders size={18} strokeWidth={1.5} />
|
||||||
<span>Collections</span>
|
</span>
|
||||||
|
<span>Collections</span>
|
||||||
|
</div>
|
||||||
|
<button onClick={() => dispatch(sortCollections())} >
|
||||||
|
<IconSortAZ size={18} strokeWidth={1.5} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -64,12 +71,12 @@ const Collections = () => {
|
|||||||
<div className="mt-4 flex flex-col overflow-y-auto absolute top-32 bottom-10 left-0 right-0">
|
<div className="mt-4 flex flex-col overflow-y-auto absolute top-32 bottom-10 left-0 right-0">
|
||||||
{collections && collections.length
|
{collections && collections.length
|
||||||
? collections.map((c) => {
|
? collections.map((c) => {
|
||||||
return (
|
return (
|
||||||
<DndProvider backend={HTML5Backend} key={c.uid}>
|
<DndProvider backend={HTML5Backend} key={c.uid}>
|
||||||
<Collection searchText={searchText} collection={c} key={c.uid} />
|
<Collection searchText={searchText} collection={c} key={c.uid} />
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
|
@ -34,6 +34,7 @@ import {
|
|||||||
renameItem as _renameItem,
|
renameItem as _renameItem,
|
||||||
cloneItem as _cloneItem,
|
cloneItem as _cloneItem,
|
||||||
deleteItem as _deleteItem,
|
deleteItem as _deleteItem,
|
||||||
|
sortCollections as _sortCollections,
|
||||||
saveRequest as _saveRequest,
|
saveRequest as _saveRequest,
|
||||||
selectEnvironment as _selectEnvironment,
|
selectEnvironment as _selectEnvironment,
|
||||||
createCollection as _createCollection,
|
createCollection as _createCollection,
|
||||||
@ -353,6 +354,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);
|
||||||
|
@ -70,6 +70,9 @@ export const collectionsSlice = createSlice({
|
|||||||
removeCollection: (state, action) => {
|
removeCollection: (state, action) => {
|
||||||
state.collections = filter(state.collections, (c) => c.uid !== action.payload.collectionUid);
|
state.collections = filter(state.collections, (c) => c.uid !== action.payload.collectionUid);
|
||||||
},
|
},
|
||||||
|
sortCollections: (state) => {
|
||||||
|
state.collections = state.collections.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
},
|
||||||
updateLastAction: (state, action) => {
|
updateLastAction: (state, action) => {
|
||||||
const { collectionUid, lastAction } = action.payload;
|
const { collectionUid, lastAction } = action.payload;
|
||||||
const collection = findCollectionByUid(state.collections, collectionUid);
|
const collection = findCollectionByUid(state.collections, collectionUid);
|
||||||
@ -1141,6 +1144,7 @@ export const {
|
|||||||
brunoConfigUpdateEvent,
|
brunoConfigUpdateEvent,
|
||||||
renameCollection,
|
renameCollection,
|
||||||
removeCollection,
|
removeCollection,
|
||||||
|
sortCollections,
|
||||||
updateLastAction,
|
updateLastAction,
|
||||||
collectionUnlinkEnvFileEvent,
|
collectionUnlinkEnvFileEvent,
|
||||||
saveEnvironment,
|
saveEnvironment,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user