mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-23 07:09:01 +01:00
feat: moved up the state logic for graphql query change
This commit is contained in:
parent
2f222aebde
commit
3133f5e253
@ -18,7 +18,7 @@ const RequestPane = ({onRunQuery, schema, leftPaneWidth, value, onQueryChange})
|
||||
width={leftPaneWidth}
|
||||
value={value}
|
||||
onRunQuery={onRunQuery}
|
||||
onChange={onQueryChange}
|
||||
onEdit={onQueryChange}
|
||||
/>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
|
@ -21,7 +21,6 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
|
||||
let {
|
||||
schema
|
||||
} = useGraphqlSchema('https://api.spacex.land/graphql');
|
||||
let [query, setQuery] = useState('');
|
||||
const [leftPaneWidth, setLeftPaneWidth] = useState(500);
|
||||
const [rightPaneWidth, setRightPaneWidth] = useState(window.innerWidth - 700 - asideWidth);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
@ -59,7 +58,15 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
|
||||
});
|
||||
};
|
||||
|
||||
const onQueryChange = (value) => setQuery(value);
|
||||
const onGraphqlQueryChange = (value) => {
|
||||
console.log(value);
|
||||
dispatch({
|
||||
type: actions.REQUEST_GQL_QUERY_CHANGED,
|
||||
query: value,
|
||||
requestTab: focusedTab,
|
||||
collectionId: collection ? collection.id : null
|
||||
});
|
||||
};
|
||||
|
||||
if(!activeRequestTabId) {
|
||||
return (
|
||||
@ -118,7 +125,7 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re
|
||||
schema={schema}
|
||||
leftPaneWidth={leftPaneWidth}
|
||||
value={item.request.body.graphql.query}
|
||||
onQueryChange={onQueryChange}
|
||||
onQueryChange={onGraphqlQueryChange}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -3,6 +3,7 @@ const SIDEBAR_COLLECTION_ITEM_CLICK = "SIDEBAR_COLLECTION_ITEM_CLICK";
|
||||
const REQUEST_TAB_CLICK = "REQUEST_TAB_CLICK";
|
||||
const REQUEST_TAB_CLOSE = "REQUEST_TAB_CLOSE";
|
||||
const REQUEST_URL_CHANGED = "REQUEST_URL_CHANGED";
|
||||
const REQUEST_GQL_QUERY_CHANGED = "REQUEST_GQL_QUERY_CHANGED";
|
||||
const RESPONSE_RECEIVED = "RESPONSE_RECEIVED";
|
||||
const SEND_REQUEST = "SEND_REQUEST";
|
||||
const SENDING_REQUEST = "SENDING_REQUEST";
|
||||
@ -16,6 +17,7 @@ export default {
|
||||
REQUEST_TAB_CLICK,
|
||||
REQUEST_TAB_CLOSE,
|
||||
REQUEST_URL_CHANGED,
|
||||
REQUEST_GQL_QUERY_CHANGED,
|
||||
RESPONSE_RECEIVED,
|
||||
SEND_REQUEST,
|
||||
SENDING_REQUEST,
|
||||
|
@ -73,6 +73,21 @@ const reducer = (state, action) => {
|
||||
});
|
||||
}
|
||||
|
||||
case actions.REQUEST_GQL_QUERY_CHANGED: {
|
||||
return produce(state, (draft) => {
|
||||
const collection = find(draft.collections, (c) => c.id === action.collectionId);
|
||||
|
||||
if(collection) {
|
||||
let flattenedItems = flattenItems(collection.items);
|
||||
let item = findItem(flattenedItems, action.requestTab.id);
|
||||
|
||||
if(item) {
|
||||
item.request.body.graphql.query = action.query;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
case actions.ADD_NEW_HTTP_REQUEST: {
|
||||
return produce(state, (draft) => {
|
||||
const uid = nanoid();
|
||||
|
Loading…
Reference in New Issue
Block a user