var AppConstants = require('../constants/AppConstants'); var AppDispatcher = require('../dispatchers/AppDispatcher'); var EventEmitter = require('events').EventEmitter; var Session = require('./Session'); var assign = require('object-assign'); var MY_PROJECTS_LOADED = 'my_projects_loaded'; var ALL_PROJECTS_LOADED = 'all_projects_loaded'; var PROJECT_CREATED = 'project_created'; var PROJECT_CREATION_FAILED = 'project_creation_failed'; var MEMBER_ADDED = 'member_added'; var MEMBER_ADD_FAILED = 'member_add_failed'; var cache = { 'my': null, 'all': null }; var Projects = assign({}, EventEmitter.prototype, { getMyProjects: function () { return cache['my']; }, getAllProjects: function () { return cache['all']; }, invalidateCache: function () { cache['my'] = null; cache['all'] = null; }, listMyProjects: function () { this.invalidateCache(); var client = Session.getClient(); var ajax = client.listMySyncProjects(); var self = this; ajax.done(function (data) { cache['my'] = data; self.emitMyProjectsLoaded(); }); }, listAllProjects: function () { this.invalidateCache(); var client = Session.getClient(); var ajax = client.listAllSyncProjects(); var self = this; ajax.done(function (data) { cache['all'] = data; self.emitAllProjectsLoaded(); }); }, createProject: function (name, description, depotDir) { this.invalidateCache(); var client = Session.getClient(); var opts = {name: name}; if (description) { opts.description = description; } if (depotDir) { opts.depotDir = depotDir; } var ajax = client.createSyncProject(opts); var self = this; ajax.done(function (project) { self.emitProjectCreated(project); }); ajax.fail(function () { self.emitProjectCreationFailed(); }); }, addMemberToProject: function (project, login) { this.invalidateCache(); var client = Session.getClient(); project.members.push(login); var ajax = client.updateSyncProject(project); var self = this; ajax.done(function (updated) { self.emitMemberAdded(updated, login); }); ajax.fail(function () { self.emitMemberAddFailed(project, login); }); }, emitMyProjectsLoaded: function () { this.emit(MY_PROJECTS_LOADED, this.getMyProjects()); }, addMyProjectsLoadedListener: function (callback) { this.on(MY_PROJECTS_LOADED, callback); }, removeMyProjectsLoadedListener: function (callback) { this.removeListener(MY_PROJECTS_LOADED, callback); }, emitAllProjectsLoaded: function () { this.emit(ALL_PROJECTS_LOADED, this.getAllProjects()); }, addAllProjectsLoadedListener: function (callback) { this.on(ALL_PROJECTS_LOADED, callback); }, removeAllProjectsLoadedListener: function (callback) { this.removeListener(ALL_PROJECTS_LOADED, callback); }, emitProjectCreated: function (project) { this.emit(PROJECT_CREATED, project); }, addProjectCreatedListener: function (callback) { this.on(PROJECT_CREATED, callback); }, removeProjectCreatedListener: function (callback) { this.removeListener(PROJECT_CREATED, callback); }, emitProjectCreationFailed: function () { this.emit(PROJECT_CREATION_FAILED); }, addProjectCreationFailedListener: function (callback) { this.on(PROJECT_CREATION_FAILED, callback); }, removeProjectCreationFailedListener: function (callback) { this.removeListener(PROJECT_CREATION_FAILED, callback); }, emitMemberAdded: function (project, login) { this.emit(MEMBER_ADDED, project, login); }, addMemberAddedListener: function (callback) { this.on(MEMBER_ADDED, callback); }, removeMemberAddedListener: function (callback) { this.removeListener(MEMBER_ADDED, callback); }, emitMemberAddFailed: function (project, login) { this.emit(MEMBER_ADD_FAILED, project, login); }, addMemberAddFailedListener: function (callback) { this.on(MEMBER_ADD_FAILED, callback); }, removeMemberAddFailedListener: function (callback) { this.removeListener(MEMBER_ADD_FAILED, callback); } }); AppDispatcher.register(function (action) { switch (action.actionType) { case AppConstants.CREATE_PROJECT: Projects.createProject(action.name, action.description, action.depotDir); break; case AppConstants.LIST_MY_PROJECTS: Projects.listMyProjects(); break; case AppConstants.LIST_ALL_PROJECTS: Projects.listAllProjects(); break; case AppConstants.ADD_MEMBER: Projects.addMemberToProject(action.project, action.login); break; default: // Do nothing } }); module.exports = Projects;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_components/project_management/stores/Projects.js | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_components/project_management/stores/Projects.js | |||||
#7 | 14176 | tjuricek |
Add a basic 'add member' function to the project details page. There appears to be some kind of funky caching issue with the components. The project data does get updated, so this UI is not 100% bug proof. Also, there's no autocomplete yet. |
||
#6 | 14151 | tjuricek |
Add depot tree control and selection to the create projects page. Styling and error checking is kept to a minimum for the time being. Our goal is just internal workflow and feedback. |
||
#5 | 14108 | tjuricek |
Added models for handling Perforce server depot listing and traversal. This is not complete, however, the models are a start to making it easy to generate a tree control. (Most tree controls in the wild assume you know the tree structure from the start, which is not true in our case.) The tricky bit is making it easy to build the tree out given that you're visiting only one directory at a time. |
||
#4 | 14105 | tjuricek |
add 'listMy' and 'listAll' sync project variations to the JS API. Also, set up the project list to switch between the two project types. Also, setup each item in the project list to not be a grouped list item, but a custom view component. Not particularly useful, but it just displays a description now. |
||
#3 | 14020 | tjuricek | Simple project creation for the Project Management UI | ||
#2 | 13999 | tjuricek |
Switching to use HWS JavaScript API for Store backend. Switching between node testing and browser testing environments isn't smooth yet. |
||
#1 | 13974 | tjuricek |
Moving 'ui/static' to 'helix_web_components' project, and altering some notes. Also, removed obsolete top-level Rake tasks. The "Helix Web Components" project will likely get moved elsewhere in the future. |
||
//guest/perforce_software/helix-web-services/main/ui/static/project_management/stores/Projects.js | |||||
#2 | 13960 | tjuricek |
Setup a development config for nginx /hws points to the new monolithic helix_web_serivces instance / points to a static directory This static directory may end up getting moved around into other projects, I'm not sure where that location should be. |
||
#1 | 13707 | tjuricek |
Infrastructure for including a "project management" React application. This attempts to create a fairly simple installer that creates a 'static' folder based on ui/static that gets hosted by the nginx front end. Right now, it's the only app, so the default page is this application. It was called "pws2" during a prototyping phase. Another prototype, "pws" and the related "project" module, is removed since that was a Sinatra-based approach that will be much more difficult to integrate into anything else. I'm running into a couple of issues with notifications setup, it's still not 100%, so I'm disabling this for now from the default 'god' configuration. (The service isn't 100% functional yet, anyway.) |
||
//guest/perforce_software/helix-web-services/main/ui/static/pms2/stores/Projects.js | |||||
#1 | 13645 | tjuricek |
React.js + Flux prototype This just logs in and displays a list of projects (create one with the other app for now). |