mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
feat: display dropdown items based in item type
This commit is contained in:
parent
c1e93915d4
commit
7fc624d1a8
@ -5,7 +5,7 @@ import { IconChevronRight, IconDots } from '@tabler/icons';
|
||||
import classnames from 'classnames';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs';
|
||||
import { isItemARequest, itemIsOpenedInTabs } from 'utils/tabs';
|
||||
import { isItemARequest, isItemAFolder, itemIsOpenedInTabs } from 'utils/tabs';
|
||||
import Dropdown from 'components/Dropdown';
|
||||
import RequestMethod from './RequestMethod';
|
||||
|
||||
@ -57,6 +57,8 @@ const CollectionItem = ({item, collection}) => {
|
||||
|
||||
let indents = range(item.depth);
|
||||
const onDropdownCreate = (ref) => dropdownTippyRef.current = ref;
|
||||
const isRequest = isItemARequest(item);
|
||||
const isFolder = isItemAFolder(item);
|
||||
|
||||
return (
|
||||
<StyledWrapper className="flex flex-col">
|
||||
@ -86,7 +88,7 @@ const CollectionItem = ({item, collection}) => {
|
||||
}}
|
||||
>
|
||||
<div style={{width:16}}>
|
||||
{item.type === 'folder' ? (
|
||||
{isFolder ? (
|
||||
<IconChevronRight size={16} strokeWidth={2} className={iconClassName} style={{color: 'rgb(160 160 160)'}}/>
|
||||
) : null}
|
||||
</div>
|
||||
@ -98,16 +100,20 @@ const CollectionItem = ({item, collection}) => {
|
||||
</div>
|
||||
<div className="menu-icon pr-2">
|
||||
<Dropdown onCreate={onDropdownCreate} icon={<MenuIcon />} placement='bottom-start'>
|
||||
<div className="dropdown-item" onClick={(e) => {
|
||||
dropdownTippyRef.current.hide();
|
||||
}}>
|
||||
New Request
|
||||
</div>
|
||||
<div className="dropdown-item" onClick={(e) => {
|
||||
dropdownTippyRef.current.hide();
|
||||
}}>
|
||||
New Folder
|
||||
</div>
|
||||
{isFolder && (
|
||||
<>
|
||||
<div className="dropdown-item" onClick={(e) => {
|
||||
dropdownTippyRef.current.hide();
|
||||
}}>
|
||||
New Request
|
||||
</div>
|
||||
<div className="dropdown-item" onClick={(e) => {
|
||||
dropdownTippyRef.current.hide();
|
||||
}}>
|
||||
New Folder
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="dropdown-item" onClick={(e) => {
|
||||
dropdownTippyRef.current.hide();
|
||||
}}>
|
||||
|
@ -1,7 +1,11 @@
|
||||
import find from 'lodash/find';
|
||||
|
||||
export const isItemARequest = (item) => {
|
||||
return item.hasOwnProperty('request');
|
||||
return item.hasOwnProperty('request') && ['http-request', 'graphql-request'].includes(item.type);
|
||||
};
|
||||
|
||||
export const isItemAFolder = (item) => {
|
||||
return !item.hasOwnProperty('request') && item.type === 'folder';
|
||||
};
|
||||
|
||||
export const itemIsOpenedInTabs = (item, tabs) => {
|
||||
|
Loading…
Reference in New Issue
Block a user