Skip to content

Commit f7e973e

Browse files
Merge branch 'development' of https://github.com/team-reactype/ReacType into development
2 parents 8a68dd6 + a31ec75 commit f7e973e

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

src/actions/components.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ export const openExpansionPanel = component => ({
240240
payload: { component },
241241
});
242242

243-
// export const deleteAllData = () => ({
244-
// type: DELETE_ALL_DATA,
245-
// });
243+
export const deleteAllData = () => ({
244+
type: DELETE_ALL_DATA,
245+
});
246246

247247
export const deleteProp = propId => dispatch => {
248248
dispatch({ type: DELETE_PROP, payload: propId });

src/components/MainContainerHeader.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const MainContainerHeader = (props) => {
5656
showGenerateAppModal,
5757
collapseColumn,
5858
rightColumnOpen,
59+
clearWorkspace,
5960
} = props;
6061

6162
return (
@@ -90,6 +91,16 @@ const MainContainerHeader = (props) => {
9091
>
9192
<GetAppIcon className={classes.light} />
9293
</Button>
94+
<Button
95+
color="secondary"
96+
aria-label="Delete All"
97+
variant="contained"
98+
onClick={clearWorkspace}
99+
disabled={totalComponents < 1}
100+
className={classes.clearButton}
101+
>
102+
Clear workspace
103+
</Button>
93104
</div>
94105
</Tooltip>
95106
</div>

src/containers/MainContainer.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
changeComponentFocusChild,
1515
deleteChild,
1616
deleteComponent,
17+
deleteAllData,
1718
createApplication,
1819
} from '../actions/components';
1920
import KonvaStage from '../components/KonvaStage';
@@ -47,6 +48,7 @@ const mapDispatchToProps = dispatch => ({
4748
genOption,
4849
}),
4950
),
51+
deleteAllData: () => dispatch(deleteAllData()),
5052
});
5153

5254
const mapStateToProps = store => ({
@@ -179,6 +181,20 @@ class MainContainer extends Component {
179181
});
180182
};
181183

184+
clearWorkspace = () => {
185+
this.setState({
186+
modal: createModal({
187+
message: 'Are you sure want to delete all data?',
188+
closeModal: this.closeModal,
189+
secBtnLabel: 'Clear Workspace',
190+
secBtnAction: () => {
191+
this.props.deleteAllData();
192+
this.closeModal();
193+
},
194+
}),
195+
});
196+
};
197+
182198
render() {
183199
const { draggable, scaleX, scaleY, modal, toggleClass } = this.state;
184200
const {
@@ -212,6 +228,7 @@ class MainContainer extends Component {
212228
<MainContainerHeader
213229
// showImageDeleteModal={showImageDeleteModal}
214230
showGenerateAppModal={showGenerateAppModal}
231+
clearWorkspace={this.clearWorkspace}
215232
/>
216233

217234
<div className="main" ref={main}>

0 commit comments

Comments
 (0)