Skip to content

Commit f9822b8

Browse files
authored
Allow marking tabs not dirty in workspace (codesandbox#354)
1 parent f7ad166 commit f9822b8

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/DirectoryChildren.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Props = {
2424
parentShortid: string,
2525
sandboxTemplate: string,
2626
mainModuleId: string,
27+
markTabsNotDirty: ?Function,
2728
};
2829

2930
export default class DirectoryChildren extends React.PureComponent<Props> {
@@ -47,6 +48,7 @@ export default class DirectoryChildren extends React.PureComponent<Props> {
4748
deleteEntry,
4849
currentModuleId,
4950
isInProjectView,
51+
markTabsNotDirty,
5052
} = this.props;
5153

5254
return (
@@ -68,6 +70,7 @@ export default class DirectoryChildren extends React.PureComponent<Props> {
6870
directories={directories}
6971
currentModuleId={currentModuleId}
7072
isInProjectView={isInProjectView}
73+
markTabsNotDirty={markTabsNotDirty}
7174
/>
7275
))}
7376
{modules.filter(x => x.directoryShortid === parentShortid).map(m => {
@@ -95,6 +98,7 @@ export default class DirectoryChildren extends React.PureComponent<Props> {
9598
isInProjectView={isInProjectView}
9699
isMainModule={mainModule}
97100
moduleHasError={hasError}
101+
markTabsNotDirty={markTabsNotDirty}
98102
/>
99103
);
100104
})}

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Props = {
4141
isInProjectView: boolean, // eslint-disable-line
4242
moduleHasError: boolean,
4343
closeTree: ?() => void, // eslint-disable-line
44+
markTabsNotDirty: Function,
4445
};
4546

4647
type State = {
@@ -174,6 +175,7 @@ class Entry extends React.PureComponent<Props, State> {
174175
onCreateDirectoryClick,
175176
deleteEntry,
176177
onClick,
178+
markTabsNotDirty,
177179
rename,
178180
isNotSynced,
179181
isMainModule,
@@ -186,6 +188,7 @@ class Entry extends React.PureComponent<Props, State> {
186188
<div>
187189
<EntryContainer
188190
onClick={setCurrentModule ? this.setCurrentModule : onClick}
191+
onDoubleClick={markTabsNotDirty}
189192
depth={depth}
190193
nameValidationError={error}
191194
active={active}

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ class DirectoryEntry extends React.PureComponent {
220220
sandboxActions.setCurrentModule(sandboxId, moduleId);
221221
};
222222

223+
markTabsNotDirty = () => {
224+
this.props.sandboxActions.markTabsNotDirty(this.props.sandboxId);
225+
};
226+
223227
render() {
224228
const {
225229
id,
@@ -291,6 +295,7 @@ class DirectoryEntry extends React.PureComponent {
291295
setCurrentModule={this.setCurrentModule}
292296
currentModuleId={currentModuleId}
293297
isInProjectView={isInProjectView}
298+
markTabsNotDirty={this.markTabsNotDirty}
294299
/>
295300
{creating === 'module' && (
296301
<Entry

0 commit comments

Comments
 (0)