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
/node_modules
npm-*
package-lock.json
# Build
/build

View file

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

View file

@ -2,7 +2,6 @@ version: '3.4'
volumes:
npm_data:
runtime_data:
intl_data:
networks:
scratch-api_scratch_network:
@ -34,7 +33,6 @@ services:
nocopy: true
- npm_data:/var/app/current/node_modules
- runtime_data:/runtime
- intl_data:/var/app/current/intl
ports:
- "8333:8333"
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);
$box-shadow-gray: hsla(0, 0, 0, .25);
$overlay-gray: hsla(0, 0, 0, .75);
$transparent: rgba(229, 240, 254, 0);
$transparent-light-blue: rgba(229, 240, 254, 0);
/* Typography Colors */
$header-gray: hsla(225, 15, 40, 1); //#575E75

View file

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

View file

@ -85,7 +85,7 @@
bottom: 0;
left: 0;
background: linear-gradient(
$transparent,
$transparent-light-blue,
$ui-blue-white
);
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 React = require('react');
const classNames = require('classnames');
@ -45,7 +45,7 @@ const StudioButton = ({
{'studio-selector-button-text-unselected': !includesProject}
)}
>
{truncate(title, {length: 20, separator: /[.,:;]*\s+/})}
{truncateAtWordBoundary(title, 20)}
</div>
<div
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: {},
projectStudios: [],
curatedStudios: [],
currentStudioIds: {}
currentStudioIds: []
});
module.exports.previewReducer = (state, action) => {
@ -62,23 +62,21 @@ module.exports.previewReducer = (state, action) => {
// the project is currently in.
return Object.assign({}, state, {
projectStudios: action.items,
currentStudioIds: action.items.reduce((ids, studio) => {
ids[studio.id] = true;
return ids;
}, {})
currentStudioIds: action.items.map(item => item.id)
});
case 'SET_CURATED_STUDIOS':
return Object.assign({}, state, {curatedStudios: action.items});
case 'ADD_PROJECT_TO_STUDIO':
// 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, {
currentStudioIds: Object.assign({}, state.currentStudioIds)
currentStudioIds: state.currentStudioIds.slice()
});
case 'REMOVE_PROJECT_FROM_STUDIO':
delete state.currentStudioIds[action.studioId];
return Object.assign({}, state, {
currentStudioIds: Object.assign({}, state.currentStudioIds)
currentStudioIds: state.currentStudioIds.filter(item => (
item !== action.studioId
))
});
case 'SET_COMMENTS':
return Object.assign({}, state, {

View file

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