Skip to content

Commit a0c2c20

Browse files
committed
fix file mode template fork condition
1 parent efb0492 commit a0c2c20

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/components/app.jsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,12 +1373,36 @@ export default class App extends Component {
13731373
}
13741374

13751375
templateSelectHandler(template, isFileMode) {
1376-
fetch(`templates/template-${isFileMode ? 'files-' : ''}${template.id}.json`)
1377-
.then(res => res.json())
1378-
.then(json => {
1379-
this.forkItem(json);
1376+
if (isFileMode) {
1377+
itemService.getCountOfFileModeItems().then(count => {
1378+
if (count < 2) {
1379+
fetch(
1380+
`templates/template-${isFileMode ? 'files-' : ''}${
1381+
template.id
1382+
}.json`
1383+
)
1384+
.then(res => res.json())
1385+
.then(json => {
1386+
this.forkItem(json);
1387+
});
1388+
this.setState({ isCreateNewModalOpen: false });
1389+
} else {
1390+
trackEvent('ui', 'FileModeCreationLimitMessageSeen');
1391+
return alert(
1392+
'"Files mode" is currently in beta and is limited to only 2 creations per user. You have already made 2 creations in Files mode.\n\nNote: You can choose to delete old ones to create new.'
1393+
);
1394+
}
13801395
});
1381-
this.setState({ isCreateNewModalOpen: false });
1396+
} else {
1397+
fetch(
1398+
`templates/template-${isFileMode ? 'files-' : ''}${template.id}.json`
1399+
)
1400+
.then(res => res.json())
1401+
.then(json => {
1402+
this.forkItem(json);
1403+
});
1404+
this.setState({ isCreateNewModalOpen: false });
1405+
}
13821406
}
13831407
importGithubRepoSelectHandler(repoUrl) {
13841408
importGithubRepo(repoUrl).then(files => {

0 commit comments

Comments
 (0)