1
- import {
2
- useCommitTreeStateStore ,
3
- SelectedCommit ,
4
- } from 'explorviz-frontend/src/stores/commit-tree-state' ;
1
+ import { useCommitTreeStateStore } from 'explorviz-frontend/src/stores/commit-tree-state' ;
5
2
import { useRenderingServiceStore } from 'explorviz-frontend/src/stores/rendering-service' ;
6
3
import { useVisibilityServiceStore } from 'explorviz-frontend/src/stores/visibility-service' ;
7
- import { useShallow } from 'zustand/react/shallow' ;
8
- import Dropdown from 'react-bootstrap/Dropdown' ;
9
- import { DropdownButton } from 'react-bootstrap' ;
10
4
import { useState } from 'react' ;
11
- import { useToastHandlerStore } from 'explorviz-frontend/src/stores/toast-handler' ;
12
-
13
- interface IArgs {
14
- selectedAppName : string ;
15
- selectedCommits : Map < string , SelectedCommit [ ] > ;
16
- }
5
+ import { DropdownButton } from 'react-bootstrap' ;
6
+ import Dropdown from 'react-bootstrap/Dropdown' ;
7
+ import { useShallow } from 'zustand/react/shallow' ;
17
8
18
- export default function EvolutionRenderingButtons ( args : IArgs ) {
9
+ export default function EvolutionRenderingButtons ( ) {
19
10
const commitTreeState = useCommitTreeStateStore (
20
11
useShallow ( ( state ) => ( {
21
12
resetSelectedCommits : state . resetSelectedCommits ,
@@ -31,8 +22,14 @@ export default function EvolutionRenderingButtons(args: IArgs) {
31
22
} ) )
32
23
) ;
33
24
34
- const showErrorToastMessage = useToastHandlerStore (
35
- ( state ) => state . showErrorToastMessage
25
+ const getCurrentSelectedApplicationName = useCommitTreeStateStore (
26
+ ( state ) => state . getCurrentSelectedApplicationName
27
+ ) ;
28
+
29
+ const { getSelectedCommits } = useCommitTreeStateStore (
30
+ useShallow ( ( state ) => ( {
31
+ getSelectedCommits : state . getSelectedCommits ,
32
+ } ) )
36
33
) ;
37
34
38
35
const visService = useVisibilityServiceStore (
@@ -67,11 +64,6 @@ export default function EvolutionRenderingButtons(args: IArgs) {
67
64
evolutionMode . renderStatic = true ;
68
65
evolutionMode . renderOnlyDifferences = false ;
69
66
} else if ( x === 'difference' ) {
70
- if ( args . selectedCommits . size < 2 ) {
71
- showErrorToastMessage (
72
- 'Cannot show differences, less than 2 commits selected'
73
- ) ;
74
- }
75
67
evolutionMode . renderStatic = true ;
76
68
evolutionMode . renderOnlyDifferences = true ;
77
69
}
@@ -80,10 +72,12 @@ export default function EvolutionRenderingButtons(args: IArgs) {
80
72
81
73
return (
82
74
< div className = "col-md-auto" >
83
- { args . selectedAppName && (
75
+ { getCurrentSelectedApplicationName ( ) && (
84
76
< div className = "row justify-content-md-center" >
85
- { ( args . selectedCommits . get ( args . selectedAppName ) ?. length === 1 ||
86
- args . selectedCommits . get ( args . selectedAppName ) ?. length === 2 ) && (
77
+ { ( getSelectedCommits ( ) . get ( getCurrentSelectedApplicationName ( ) )
78
+ ?. length === 1 ||
79
+ getSelectedCommits ( ) . get ( getCurrentSelectedApplicationName ( ) )
80
+ ?. length === 2 ) && (
87
81
< div className = "col-md-auto" >
88
82
< div className = "d-flex" >
89
83
< button
@@ -96,7 +90,7 @@ export default function EvolutionRenderingButtons(args: IArgs) {
96
90
</ div >
97
91
</ div >
98
92
) }
99
- { args . selectedCommits . size > 0 && (
93
+ { getSelectedCommits ( ) . size > 0 && (
100
94
< div className = "col-md-auto" >
101
95
< DropdownButton
102
96
id = "dropdown-basic-button"
0 commit comments