generated from allen-cell-animated/github-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add compoundSelectors to redux * add ColorSettings enum and use container specific selector in ModelPanel * add currentColorSettings to selection branch state * rename ColorSetting from plural * fix typo in selection branch spread in getCurrentUIData test * add explanatory comment to compoundSelectors
- Loading branch information
Showing
10 changed files
with
220 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { getCurrentUIData } from "."; | ||
import { initialState } from ".."; | ||
import { ColorSetting } from "../selection/types"; | ||
|
||
describe("getCurrentUIData", () => { | ||
it("returns empty array if default UI data has not been entered yet", () => { | ||
expect(getCurrentUIData(initialState)).toEqual([]); | ||
1; | ||
}); | ||
it("returns selectedUIDisplayData if colorSetting is equal to ColorSetting.UserSelected", () => { | ||
expect( | ||
getCurrentUIData({ | ||
...initialState, | ||
trajectory: { | ||
...initialState.trajectory, | ||
defaultUIData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
], | ||
}, | ||
selection: { | ||
...initialState.selection, | ||
currentColorSetting: ColorSetting.UserSelected, | ||
selectedUIDisplayData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
], | ||
}, | ||
}) | ||
).toEqual([ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
]); | ||
}); | ||
|
||
it("returns defaultUIData if colorSetting is euqal to ColorSetting.Default", () => { | ||
expect( | ||
getCurrentUIData({ | ||
...initialState, | ||
trajectory: { | ||
...initialState.trajectory, | ||
defaultUIData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
], | ||
}, | ||
selection: { | ||
...initialState.selection, | ||
currentColorSetting: ColorSetting.Default, | ||
selectedUIDisplayData: [ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#000", | ||
}, | ||
], | ||
}, | ||
}) | ||
).toEqual([ | ||
{ | ||
name: "agent1", | ||
displayStates: [], | ||
color: "#bbbbbb", | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { createSelector } from "reselect"; | ||
import { UIDisplayData } from "@aics/simularium-viewer"; | ||
|
||
import { getDefaultUIDisplayData } from "../trajectory/selectors"; | ||
import { | ||
getCurrentColorSetting, | ||
getSelectedUIDisplayData, | ||
} from "../selection/selectors"; | ||
import { ColorSetting } from "../selection/types"; | ||
|
||
/** | ||
* compoundSelectors are selectors that consume state from multiple branches | ||
* of state, so don't belong in a particular branch's selectors file, | ||
* and are consumed by multiple containers, and so don't belong in a particular | ||
* container's selectors file. | ||
*/ | ||
|
||
export const getCurrentUIData = createSelector( | ||
[getCurrentColorSetting, getSelectedUIDisplayData, getDefaultUIDisplayData], | ||
( | ||
colorSetting: ColorSetting, | ||
sessionData: UIDisplayData, | ||
defaultData: UIDisplayData | ||
) => { | ||
const fileHasBeenParsed = defaultData.length > 0; | ||
if (!fileHasBeenParsed) { | ||
return []; | ||
} | ||
if (colorSetting === ColorSetting.UserSelected) { | ||
return sessionData; | ||
} | ||
return defaultData; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.