Skip to content

Commit c1b4f43

Browse files
added a another case to overlays to account hide the 'don't save' button. closes #247
1 parent 9ce3fc8 commit c1b4f43

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

src/constants/overlay-states.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const overlayStates = {
99
OVERWRITE_OVERLAY: 'OVERWRITE_OVERLAY',
1010
NEW_VERSION_OVERLAY: 'NEW_VERSION_OVERLAY',
1111
DELETE_FILE_OVERLAY: 'DELETE_FILE_OVERLAY',
12+
SAVE_ON_CHANGE_OVERLAY: 'SAVE_ON_CHANGE_OVERLAY',
1213
DELETE_PROJECT_OVERLAY: 'DELETE_PROJECT_OVERLAY'
1314
};
1415

src/creators/show-save-overlay.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ const {
55
} = require('../constants/action-types');
66

77
const {
8-
SAVE_OVERLAY
8+
SAVE_OVERLAY,
9+
SAVE_ON_CHANGE_OVERLAY
910
} = require('../constants/overlay-states');
1011

11-
function showSaveOverlay(){
12+
function showSaveOverlay(showDontSaveButton){
13+
const state = showDontSaveButton ? SAVE_ON_CHANGE_OVERLAY : SAVE_OVERLAY;
1214
return {
1315
type: SHOW_OVERLAY,
1416
payload: {
15-
state: SAVE_OVERLAY
17+
state
1618
}
1719
};
1820
}

src/plugins/handlers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function handlers(app, opts, done){
9898
// TODO: DRY this up
9999
if(isNew && _.trim(content).length){
100100
store.dispatch(creators.queueNewFile());
101-
showSaveOverlay();
101+
showSaveOverlay(false);
102102
return;
103103
}
104104

@@ -114,7 +114,7 @@ function handlers(app, opts, done){
114114
const { filename, content, isNew, cwd } = workspace.getState();
115115

116116
if(isNew){
117-
showSaveOverlay();
117+
showSaveOverlay(false);
118118
} else {
119119
workspace.saveFile(filename, content)
120120
.then(function(){
@@ -185,7 +185,7 @@ function handlers(app, opts, done){
185185
// TODO: DRY this up
186186
if(isNew && _.trim(content).length){
187187
store.dispatch(creators.queueChangeFile(filename));
188-
showSaveOverlay();
188+
showSaveOverlay(true);
189189
return;
190190
}
191191

src/plugins/overlays.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const {
2222
OVERWRITE_OVERLAY,
2323
NEW_VERSION_OVERLAY,
2424
DELETE_FILE_OVERLAY,
25+
SAVE_ON_CHANGE_OVERLAY,
2526
DELETE_PROJECT_OVERLAY
2627
} = require('../constants/overlay-states');
2728

@@ -47,6 +48,9 @@ function overlays(app, opts, done){
4748
case SAVE_OVERLAY:
4849
renderOverlay(<SaveOverlay workspace={workspace} handlers={handlers} />);
4950
break;
51+
case SAVE_ON_CHANGE_OVERLAY:
52+
renderOverlay(<SaveOverlay workspace={workspace} handlers={handlers} showDontSaveButton={true} />);
53+
break;
5054
case OVERWRITE_OVERLAY:
5155
renderOverlay(<OverwriteOverlay store={store} handlers={handlers} />);
5256
break;

src/views/save-overlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class SaveOverlay extends React.Component {
106106
const { filename } = this.state;
107107

108108
let dontSaveButton;
109-
if(isNew){
109+
if(isNew && this.props.showDontSaveButton){
110110
dontSaveButton = (
111111
<Button onClick={this.dontSave}>Don't Save</Button>
112112
);

0 commit comments

Comments
 (0)