diff --git a/src/components/app.jsx b/src/components/app.jsx index ae92ca0..301c657 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -1373,12 +1373,36 @@ export default class App extends Component { } templateSelectHandler(template, isFileMode) { - fetch(`templates/template-${isFileMode ? 'files-' : ''}${template.id}.json`) - .then(res => res.json()) - .then(json => { - this.forkItem(json); + if (isFileMode) { + itemService.getCountOfFileModeItems().then(count => { + if (count < 2) { + fetch( + `templates/template-${isFileMode ? 'files-' : ''}${ + template.id + }.json` + ) + .then(res => res.json()) + .then(json => { + this.forkItem(json); + }); + this.setState({ isCreateNewModalOpen: false }); + } else { + trackEvent('ui', 'FileModeCreationLimitMessageSeen'); + return alert( + '"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.' + ); + } }); - this.setState({ isCreateNewModalOpen: false }); + } else { + fetch( + `templates/template-${isFileMode ? 'files-' : ''}${template.id}.json` + ) + .then(res => res.json()) + .then(json => { + this.forkItem(json); + }); + this.setState({ isCreateNewModalOpen: false }); + } } importGithubRepoSelectHandler(repoUrl) { importGithubRepo(repoUrl).then(files => {