-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
41 lines (35 loc) · 1.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import { Layout, Block } from '@storybook/addon-devkit';
import { styled } from '@storybook/theming';
import ReactJson from 'react-json-view'
import SearchInputs from './SearchInputs';
const LayoutBlock = styled(Layout)`
margin: 0px;
height: 100px;
`;
const AddonBlock = styled(Block)`
border: 1px solid gray;
margin: 2px;
padding: 8px;
overflow: auto;
`;
const Panel = ({ startRequest, request, kind, story, isFirstDataReceived, searchVars, search, rowResult, onEdit }) => {
React.useEffect(() => {
if (isFirstDataReceived) {
startRequest();
request();
}
}, [kind, story, request, startRequest, isFirstDataReceived, searchVars]);
if (!isFirstDataReceived) return null;
return (
<LayoutBlock>
<AddonBlock size="30%">
<SearchInputs search={searchVars} onChange={search} />
</AddonBlock>
<AddonBlock>
<ReactJson src={rowResult} name="data" collapsed={4} collapseStringsAfterLength={60} onEdit={onEdit} /* onDelete={onEdit} */ />
</AddonBlock>
</LayoutBlock>
);
};
export default Panel;