1
- import { useRef } from 'react' ;
2
1
import {
3
2
useCommitTreeStateStore ,
4
3
SelectedCommit ,
@@ -8,6 +7,8 @@ import { useVisibilityServiceStore } from 'explorviz-frontend/src/stores/visibil
8
7
import { useShallow } from 'zustand/react/shallow' ;
9
8
import Dropdown from 'react-bootstrap/Dropdown' ;
10
9
import { DropdownButton } from 'react-bootstrap' ;
10
+ import { useState } from 'react' ;
11
+ import { useToastHandlerStore } from 'explorviz-frontend/src/stores/toast-handler' ;
11
12
12
13
interface IArgs {
13
14
selectedAppName : string ;
@@ -21,13 +22,19 @@ export default function EvolutionRenderingButtons(args: IArgs) {
21
22
} ) )
22
23
) ;
23
24
25
+ const [ modeLabel , setModeLabel ] = useState < string > ( 'Show Evolution Only' ) ;
26
+
24
27
const renderingService = useRenderingServiceStore (
25
28
useShallow ( ( state ) => ( {
26
29
triggerRenderingForSelectedCommits :
27
30
state . triggerRenderingForSelectedCommits ,
28
31
} ) )
29
32
) ;
30
33
34
+ const showErrorToastMessage = useToastHandlerStore (
35
+ ( state ) => state . showErrorToastMessage
36
+ ) ;
37
+
31
38
const visService = useVisibilityServiceStore (
32
39
useShallow ( ( state ) => ( {
33
40
configuration : state . _evolutionModeRenderingConfiguration ,
@@ -38,10 +45,6 @@ export default function EvolutionRenderingButtons(args: IArgs) {
38
45
} ) )
39
46
) ;
40
47
41
- const checkboxValues = useRef (
42
- visService . getCloneOfEvolutionModeRenderingConfiguration ( )
43
- ) ;
44
-
45
48
const unselectAllSelectedCommits = ( ) => {
46
49
commitTreeState . resetSelectedCommits ( ) ;
47
50
renderingService . triggerRenderingForSelectedCommits ( ) ;
@@ -64,6 +67,11 @@ export default function EvolutionRenderingButtons(args: IArgs) {
64
67
evolutionMode . renderStatic = true ;
65
68
evolutionMode . renderOnlyDifferences = false ;
66
69
} else if ( x === 'difference' ) {
70
+ if ( args . selectedCommits . size < 2 ) {
71
+ showErrorToastMessage (
72
+ 'Cannot show differences, less than 2 commits selected'
73
+ ) ;
74
+ }
67
75
evolutionMode . renderStatic = true ;
68
76
evolutionMode . renderOnlyDifferences = true ;
69
77
}
@@ -92,54 +100,49 @@ export default function EvolutionRenderingButtons(args: IArgs) {
92
100
< div className = "col-md-auto" >
93
101
< DropdownButton
94
102
id = "dropdown-basic-button"
95
- title = "Dropdown button"
103
+ title = { modeLabel }
96
104
variant = "secondary"
97
105
drop = "end"
98
106
>
99
107
< Dropdown . Item
100
- key = "Show Runtime Only"
101
- onClick = { ( ) => changeAnalysisMode ( 'dynamic' ) }
108
+ key = "Show Evolution Only"
109
+ onClick = { ( ) => {
110
+ changeAnalysisMode ( 'static' ) ;
111
+ setModeLabel ( 'Show Evolution Only' ) ;
112
+ } }
102
113
>
103
- Show Runtime Only
114
+ Show Evolution Only
104
115
</ Dropdown . Item >
105
116
< Dropdown . Item
106
- key = "Show Evolution Only"
107
- onClick = { ( ) => changeAnalysisMode ( 'static' ) }
117
+ key = "Show Runtime Only"
118
+ onClick = { ( ) => {
119
+ changeAnalysisMode ( 'dynamic' ) ;
120
+ setModeLabel ( 'Show Runtime Only' ) ;
121
+ } }
108
122
>
109
- Show Evolution Only
123
+ Show Runtime Only
110
124
</ Dropdown . Item >
111
125
< Dropdown . Item
112
126
key = "Show Runtime + Evolution"
113
- onClick = { ( ) => changeAnalysisMode ( 'static+dynamic' ) }
127
+ onClick = { ( ) => {
128
+ changeAnalysisMode ( 'static+dynamic' ) ;
129
+ setModeLabel ( 'Show Runtime + Evolution' ) ;
130
+ } }
114
131
>
115
132
Show Runtime + Evolution
116
133
</ Dropdown . Item >
117
134
< Dropdown . Item
118
135
key = "Evolution (Differences Only)"
119
- onClick = { ( ) => changeAnalysisMode ( 'difference' ) }
136
+ onClick = { ( ) => {
137
+ changeAnalysisMode ( 'difference' ) ;
138
+ setModeLabel ( 'Evolution (Differences Only)' ) ;
139
+ } }
120
140
>
121
141
Evolution (Differences Only)
122
142
</ Dropdown . Item >
123
143
</ DropdownButton >
124
144
</ div >
125
145
) }
126
- { args . selectedCommits . get ( args . selectedAppName ) ?. length === 2 && (
127
- < div className = "col-md-auto" >
128
- < div className = "d-flex" >
129
- < div style = { { marginRight : '4rem' } } > Only show differences</ div >
130
- < div className = "d-flex" >
131
- < label className = "wide-checkbox-container" >
132
- < input
133
- type = "checkbox"
134
- checked = { visService . configuration . renderOnlyDifferences }
135
- onChange = { ( ) => changeAnalysisMode ( 'difference' ) }
136
- />
137
- < span className = "wide-checkbox" > </ span >
138
- </ label >
139
- </ div >
140
- </ div >
141
- </ div >
142
- ) }
143
146
</ div >
144
147
) }
145
148
</ div >
0 commit comments