bruno/renderer/pageComponents/Main/index.js

83 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-12-03 20:37:38 +01:00
import React from 'react';
import RequestTabs from 'components/RequestTabs';
import RequestTabPanel from 'components/RequestTabPanel';
import Sidebar from 'components/Sidebar';
2021-12-03 20:37:38 +01:00
import actions from 'providers/Store/actions';
import { useStore } from '../../providers/Store/index';
2021-12-03 20:37:38 +01:00
import StyledWrapper from './StyledWrapper';
import { IconStack, IconGitFork } from '@tabler/icons';
2021-12-05 17:04:03 +01:00
const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true;
if(!SERVER_RENDERED) {
require('codemirror/mode/javascript/javascript');
require('codemirror/mode/javascript/javascript');
require('codemirror/addon/edit/matchbrackets');
require('codemirror/addon/fold/brace-fold');
require('codemirror/addon/fold/foldgutter');
require('codemirror/addon/hint/show-hint');
require('codemirror/keymap/sublime');
require('codemirror/addon/comment/comment');
require('codemirror/addon/edit/closebrackets');
require('codemirror/addon/search/search');
require('codemirror/addon/search/searchcursor');
require('codemirror/addon/search/jump-to-line');
require('codemirror/addon/dialog/dialog');
require('codemirror-graphql/hint');
require('codemirror-graphql/lint');
require('codemirror-graphql/info');
require('codemirror-graphql/jump');
require('codemirror-graphql/mode');
}
2021-12-03 20:37:38 +01:00
export default function Main() {
const [state, dispatch] = useStore();
if (SERVER_RENDERED) {
return null;
}
2021-12-03 20:37:38 +01:00
const {
collections,
2021-12-03 21:33:46 +01:00
requestTabs,
2021-12-03 20:37:38 +01:00
activeRequestTabId
} = state;
return (
<div>
<StyledWrapper>
<Sidebar
collections={collections}
actions={actions}
dispatch={dispatch}
activeRequestTabId={activeRequestTabId}
/>
<section className='flex flex-grow flex-col'>
<div className="flex items-center" style={{padding: "8px", paddingBottom: "4px"}}>
<IconStack size={18} strokeWidth={1.5}/>
<span className="ml-2 mr-4 font-semibold">spacex</span>
<IconGitFork size={16} strokeWidth={1}/>
<span className="ml-1 text-xs">main</span>
</div>
2021-12-03 21:33:46 +01:00
<RequestTabs
requestTabs={requestTabs}
actions={actions}
dispatch={dispatch}
activeRequestTabId={activeRequestTabId}
/>
<RequestTabPanel
actions={actions}
dispatch={dispatch}
collections={collections}
requestTabs={requestTabs}
activeRequestTabId={activeRequestTabId}
/>
2021-12-03 20:37:38 +01:00
</section>
</StyledWrapper>
</div>
2021-12-30 15:12:04 +01:00
);
};