mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
feat: welcome screen add new request
This commit is contained in:
parent
1f1e8a602e
commit
3ffcc0e9f2
@ -4,6 +4,7 @@ import { rawRequest, gql } from 'graphql-request';
|
|||||||
import QueryUrl from '../QueryUrl';
|
import QueryUrl from '../QueryUrl';
|
||||||
import RequestPane from '../RequestPane';
|
import RequestPane from '../RequestPane';
|
||||||
import ResponsePane from '../ResponsePane';
|
import ResponsePane from '../ResponsePane';
|
||||||
|
import Welcome from '../Welcome';
|
||||||
import {
|
import {
|
||||||
flattenItems,
|
flattenItems,
|
||||||
findItem
|
findItem
|
||||||
@ -58,7 +59,7 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
|
|||||||
|
|
||||||
if(!activeRequestTabId) {
|
if(!activeRequestTabId) {
|
||||||
return (
|
return (
|
||||||
<div className="pb-4 px-4">No request selected</div>
|
<Welcome dispatch={dispatch} actions={actions}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +71,16 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const collection = find(collections, (c) => c.id === focusedTab.collectionId);
|
let collection;
|
||||||
const flattenedItems = flattenItems(collection.items);
|
let item;
|
||||||
const item = findItem(flattenedItems, activeRequestTabId);
|
|
||||||
|
if(focusedTab.collectionId) {
|
||||||
|
collection = find(collections, (c) => c.id === focusedTab.collectionId);
|
||||||
|
let flattenedItems = flattenItems(collection.items);
|
||||||
|
item = findItem(flattenedItems, activeRequestTabId);
|
||||||
|
} else {
|
||||||
|
item = focusedTab;
|
||||||
|
}
|
||||||
|
|
||||||
const runQuery = async () => {
|
const runQuery = async () => {
|
||||||
const query = gql`${item.request.body.graphql.query}`;
|
const query = gql`${item.request.body.graphql.query}`;
|
||||||
|
@ -7,7 +7,7 @@ import { IconBox, IconSearch, IconDots } from '@tabler/icons';
|
|||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
const Sidebar = ({collections, actions, dispatch, activeRequestTabId}) => {
|
const Sidebar = ({collections, actions, dispatch, activeRequestTabId}) => {
|
||||||
const [modalOpen, setModalOpen] = useState(true);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
|
|
||||||
const menuDropdownTippyRef = useRef();
|
const menuDropdownTippyRef = useRef();
|
||||||
const onMenuDropdownCreate = (ref) => menuDropdownTippyRef.current = ref;
|
const onMenuDropdownCreate = (ref) => menuDropdownTippyRef.current = ref;
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const StyledWrapper = styled.div`
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default StyledWrapper;
|
28
packages/grafnode-components/src/components/Welcome/index.js
Normal file
28
packages/grafnode-components/src/components/Welcome/index.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
|
const Welcome = ({dispatch, actions}) => {
|
||||||
|
const handleClick = () => {
|
||||||
|
dispatch({
|
||||||
|
type: actions.ADD_NEW_HTTP_REQUEST
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledWrapper className="pb-4 px-4">
|
||||||
|
<div>Welcome</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
style={{backgroundColor: '#8e44ad'}}
|
||||||
|
className="flex items-center h-full text-white active:bg-blue-600 font-bold text-xs px-4 py-2 ml-2 uppercase rounded shadow hover:shadow-md outline-none focus:outline-none ease-linear transition-all duration-150"
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
Add Request
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</StyledWrapper>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Welcome;
|
@ -4,6 +4,7 @@ const REQUEST_TAB_CLICK = "REQUEST_TAB_CLICK";
|
|||||||
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
|
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
|
||||||
const RESPONSE_RECEIVED = "RESPONSE_RECEIVED";
|
const RESPONSE_RECEIVED = "RESPONSE_RECEIVED";
|
||||||
const ADD_REQUEST = "ADD_REQUEST";
|
const ADD_REQUEST = "ADD_REQUEST";
|
||||||
|
const ADD_NEW_HTTP_REQUEST = "ADD_NEW_HTTP_REQUEST";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
SIDEBAR_COLLECTION_CLICK,
|
SIDEBAR_COLLECTION_CLICK,
|
||||||
@ -11,5 +12,6 @@ export default {
|
|||||||
REQUEST_TAB_CLICK,
|
REQUEST_TAB_CLICK,
|
||||||
REQUEST_TAB_CLOSE,
|
REQUEST_TAB_CLOSE,
|
||||||
RESPONSE_RECEIVED,
|
RESPONSE_RECEIVED,
|
||||||
ADD_REQUEST
|
ADD_REQUEST,
|
||||||
|
ADD_NEW_HTTP_REQUEST
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,27 @@ const reducer = (state, action) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case actions.ADD_NEW_HTTP_REQUEST: {
|
||||||
|
return produce(state, (draft) => {
|
||||||
|
const uid = nanoid();
|
||||||
|
draft.requestTabs.push({
|
||||||
|
id: uid,
|
||||||
|
name: 'Untitled Request',
|
||||||
|
method: 'GET',
|
||||||
|
request: {
|
||||||
|
url: 'https://api.spacex.land/graphql/',
|
||||||
|
body: {
|
||||||
|
graphql: {
|
||||||
|
query: '{}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
collectionId: null
|
||||||
|
});
|
||||||
|
draft.activeRequestTabId = uid;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
case actions.RESPONSE_RECEIVED: {
|
case actions.RESPONSE_RECEIVED: {
|
||||||
return produce(state, (draft) => {
|
return produce(state, (draft) => {
|
||||||
const collection = find(draft.collections, (c) => c.id === action.collectionId);
|
const collection = find(draft.collections, (c) => c.id === action.collectionId);
|
||||||
|
Loading…
Reference in New Issue
Block a user