1- import { Icon } from '@gravity-ui/uikit' ;
1+ import { Icon , Spin } from '@gravity-ui/uikit' ;
22import classNames from 'classnames' ;
33import {
44 ArrowUturnCcwLeft ,
@@ -28,6 +28,7 @@ import {
2828import { ImageEntity , TreeViewMode } from '@/static/new-ui/types/store' ;
2929import { CHECKED , INDETERMINATE } from '@/constants/checked-statuses' ;
3030import { IconButton } from '@/static/new-ui/components/IconButton' ;
31+ import { TestStatus } from '@/constants' ;
3132import {
3233 getCheckedTests ,
3334 getSelectedImages ,
@@ -69,7 +70,9 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
6970
7071 const isRunTestsAvailable = useSelector ( state => state . app . availableFeatures )
7172 . find ( feature => feature . name === RunTestsFeature . name ) ;
72- const isRunning = useSelector ( state => state . running ) ;
73+ const isRunning = useSelector ( state => (
74+ state . tree . suites . allRootIds . some ( ( id ) => state . tree . suites . byId [ id ] . status === TestStatus . RUNNING )
75+ ) ) ;
7376
7477 const isEditScreensAvailable = useSelector ( state => state . app . availableFeatures )
7578 . find ( feature => feature . name === EditScreensFeature . name ) ;
@@ -177,43 +180,57 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
177180 const selectedOrVisible = isSelectedAtLeastOne ? 'selected' : 'visible' ;
178181 const areActionsDisabled = isRunning || ! isInitialized ;
179182
180- const viewButtons = < >
181- { isRunTestsAvailable && < IconButton className = { styles . iconButton } icon = { < Icon data = { Play } height = { 14 } /> }
182- tooltip = { `Run ${ selectedOrVisible } ` } view = { 'flat' } onClick = { handleRun }
183- disabled = { isRunning || ! isInitialized } > </ IconButton > }
184- { isEditScreensAvailable && (
185- isUndoButtonVisible ?
186- < IconButton className = { styles . iconButton } icon = { < Icon data = { ArrowUturnCcwLeft } /> } tooltip = { `Undo accepting ${ selectedOrVisible } screenshots` } view = { 'flat' } onClick = { handleUndo } disabled = { areActionsDisabled } > </ IconButton > :
187- < IconButton className = { styles . iconButton } icon = { < Icon data = { Check } /> } tooltip = { `Accept ${ selectedOrVisible } screenshots` } view = { 'flat' } onClick = { handleAccept } disabled = { areActionsDisabled || ! isAtLeastOneAcceptable } > </ IconButton >
188- ) }
189- { ( isRunTestsAvailable || isEditScreensAvailable ) && < div className = { styles . buttonsDivider } > </ div > }
190- < IconButton
191- icon = { < Icon data = { treeViewMode === TreeViewMode . Tree ? ListUl : Hierarchy } height = { 14 } /> }
192- tooltip = { treeViewMode === TreeViewMode . Tree ? 'Switch to list view' : 'Switch to tree view' }
193- view = { 'flat' }
194- onClick = { handleToggleTreeView }
195- disabled = { ! isInitialized } />
196- < IconButton icon = { < Icon data = { SquareDashed } height = { 14 } /> } tooltip = { 'Focus on active test' } view = { 'flat' } onClick = { onHighlightCurrentTest } disabled = { ! isFocusAvailable } />
197- < IconButton icon = { < Icon data = { ChevronsExpandVertical } height = { 14 } /> } tooltip = { 'Expand all' } view = { 'flat' } onClick = { handleExpandAll } disabled = { ! isInitialized } />
198- < IconButton icon = { < Icon data = { ChevronsCollapseVertical } height = { 14 } /> } tooltip = { 'Collapse all' } view = { 'flat' } onClick = { handleCollapseAll } disabled = { ! isInitialized } />
199- { areCheckboxesNeeded && < IconButton
200- icon = { < Icon data = { isIndeterminate ? SquareMinus : ( isSelectedAll ? SquareCheck : Square ) } /> }
201- tooltip = { isSelectedAtLeastOne ? 'Deselect all' : 'Select all' }
202- view = { 'flat' }
203- onClick = { handleToggleAll }
204- disabled = { ! isInitialized }
205- className = { styles . selectAllButton }
206- qa = "select-all-button"
207- /> }
208- </ > ;
183+ const getViewButtons = ( ) : ReactNode => (
184+ < >
185+ { isRunTestsAvailable && (
186+ isRunning
187+ ? (
188+ < Spin size = { 'xs' } style = { { marginRight : '6px' } } />
189+ ) : (
190+ < IconButton
191+ className = { styles . iconButton }
192+ icon = { < Icon data = { Play } height = { 14 } /> }
193+ tooltip = { `Run ${ selectedOrVisible } ` }
194+ view = { 'flat' }
195+ onClick = { handleRun }
196+ disabled = { isRunning || ! isInitialized }
197+ />
198+ )
199+ ) }
200+ { isEditScreensAvailable && (
201+ isUndoButtonVisible ?
202+ < IconButton className = { styles . iconButton } icon = { < Icon data = { ArrowUturnCcwLeft } /> } tooltip = { `Undo accepting ${ selectedOrVisible } screenshots` } view = { 'flat' } onClick = { handleUndo } disabled = { areActionsDisabled } > </ IconButton > :
203+ < IconButton className = { styles . iconButton } icon = { < Icon data = { Check } /> } tooltip = { `Accept ${ selectedOrVisible } screenshots` } view = { 'flat' } onClick = { handleAccept } disabled = { areActionsDisabled || ! isAtLeastOneAcceptable } > </ IconButton >
204+ ) }
205+ { ( isRunTestsAvailable || isEditScreensAvailable ) && < div className = { styles . buttonsDivider } > </ div > }
206+ < IconButton
207+ icon = { < Icon data = { treeViewMode === TreeViewMode . Tree ? ListUl : Hierarchy } height = { 14 } /> }
208+ tooltip = { treeViewMode === TreeViewMode . Tree ? 'Switch to list view' : 'Switch to tree view' }
209+ view = { 'flat' }
210+ onClick = { handleToggleTreeView }
211+ disabled = { ! isInitialized } />
212+ < IconButton icon = { < Icon data = { SquareDashed } height = { 14 } /> } tooltip = { 'Focus on active test' } view = { 'flat' } onClick = { onHighlightCurrentTest } disabled = { ! isFocusAvailable } />
213+ < IconButton icon = { < Icon data = { ChevronsExpandVertical } height = { 14 } /> } tooltip = { 'Expand all' } view = { 'flat' } onClick = { handleExpandAll } disabled = { ! isInitialized } />
214+ < IconButton icon = { < Icon data = { ChevronsCollapseVertical } height = { 14 } /> } tooltip = { 'Collapse all' } view = { 'flat' } onClick = { handleCollapseAll } disabled = { ! isInitialized } />
215+ { areCheckboxesNeeded && < IconButton
216+ icon = { < Icon data = { isIndeterminate ? SquareMinus : ( isSelectedAll ? SquareCheck : Square ) } /> }
217+ tooltip = { isSelectedAtLeastOne ? 'Deselect all' : 'Select all' }
218+ view = { 'flat' }
219+ onClick = { handleToggleAll }
220+ disabled = { ! isInitialized }
221+ className = { styles . selectAllButton }
222+ qa = "select-all-button"
223+ /> }
224+ </ >
225+ ) ;
209226
210227 return < div className = { classNames ( styles . container , className ) } >
211228 { /* This one is needed for paddings to work correctly for absolutely positioned selectedContainer */ }
212229 < div className = { styles . innerContainer } >
213230 < GroupBySelect />
214231 < SortBySelect />
215232 < div className = { styles . buttonsContainer } >
216- { viewButtons }
233+ { getViewButtons ( ) }
217234 </ div >
218235
219236 < div
@@ -224,7 +241,7 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
224241 </ div >
225242
226243 < div className = { styles . buttonsContainer } >
227- { viewButtons }
244+ { getViewButtons ( ) }
228245 </ div >
229246 </ div >
230247 </ div >
0 commit comments