Skip to content

Commit efef5f9

Browse files
Add download setup feature
1 parent fe5fa2e commit efef5f9

8 files changed

Lines changed: 263 additions & 35 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"copy-text-to-clipboard": "^1.0.4",
3131
"d3-flextree": "^2.1.1",
3232
"directory-tree": "^2.1.0",
33+
"file-saver": "^2.0.0",
3334
"http-server": "^0.11.1",
3435
"js2flowchart": "^1.1.7",
3536
"lodash": "^4.17.10",

‎src/public/dist/bundle.js‎

Lines changed: 162 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/public/dist/bundle.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import { connect } from 'react-redux';
3+
import { Menu, Dropdown, Button, Icon } from 'antd';
4+
5+
import { downloadStore } from 'components/dataBus/store/actions';
6+
7+
const SettingsControl = ({ onDownloadClick }) => {
8+
const menu = (
9+
<Menu>
10+
<Menu.Item key={'download'}>
11+
<a target="_blank" rel="noopener noreferrer" onClick={onDownloadClick}>
12+
Download store <Icon type="download" />
13+
</a>
14+
</Menu.Item>
15+
<Menu.Item key={'upload'}>
16+
<a target="_blank" rel="noopener noreferrer" onClick={onDownloadClick}>
17+
Upload store <Icon type="upload" />
18+
</a>
19+
</Menu.Item>
20+
</Menu>
21+
);
22+
23+
return (
24+
<div className={'SettingsControl'}>
25+
<Dropdown overlay={menu} placement="bottomLeft">
26+
<Button size={'small'}>
27+
setup
28+
<Icon type="setting" />
29+
</Button>
30+
</Dropdown>
31+
</div>
32+
);
33+
};
34+
35+
const mapDispatchToProps = {
36+
onDownloadClick: downloadStore
37+
};
38+
39+
export default connect(
40+
null,
41+
mapDispatchToProps
42+
)(SettingsControl);

‎src/public/js/components/controls/ViewSwitches/component/List/ViewSwitchList.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import classNames from 'classnames';
33
import FlowSelect from 'components/controls/FlowSelect';
44
import ZoomControl from 'components/controls/ZoomControl';
5+
import SettingsContol from 'components/controls/SettingsControl';
56
import ViewSwitch from '../Item/ViewSwitch';
67
import './ViewSwitchList.scss';
78

@@ -38,7 +39,14 @@ const ViewSwitchList = props => {
3839
<div className={'side'}>
3940
<ZoomControl />
4041
</div>
41-
<div className={'side'}>{rightSide}</div>
42+
<div className={'side'}>
43+
{rightSide.concat(
44+
<div className={'settingContainer'} key={'setting'}>
45+
<div className={'spacer'} />
46+
<SettingsContol />
47+
</div>
48+
)}
49+
</div>
4250
</div>
4351
);
4452
};

‎src/public/js/components/controls/ViewSwitches/component/List/ViewSwitchList.scss‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,15 @@
1313
margin-right: 16px;
1414
}
1515
}
16+
17+
.settingContainer {
18+
display: flex;
19+
flex-direction: row;
20+
21+
.spacer {
22+
margin: 0 10px;
23+
height: 100%;
24+
border-left: 1px solid #d9d9d9;
25+
}
26+
}
1627
}

‎src/public/js/components/dataBus/store/actions.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import saveAs from 'file-saver';
2+
13
import { ACTIONS } from './constants';
24
import {
35
getTreeLayout,
@@ -202,3 +204,32 @@ const getFoldersForPaths = (paths, openedFolders, override) =>
202204

203205
return res;
204206
}, {});
207+
208+
// TODO: group and move actions to different files
209+
export const downloadStore = () => (dispatch, getState) => {
210+
const { viewSwitches, dataBus } = getState();
211+
212+
const partialStateToSave = {
213+
viewSwitches: {
214+
checkedState: viewSwitches.checkedState,
215+
disabledState: viewSwitches.disabledState,
216+
valuesState: viewSwitches.valuesState
217+
},
218+
dataBus: {
219+
sourceTree: dataBus.sourceTree,
220+
filesMap: dataBus.filesMap,
221+
foldersMap: dataBus.foldersMap,
222+
codeCrumbedFlowsMap: dataBus.codeCrumbedFlowsMap,
223+
dependenciesRootEntryName: dataBus.dependenciesRootEntryName
224+
}
225+
};
226+
227+
const fileName = 'cc-store-state.json';
228+
const fileToSave = new Blob([JSON.stringify(partialStateToSave, undefined, 2)], {
229+
type: 'application/json',
230+
name: fileName
231+
});
232+
233+
// TODO: use file data (uploaded after to dispatch action for DATA_BUS.SET_INITIAL_SOURCE_DATA
234+
saveAs(fileToSave, fileName);
235+
};

‎src/public/js/components/sideBar/component/CrumbsTab/index.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ const CrumbsTab = props => {
2222
>
2323
{flowStepsFiles.map((stepFile, i) => {
2424
return (
25-
<Panel header={`[${stepFile.step || '*'}] ${stepFile.file.path}`} key={i}>
25+
<Panel
26+
header={`[${typeof stepFile.step !== 'undefined' ? stepFile.step : '*'}] ${
27+
stepFile.file.path
28+
}`}
29+
key={i}
30+
>
2631
<Code
2732
limitedHeight={true}
2833
code={stepFile.file.fileCode || ''}

0 commit comments

Comments
 (0)