Skip to content

Commit 56a87d5

Browse files
author
denis.vybornov
committed
MFRU-12750 added simulations example template
1 parent b1b5360 commit 56a87d5

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

src/components/Simulations/Simulations.pcss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ $(b) {
2727
width: 120px;
2828
}
2929

30+
&__menu-button_example {
31+
color: var(--spbSky3) !important;
32+
33+
box-shadow: inset 0 0 0 1px var(--spbSky3) !important;
34+
}
35+
3036
&__fields {
3137
display: grid;
3238
flex-direction: flex-end;

src/components/Simulations/Simulations.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ReactComponent as PlusIcon } from 'static/favicon/plus.svg';
1515
import { useSelector } from 'store/hooks';
1616
import { downloadFile } from 'utils';
1717
import Popup from '../Popup/Popup';
18+
import exampleData from './exampleData';
1819
import type { RouteItem } from './types';
1920
import { getRouteList, validateImport } from './utils';
2021
import './Simulations.pcss';
@@ -124,6 +125,10 @@ const Simulations: React.FC<ISimulationsProps> = ({ onChange, onDelete, onImport
124125
}
125126
}
126127

128+
function handleExample() {
129+
downloadFile(JSON.stringify(exampleData, null, 2), 'example.json');
130+
}
131+
127132
function handleSimulationEditButtonClick(index: number) {
128133
return () => onChange(index, 'edit');
129134
}
@@ -261,6 +266,16 @@ const Simulations: React.FC<ISimulationsProps> = ({ onChange, onDelete, onImport
261266
>
262267
Import
263268
</Button>
269+
<Button
270+
className={cn('menu-button', { example: true })}
271+
sizeAll="small"
272+
type="outline"
273+
theme="black"
274+
actionType="button"
275+
onClick={handleExample}
276+
>
277+
Example
278+
</Button>
264279
</div>
265280
<div className={cn('fields')}>
266281
<TextField
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const exampleData = [
2+
{
3+
request: {
4+
path: [
5+
{
6+
matcher: 'exact',
7+
value: '/',
8+
},
9+
],
10+
method: [
11+
{
12+
matcher: 'exact',
13+
value: 'GET',
14+
},
15+
],
16+
destination: [
17+
{
18+
matcher: 'exact',
19+
value: '/',
20+
},
21+
],
22+
headers: {
23+
requestHeaderKey: [
24+
{
25+
matcher: 'exact',
26+
value: 'requestHeaderKeys',
27+
},
28+
],
29+
},
30+
query: {
31+
requestQueryKey: [
32+
{
33+
matcher: 'exact',
34+
value: 'requestQueryKeys',
35+
},
36+
],
37+
},
38+
requiresState: {
39+
requireStateKey: 'requireStateValue',
40+
},
41+
},
42+
response: {
43+
status: 200,
44+
body: '{\n "key": "value"\n}\n',
45+
encodedBody: false,
46+
headers: {
47+
responseHeaderKey: ['responseHeaderValue'],
48+
},
49+
templated: false,
50+
transitionsState: {
51+
newStateKey: 'newStateValue',
52+
},
53+
fixedDelay: 500,
54+
},
55+
},
56+
];
57+
58+
export default exampleData;

0 commit comments

Comments
 (0)