-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: option to highlight "Deep dependencies" when clicking on source…
… files (#180) * chore: add deep dependency node and edge color * feat: add "Deep dependencies" button and state * feat: select deep dependencies on click * chore: add changeset message * fix: never disable "Deep dependencies" * fix: only render deep dependencies when it's toggle is active * fix: only toggle one of "Circular dependencies" or "Deep dependencies" * chore: move ui mutation to reducer and dispatch "select_node" action * chore: state injectable select_node dispatcher * test: add toggle_deep test case * fix: prefer to mutate ui in toggleDependencies reducer * test: add select_node action spec
- Loading branch information
1 parent
9646be0
commit 93bc556
Showing
12 changed files
with
204 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"skott-webapp": minor | ||
--- | ||
|
||
Add option to highlight "Deep dependencies" when clicking on source files |
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,52 @@ | ||
import { AppState, storeDefaultValue } from "@/store/state"; | ||
import { AppStore } from "@/store/store"; | ||
import { BehaviorSubject } from "rxjs"; | ||
import { describe, expect, test } from "vitest"; | ||
import { toPromise } from "../utils"; | ||
import { networkReducers } from "./reducers"; | ||
import { selectNode } from "./select-node"; | ||
|
||
describe("When clicking on a node", () => { | ||
test(`Should update selected nodeId`, async () => { | ||
const appStore = new AppStore( | ||
new BehaviorSubject<AppState>(storeDefaultValue), | ||
networkReducers | ||
); | ||
|
||
const emittedEvents: string[] = []; | ||
const subscription = appStore.events$.subscribe((events) => { | ||
emittedEvents.push(events.action); | ||
}); | ||
|
||
const dispatchAction = selectNode(appStore); | ||
|
||
dispatchAction(['file-1.ts']); | ||
|
||
const { ui: uiState1 } = await toPromise(appStore.store$); | ||
|
||
expect(uiState1).toEqual({ | ||
...storeDefaultValue.ui, | ||
network: { | ||
...storeDefaultValue.ui.network, | ||
selectedNodeId: 'file-1.ts' | ||
}, | ||
}); | ||
|
||
dispatchAction(['file-2.ts']); | ||
|
||
const { ui: uiState2 } = await toPromise(appStore.store$); | ||
|
||
expect(uiState2).toEqual({ | ||
...storeDefaultValue.ui, | ||
network: { | ||
...storeDefaultValue.ui.network, | ||
selectedNodeId: 'file-2.ts' | ||
}, | ||
}); | ||
|
||
const appEvent = "select_node"; | ||
expect(emittedEvents).toEqual([appEvent, appEvent]); | ||
|
||
subscription.unsubscribe(); | ||
}); | ||
}); |
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,16 @@ | ||
import { AppStore } from "@/store/store"; | ||
|
||
export function selectNode(appStore: AppStore) { | ||
return function (nodes: string[]) { | ||
const { ui } = appStore.getState(); | ||
appStore.dispatch({ | ||
action: "select_node", | ||
payload: { | ||
nodeId: nodes.length > 0 ? nodes[0] : "", | ||
oldNodeId: ui.network.selectedNodeId | ||
}, | ||
}, { | ||
notify: true | ||
}); | ||
}; | ||
} |
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
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