flow(function*({ name, url }) { self.importingWebUrl.setFalse(); const newProject = Project.create({ name, webUrl: url, isWebBased: true }); self.projects.push(newProject); })
flow(function*() { const { value: name } = yield prompt('Group title'); if (name) { self.groups.push( Group.create({ name }) ); } })
flow(function*(groupId) { try { const folderName = yield ipcc.callMain('open-dialog'); const splitted = folderName.split('/'); const group = groupId && typeof groupId !== 'object' && self.groups.find(g => g.id === groupId); let createdProject = Project.create({ name: splitted[splitted.length - 1], path: folderName, ...(group ? { group } : {}) }); self.addNewProject(createdProject); } catch (err) { console.error(err); alert(`Couldn't add project. Error: ${err.toString()}`); } })
setTimeout(() => { console.log('cloning', project, projectInfo); const store = getRoot(self); const newPath = path.join(store.settings.projectsPath, projectInfo.name); console.log('newPath', newPath); const files = fs.readdirSync(project.path); files.forEach(file => { let restrictedFiles = ['node_modules', 'build', 'dist', '.idea', '.vscode', '.git']; let isRestricted = restrictedFiles.includes(file); if (!isRestricted) { const fromFile = path.join(project.path, file); const toFile = path.join(newPath, file); fsExtra.copySync(fromFile, toFile); } }); const newProject = Project.create({ name: projectInfo.name, path: newPath }); self.addNewProject(newProject); setTimeout(() => { toast({ title: `Successfully cloned project!`, type: 'success' }); }, 1000); }, 500);
case IMPORT_WORKSPACE_TYPES.SEPARATELY: { self.importingWorkspace.folders.forEach(folder => { const project = Project.create({ name: getLastFromString(folder.path, '/'), path: folder.path const group = Group.create({ name: groupName }); self.groups.push(group); const project = Project.create({ name: getLastFromString(folder.path, '/'), path: folder.path,
} else { console.log('adding', folderPath); const newProject = Project.create({ name: getLastFromString(folderPath, '/'), path: folderPath
const getDefaultStore = () => RootStore.create({})
types.model({ books: types.array(Book) }) .views(self => ({ get readBooks() { return self.books.filter(book => book.read) }, booksByAuthor(author) { return self.books.filter(book => book.author === author) } }) ) .actions(self => ({ addBook(book) { self.books.push(book) }, remove(book) { destroy(book) } })) .create({ books: [] })
types.model('Books', { books: types.array(Book) }) .views(self => ({ get readBooks(){ return self.books.filter(book => book.read) }, booksByAuthor(author){ return self.books.filter(book => book.author === author) } })) .actions(self => ({ addBook(book) { self.books.push(book) }, removeBook(book){ destroy(book) } })) .create({ books: [{ title: 'Ready Player One', author: 'Ernest Cline', read: true }] })