// The Location store keeps a single 'location' reference available that // has a few different structures: // // 1. The project list: // // { projectList: 'my' } // { projectList: 'all' } // // 2. A project details: // // { project: 'ID' } // // 3. Create a project: // // { createProject: true } var AppConstants = require('../constants/AppConstants'); var AppDispatcher = require('../dispatchers/AppDispatcher'); var EventEmitter = require('events').EventEmitter; var assign = require('object-assign'); // Events var NEW_LOCATION = 'new_location'; // Default values var DEFAULT_LOCATION = { projectList: "my" }; var Location = assign({}, EventEmitter.prototype, { getLocation: function() { var location = sessionStorage.getItem('location'); if (!location) { location = DEFAULT_LOCATION; } else { location = JSON.parse(location); } return location; }, setLocation: function(location) { sessionStorage.setItem('location', JSON.stringify(location)); // If we change the location as the result of another action (very common // to do after, say, we handle success of a project) we need to dispatch // the event outside of this dispatcher thread. var self = this; setTimeout(function() { self.emitNewLocation(); }); }, emitNewLocation: function() { this.emit(NEW_LOCATION); }, addNewLocationListener: function(callback) { this.on(NEW_LOCATION, callback); }, removeNewLocationListener: function(callback) { this.removeListener(NEW_LOCATION, callback); } }); AppDispatcher.register(function(action) { switch(action.actionType) { case AppConstants.CHANGE_LOCATION: Location.setLocation(action.location); break; default: // Do nothing } }); module.exports = Location;
# | 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/Location.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/Location.js | |||||
#2 | 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. |
||
#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/Location.js | |||||
#1 | 13962 | tjuricek |
Add 'location' store and integrate "Jest" for unit testing. The location will trigger different views of the main ProjectManagement component. The Jest framework allows us to create headless tests of the React component logic. It's a little tricky, and right now has a dependency on node 0.10. |