-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/selector org #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/selector org #606
Changes from 3 commits
667a0a5
25f4478
7ac652e
9dae22e
1818d54
622b3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { getCurrentUIData } from "."; | ||
| import { initialState } from ".."; | ||
| import { ColorSettings } from "../selection/types"; | ||
|
|
||
| describe("getCurrentUIData", () => { | ||
| it("returns empty array if default UI data has not been entered yet", () => { | ||
| expect(getCurrentUIData(initialState)).toEqual([]); | ||
| }); | ||
| it("returns selectedUIDisplayData if colorSetting is equal to ColorSettings.UserSelected", () => { | ||
| expect( | ||
| getCurrentUIData({ | ||
| ...initialState, | ||
| trajectory: { | ||
| ...initialState.trajectory, | ||
| defaultUIData: [ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#bbbbbb", | ||
| }, | ||
| ], | ||
| }, | ||
| selection: { | ||
| ...initialState.selection, | ||
| currentColorSettings: ColorSettings.UserSelected, | ||
| selectedUIDisplayData: [ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#000", | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| ).toEqual([ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#000", | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it("returns defaultUIData if colorSetting is euqal to ColorSettings.Default", () => { | ||
| expect( | ||
| getCurrentUIData({ | ||
| ...initialState, | ||
| trajectory: { | ||
| ...initialState.trajectory, | ||
| defaultUIData: [ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#bbbbbb", | ||
| }, | ||
| ], | ||
| }, | ||
| selection: { | ||
| ...initialState.selection, | ||
| currentColorSettings: ColorSettings.Default, | ||
| selectedUIDisplayData: [ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#000", | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| ).toEqual([ | ||
| { | ||
| name: "agent1", | ||
| displayStates: [], | ||
| color: "#bbbbbb", | ||
| }, | ||
| ]); | ||
| }); | ||
| }); |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a short comment at the top of this file that describes what this file is for, like you did in the PR description? I also see that the parent |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { createSelector } from "reselect"; | ||
|
|
||
| import { getDefaultUIDisplayData } from "../trajectory/selectors"; | ||
| import { | ||
| getCurrentColorSettings, | ||
| getSelectedUIDisplayData, | ||
| } from "../selection/selectors"; | ||
| import { ColorSettings } from "../selection/types"; | ||
| import { UIDisplayData } from "@aics/simularium-viewer"; | ||
|
||
|
|
||
| export const getCurrentUIData = createSelector( | ||
| [ | ||
| getCurrentColorSettings, | ||
| getSelectedUIDisplayData, | ||
| getDefaultUIDisplayData, | ||
| ], | ||
| ( | ||
| colorSetting: ColorSettings, | ||
| sessionData: UIDisplayData, | ||
| defaultData: UIDisplayData | ||
| ) => { | ||
| const fileHasBeenParsed = defaultData.length > 0; | ||
| if (!fileHasBeenParsed) { | ||
| return []; | ||
| } | ||
| if (colorSetting === ColorSettings.UserSelected) { | ||
| return sessionData; | ||
| } | ||
| return defaultData; | ||
| } | ||
| ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important in forthcoming work but not functionally relevant until it replaces Mostly here to demonstrate the reasoning behind |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,5 @@ export const getSelectedAgentMetadata = (state: State) => | |
| state.selection.selectedAgentMetadata; | ||
| export const getSelectedUIDisplayData = (state: State) => | ||
| state.selection.selectedUIDisplayData; | ||
| export const getCurrentColorSettings = (state: State) => | ||
| state.selection.currentColorSettings; | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,3 +87,8 @@ export interface SetSelectedUIDisplayDataAction { | |
| payload: UIDisplayData; | ||
| type: string; | ||
| } | ||
|
|
||
| export enum ColorSettings { | ||
|
||
| UserSelected = "userSelected", | ||
| Default = "default", | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved