Skip to content

Commit 4624bee

Browse files
committed
fixing history tab in workspace area
1 parent ce4df18 commit 4624bee

File tree

10 files changed

+79
-11
lines changed

10 files changed

+79
-11
lines changed

__tests__/composerTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('GraphQL Composer', () => {
2929
newRequestBody: {
3030
bodyContent: '',
3131
bodyType: 'raw',
32-
rawType: 'Text (text/plain)',
32+
rawType: 'text/plain',
3333
JSONFormatted: true,
3434
bodyVariables: '',
3535
},

src/client/components-v2/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import '../../assets/style/App.scss';
1212
import NavBarContainer from './navbar/NavBarContainer';
1313
import WorkspaceContainer from './workspace/WorkspaceContainer';
1414
import MainContainer from './main/MainContainer';
15-
15+
import HistoryOrWorkspaceContainer from './history-workspace-display/HistoryOrWorkspaceContainer';
1616

1717
import { Box, Divider } from '@mui/material';
1818

@@ -35,7 +35,7 @@ const App = () => {
3535
<Divider orientation="horizontal"/>
3636
<Box sx={{ height: '100%', display: 'flex' }}>
3737
{/* New MUI workspace. */}
38-
<WorkspaceContainer />
38+
<HistoryOrWorkspaceContainer />
3939
{/* Legacy workspace. */}
4040
<ContentsContainer />
4141
<Divider orientation="vertical"/>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import * as React from 'react';
2+
import Tabs from '@mui/material/Tabs';
3+
import Tab from '@mui/material/Tab';
4+
import Typography from '@mui/material/Typography';
5+
import Box from '@mui/material/Box';
6+
import WorkspaceContainer from "../workspace/WorkspaceContainer";
7+
import HistoryContainer from '../../components/containers/HistoryContainer';
8+
import AccessTimeIcon from '@mui/icons-material/AccessTime';
9+
import WorkIcon from '@mui/icons-material/Work';
10+
11+
interface TabPanelProps {
12+
children?: React.ReactNode;
13+
index: number;
14+
value: number;
15+
}
16+
17+
function TabPanel(props: TabPanelProps) {
18+
const { children, value, index, ...other } = props;
19+
20+
return (
21+
<div
22+
role="tabpanel"
23+
hidden={value !== index}
24+
id={`simple-tabpanel-${index}`}
25+
aria-labelledby={`simple-tab-${index}`}
26+
{...other}
27+
>
28+
{value === index && (
29+
<Box sx={{ p: 3 }}>
30+
<Box>{children}</Box>
31+
</Box>
32+
)}
33+
</div>
34+
);
35+
}
36+
37+
function a11yProps(index: number) {
38+
return {
39+
id: `simple-tab-${index}`,
40+
'aria-controls': `simple-tabpanel-${index}`,
41+
};
42+
}
43+
44+
export default function HistoryOrWorkspaceContainer() {
45+
const [value, setValue] = React.useState(0);
46+
47+
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
48+
setValue(newValue);
49+
};
50+
51+
return (
52+
<Box sx={{ minWidth: '25%', overflow: 'auto', maxHeight: '100%', overflowX: 'auto' }}>
53+
<Box sx={{ borderBottom: 1, borderColor: 'divider', }}>
54+
<Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
55+
<Tab icon={<WorkIcon />} label="Current Workspace" {...a11yProps(0)} sx={{fontSize:'10px', overflowWrap: "break-word", maxWidth: '50%'}}/>
56+
<Tab icon={<AccessTimeIcon />} label='View History' {...a11yProps(1)} sx={{fontSize:'10px', overflowWrap: "break-word", maxWidth: '50%'}}/>
57+
</Tabs>
58+
</Box>
59+
<TabPanel value={value} index={0}>
60+
<WorkspaceContainer />
61+
</TabPanel>
62+
<TabPanel value={value} index={1}>
63+
<HistoryContainer />
64+
</TabPanel>
65+
</Box>
66+
);
67+
}

src/client/components-v2/navbar/ProtocolSelect.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ function ProtocolSelect(props) {
282282
key={page.name}
283283
variant="contained"
284284
color="primary"
285-
onClick={() => onProtocolSelect(page.value)}
285+
onClick={() => {
286+
console.log(page.value)
287+
onProtocolSelect(page.value)}
288+
}
286289
sx={{
287290
m: 1
288291
}}>

src/client/components-v2/workspace/WorkspaceContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export default function WorkspaceContainer(props) {
3333

3434
return (
3535
<Box sx={{ minWidth: '20%', align: 'center', p: 1.5 }}>
36-
3736
<CurrentWorskpaceDisplay currentWorkspaceId={currentWorkspaceId} handleWorkspaceChange={handleWorkspaceChange}/>
3837

3938
<Box sx={{ p: 1 }}>

src/client/components/composer/NewRequest/TextCodeArea.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const langs = {
1818

1919
export default function TextCodeArea({ value, mode, onChange, theme = 'dark' , readOnly = false}) {
2020
const lang = mode.substring(mode.indexOf('/') + 1) // Grab language mode based on value passed in
21+
console.log(lang)
2122
return (
2223
<div className="is-neutral-200-box">
2324
<CodeMirror

src/client/components/containers/SingleReqResContainer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const SingleReqResContainer = (props) => {
150150
bodyType: content.request.bodyType || 'raw',
151151
bodyContent: content.request.body || '',
152152
bodyVariables: content.request.bodyVariables || '',
153-
rawType: content.request.rawType || 'Text (text/plain)',
153+
rawType: content.request.rawType || 'text/plain',
154154
JSONFormatted: true,
155155
bodyIsNew: false,
156156
};

src/client/components/display/History.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const History = ({
173173
bodyType: bodyType || 'raw',
174174
bodyContent: body || '',
175175
bodyVariables: bodyVariables || '',
176-
rawType: rawType || 'Text (text/plain)',
176+
rawType: rawType || 'text/plain',
177177
JSONFormatted: JSONFormatted || true,
178178
bodyIsNew: false,
179179
};

src/client/components/display/HistoryDate.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ class HistoryDate extends Component {
2020
let date = parse(current.date, 'MM/dd/yyyy', new Date())
2121
// let date = parseISO(current.date)
2222
if (isToday(date)) {
23-
console.log('today')
2423
date = 'Today';
2524
} // If the date matches todays date render the word "Today"
2625
else if (isYesterday(date)) {
2726
date = 'Yesterday';
2827
} else {
29-
log('else')
3028
date = format(date, 'MMM d, yyyy');
3129
}
3230

src/client/controllers/historyController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ const historyController = {
3434
return groups;
3535
}, {});
3636
const historyGroupsArr = Object.keys(historyGroupsObj)
37-
//.sort((a, b) => parse(b, 'MM/dd/yyyy', new Date()).valueOf() - parse(a, 'MM/dd/yyyy', new Date()).valueOf())
38-
.sort((a, b) => parseISO(b).valueOf() - parseISO(a).valueOf())
37+
.sort((a, b) => parse(b, 'MM/dd/yyyy', new Date()).valueOf() - parse(a, 'MM/dd/yyyy', new Date()).valueOf())
3938
.map((date: string) => ({ // this returns an array of objects with K:date T:string and K:array of history objects
4039
date,
4140
history: historyGroupsObj[date].sort(
4241
(a: ReqRes, b: ReqRes) => b.createdAt.valueOf() - a.createdAt.valueOf()),
4342
}));
43+
console.log(historyGroupsArr)
4444
store.default.dispatch(actions.getHistory(historyGroupsArr));
4545
} catch {
4646
((err: string) => console.log('Error in getHistory', err))

0 commit comments

Comments
 (0)