Skip to content

Commit

Permalink
Merge pull request #15 from aMarcireau/known
Browse files Browse the repository at this point in the history
Known
  • Loading branch information
Alexandre Marcireau authored Nov 28, 2017
2 parents 89248e5 + 0e536d4 commit 01f006b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
2 changes: 2 additions & 0 deletions source/actions/manageMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function stateToJson(state, expand) {
return `${JSON.stringify({
appVersion: state.appVersion,
display: state.menu.display,
knownDois: Array.from(state.knownDois),
publicationRequests: Array.from(state.publicationRequests.entries()).map(
([id, publicationRequest]) => {
const savableDoiRequest = {...publicationRequest};
Expand Down Expand Up @@ -135,6 +136,7 @@ export function jsonToState(json, saveFilename, previousState) {
state.appVersion = previousState ? previousState.appVersion : undefined;
state.colors = previousState ? previousState.colors : undefined;
state.connected = previousState ? previousState.connected : undefined;
state.knownDois = new Set(state.knownDois);
state.publicationRequests = new Map(state.publicationRequests.map(
([id, publicationRequest]) => [id, {
...publicationRequest,
Expand Down
14 changes: 12 additions & 2 deletions source/containers/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ class Graph extends React.Component {
if (publication.doi === node.doi) {
node.keep = true;
found = true;
if (publication.status !== node.status || publication.selected !== node.selected || publication.locked !== node.locked) {
if (
publication.status !== node.status
|| publication.selected !== node.selected
|| nextProps.knownDois.has(publication.doi) !== node.known
|| publication.locked !== node.locked
) {
updateRequired = true;
node.status = publication.status;
node.selected = publication.selected;
node.known = nextProps.knownDois.has(node.doi);
if (node.locked && !publication.locked) {
node.fx = null;
node.fy = null;
Expand Down Expand Up @@ -164,6 +170,7 @@ class Graph extends React.Component {
}
}
publication.keep = true;
publication.known = nextProps.knownDois.has(publication.doi);
this.nodes.push(publication);
}
}
Expand Down Expand Up @@ -230,7 +237,6 @@ class Graph extends React.Component {
.attr('stroke', this.props.colors.secondaryContent)
;
d3NodeGroup.append('circle')
.attr('r', 20)
.attr('class', 'publication')
;
d3NodeGroup.append('text')
Expand Down Expand Up @@ -287,6 +293,9 @@ class Graph extends React.Component {
)
)
))
.attr('r', node => node.known ? '20' : '19')
.attr('stroke', this.props.colors.active)
.attr('stroke-width', node => node.known ? '0' : '2')
.on('mouseover', function(node) {
d3.select(this).attr('fill', colors.active);
})
Expand Down Expand Up @@ -451,6 +460,7 @@ export default connect(
: []
),
recommandedDois,
knownDois: state.knownDois,
display: state.menu.display,
sticky: state.graph.sticky,
colors: state.colors,
Expand Down
7 changes: 6 additions & 1 deletion source/containers/PublicationsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class PublicationsList extends React.Component {
style={{
width: '100%',
height: '50px',
padding: '6px',
paddingTop: '6px',
paddingRight: '6px',
paddingBottom: '6px',
paddingLeft: element.isKnown ? '6px' : '4px',
backgroundColor: (element.selected ?
this.props.colors.active
: (element.isCiting ?
Expand All @@ -65,6 +68,7 @@ class PublicationsList extends React.Component {
)
),
borderBottom: `1px solid ${this.props.colors.sideSeparator}`,
borderLeft: element.isKnown ? 'none': `2px solid ${this.props.colors.active}`,
cursor: 'pointer',
':hover': {
backgroundColor: this.props.colors.active,
Expand Down Expand Up @@ -176,6 +180,7 @@ export default connect(
doi,
isCiting: doisCitingSelected.has(doi),
isCited: doisCitedBySelected.has(doi),
isKnown: state.knownDois.has(doi),
}}
).sort(
(firstPublication, secondPublication) => {
Expand Down
2 changes: 1 addition & 1 deletion source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Origami",
"version": "0.4.0",
"version": "0.5.0",
"main": "main.js",
"private": true,
"devDependencies": {
Expand Down
17 changes: 17 additions & 0 deletions source/reducers/knownDois.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
SELECT_PUBLICATION,
} from '../constants/actionTypes'

export default function knownDois(state = new Set(), action) {
switch (action.type) {
case SELECT_PUBLICATION:
if (state.has(action.doi)) {
return state;
}
const newState = new Set(state);
newState.add(action.doi);
return newState;
default:
return state;
}
}
2 changes: 2 additions & 0 deletions source/reducers/origami.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {combineReducers} from 'redux'
import bibtexRequests from './bibtexRequests'
import connected from './connected'
import knownDois from './knownDois'
import publicationRequests from './publicationRequests'
import graph from './graph'
import menu from './menu'
Expand Down Expand Up @@ -83,6 +84,7 @@ export default function(state, action) {
bibtexRequests: (state = new Map()) => state,
colors: (state = {}) => state,
connected,
knownDois,
publicationRequests: (state = new Map()) => state,
graph,
menu,
Expand Down

0 comments on commit 01f006b

Please sign in to comment.