currentStudioIds now an array; reverted a few changes

This commit is contained in:
Ben Wheeler 2018-07-31 15:00:56 -04:00
parent 8eec0d3a87
commit 097fb66955
11 changed files with 14734 additions and 23 deletions

1
.gitignore vendored
View file

@ -4,7 +4,6 @@
# NPM # NPM
/node_modules /node_modules
npm-* npm-*
package-lock.json
# Build # Build
/build /build

View file

@ -14,10 +14,10 @@ build:
@make webpack @make webpack
clean: clean:
rm -rf ./build
rm -rf ./intl
mkdir -p build mkdir -p build
rm -rf ./build/*
mkdir -p intl mkdir -p intl
rm -rf ./intl/*
deploy: deploy:
@make build @make build

View file

@ -2,7 +2,6 @@ version: '3.4'
volumes: volumes:
npm_data: npm_data:
runtime_data: runtime_data:
intl_data:
networks: networks:
scratch-api_scratch_network: scratch-api_scratch_network:
@ -34,7 +33,6 @@ services:
nocopy: true nocopy: true
- npm_data:/var/app/current/node_modules - npm_data:/var/app/current/node_modules
- runtime_data:/runtime - runtime_data:/runtime
- intl_data:/var/app/current/intl
ports: ports:
- "8333:8333" - "8333:8333"
networks: networks:

14707
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -48,7 +48,7 @@ $active-gray: hsla(0, 0, 0, .1);
$active-dark-gray: hsla(0, 0, 0, .2); $active-dark-gray: hsla(0, 0, 0, .2);
$box-shadow-gray: hsla(0, 0, 0, .25); $box-shadow-gray: hsla(0, 0, 0, .25);
$overlay-gray: hsla(0, 0, 0, .75); $overlay-gray: hsla(0, 0, 0, .75);
$transparent: rgba(229, 240, 254, 0); $transparent-light-blue: rgba(229, 240, 254, 0);
/* Typography Colors */ /* Typography Colors */
$header-gray: hsla(225, 15, 40, 1); //#575E75 $header-gray: hsla(225, 15, 40, 1); //#575E75

View file

@ -17,14 +17,14 @@ class AddToStudioModal extends React.Component {
} }
componentWillUpdate () { componentWillUpdate () {
this.checkIfFinishedUpdating(); this.closeIfFinishedUpdating();
} }
hasOutstandingUpdates () { hasOutstandingUpdates () {
return (this.props.studios.some(studio => (studio.hasRequestOutstanding === true))); return (this.props.studios.some(studio => (studio.hasRequestOutstanding === true)));
} }
checkIfFinishedUpdating () { closeIfFinishedUpdating () {
if (this.state.waitingToClose === true && this.hasOutstandingUpdates() === false) { if (this.state.waitingToClose === true && this.hasOutstandingUpdates() === false) {
this.closeAndStopWaiting(); this.closeAndStopWaiting();
} }
@ -44,7 +44,7 @@ class AddToStudioModal extends React.Component {
handleSubmit () { handleSubmit () {
this.setState({waitingToClose: true}, () => { this.setState({waitingToClose: true}, () => {
this.checkIfFinishedUpdating(); this.closeIfFinishedUpdating();
}); });
} }

View file

@ -85,7 +85,7 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
background: linear-gradient( background: linear-gradient(
$transparent, $transparent-light-blue,
$ui-blue-white $ui-blue-white
); );
height: 32px; height: 32px;

View file

@ -1,4 +1,4 @@
const truncate = require('lodash.truncate'); const truncateAtWordBoundary = require('../../../lib/truncate').truncateAtWordBoundary;
const PropTypes = require('prop-types'); const PropTypes = require('prop-types');
const React = require('react'); const React = require('react');
const classNames = require('classnames'); const classNames = require('classnames');
@ -45,7 +45,7 @@ const StudioButton = ({
{'studio-selector-button-text-unselected': !includesProject} {'studio-selector-button-text-unselected': !includesProject}
)} )}
> >
{truncate(title, {length: 20, separator: /[.,:;]*\s+/})} {truncateAtWordBoundary(title, 20)}
</div> </div>
<div <div
className={classNames( className={classNames(

9
src/lib/truncate.js Normal file
View file

@ -0,0 +1,9 @@
const lodashTruncate = require('lodash.truncate');
/*
* Function that applies regex for word boundaries, replaces removed string
* with indication of ellipsis (...)
*/
module.exports.truncateAtWordBoundary = (str, length) => (
lodashTruncate(str, {length: length, separator: /[.,:;]*\s+/})
);

View file

@ -32,7 +32,7 @@ module.exports.getInitialState = () => ({
parent: {}, parent: {},
projectStudios: [], projectStudios: [],
curatedStudios: [], curatedStudios: [],
currentStudioIds: {} currentStudioIds: []
}); });
module.exports.previewReducer = (state, action) => { module.exports.previewReducer = (state, action) => {
@ -62,23 +62,21 @@ module.exports.previewReducer = (state, action) => {
// the project is currently in. // the project is currently in.
return Object.assign({}, state, { return Object.assign({}, state, {
projectStudios: action.items, projectStudios: action.items,
currentStudioIds: action.items.reduce((ids, studio) => { currentStudioIds: action.items.map(item => item.id)
ids[studio.id] = true;
return ids;
}, {})
}); });
case 'SET_CURATED_STUDIOS': case 'SET_CURATED_STUDIOS':
return Object.assign({}, state, {curatedStudios: action.items}); return Object.assign({}, state, {curatedStudios: action.items});
case 'ADD_PROJECT_TO_STUDIO': case 'ADD_PROJECT_TO_STUDIO':
// add studio id to our studios-that-this-project-belongs-to set. // add studio id to our studios-that-this-project-belongs-to set.
state.currentStudioIds[action.studioId] = true; state.currentStudioIds.push(action.studioId);
return Object.assign({}, state, { return Object.assign({}, state, {
currentStudioIds: Object.assign({}, state.currentStudioIds) currentStudioIds: state.currentStudioIds.slice()
}); });
case 'REMOVE_PROJECT_FROM_STUDIO': case 'REMOVE_PROJECT_FROM_STUDIO':
delete state.currentStudioIds[action.studioId];
return Object.assign({}, state, { return Object.assign({}, state, {
currentStudioIds: Object.assign({}, state.currentStudioIds) currentStudioIds: state.currentStudioIds.filter(item => (
item !== action.studioId
))
}); });
case 'SET_COMMENTS': case 'SET_COMMENTS':
return Object.assign({}, state, { return Object.assign({}, state, {

View file

@ -404,7 +404,7 @@ const consolidateStudiosInfo = (curatedStudios, projectStudios, currentStudioIds
const consolidatedStudios = []; const consolidatedStudios = [];
projectStudios.forEach(projectStudio => { projectStudios.forEach(projectStudio => {
const includesProject = (projectStudio.id in currentStudioIds); const includesProject = (currentStudioIds.indexOf(projectStudio.id) !== -1);
const consolidatedStudio = const consolidatedStudio =
Object.assign({}, projectStudio, {includesProject: includesProject}); Object.assign({}, projectStudio, {includesProject: includesProject});
consolidatedStudios.push(consolidatedStudio); consolidatedStudios.push(consolidatedStudio);
@ -413,7 +413,7 @@ const consolidateStudiosInfo = (curatedStudios, projectStudios, currentStudioIds
// copy the curated studios that project is not in // copy the curated studios that project is not in
curatedStudios.forEach(curatedStudio => { curatedStudios.forEach(curatedStudio => {
if (!projectStudios.some(projectStudio => (projectStudio.id === curatedStudio.id))) { if (!projectStudios.some(projectStudio => (projectStudio.id === curatedStudio.id))) {
const includesProject = (curatedStudio.id in currentStudioIds); const includesProject = (currentStudioIds.indexOf(curatedStudio.id) !== -1);
const consolidatedStudio = const consolidatedStudio =
Object.assign({}, curatedStudio, {includesProject: includesProject}); Object.assign({}, curatedStudio, {includesProject: includesProject});
consolidatedStudios.push(consolidatedStudio); consolidatedStudios.push(consolidatedStudio);