1- import { Hotkey , Icon , Popover , Spin } from '@gravity-ui/uikit' ;
1+ import { Hotkey , Icon , Popover } from '@gravity-ui/uikit' ;
22import classNames from 'classnames' ;
33import {
44 ArrowUturnCcwLeft ,
@@ -13,7 +13,8 @@ import {
1313 SquareMinus ,
1414 ListUl ,
1515 Hierarchy ,
16- GearPlay
16+ GearPlay ,
17+ ArrowsRotateRight
1718} from '@gravity-ui/icons' ;
1819import React , { ReactNode , useCallback , useMemo } from 'react' ;
1920import { useDispatch , useSelector } from 'react-redux' ;
@@ -22,9 +23,9 @@ import styles from './index.module.css';
2223import {
2324 deselectAll ,
2425 selectAll ,
25- setAllTreeNodesState , setTreeViewMode ,
26+ setAllTreeNodesState , setRefreshLoading , setTreeViewMode ,
2627 staticAccepterStageScreenshot ,
27- staticAccepterUnstageScreenshot , thunkRunTests
28+ staticAccepterUnstageScreenshot , thunkInitGuiReport , thunkRunTests
2829} from '@/static/modules/actions' ;
2930import { ImageEntity , TreeViewMode } from '@/static/new-ui/types/store' ;
3031import { CHECKED , INDETERMINATE } from '@/constants/checked-statuses' ;
@@ -74,6 +75,7 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
7475 const selectedTests = useSelector ( getCheckedTests ) ;
7576 const visibleBrowserIds : string [ ] = useSelector ( getVisibleBrowserIds ) ;
7677 const isInitialized = useSelector ( getIsInitialized ) ;
78+ const isRefreshLoading = useSelector ( ( state ) => state . app . isRefreshLoading ) ;
7779
7880 const isRunTestsAvailable = useSelector ( state => state . app . availableFeatures )
7981 . find ( feature => feature . name === RunTestsFeature . name ) ;
@@ -139,6 +141,12 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
139141 const selectedOrVisible = isSelectedAtLeastOne ? 'selected' : 'visible' ;
140142 const areActionsDisabled = isRunning || ! isInitialized ;
141143
144+ const handleRefresh = useCallback ( async ( ) => {
145+ dispatch ( setRefreshLoading ( true ) ) ;
146+ await fetch ( '/refresh' , { method : 'POST' } ) ;
147+ dispatch ( thunkInitGuiReport ( { isNewUi : true } ) ) ;
148+ } , [ ] ) ;
149+
142150 const handleRun = useCallback ( ( ) : void => {
143151 analytics ?. trackFeatureUsage ( { featureName : `${ ANALYTICS_PREFIX } run tests` } ) ;
144152 if ( isSelectedAtLeastOne ) {
@@ -195,19 +203,24 @@ export function TreeActionsToolbar({onHighlightCurrentTest, className}: TreeActi
195203 const getViewButtons = ( ) : ReactNode => (
196204 < >
197205 { isRunTestsAvailable && (
198- isRunning
199- ? (
200- < Spin size = { 'xs' } style = { { marginRight : '6px' } } />
201- ) : (
202- < IconButton
203- className = { styles . iconButton }
204- icon = { < Icon data = { Play } height = { 14 } /> }
205- tooltip = { < > Run { selectedOrVisible } ⋅ < Hotkey value = "shift+r" view = "light" /> </ > }
206- view = { 'flat' }
207- onClick = { handleRun }
208- disabled = { isRunning || ! isInitialized }
209- />
210- )
206+ < IconButton
207+ className = { styles . iconButton }
208+ icon = { < Icon className = { classNames ( { [ styles . isRefreshLoading ] : isRefreshLoading } ) } data = { ArrowsRotateRight } height = { 14 } /> }
209+ tooltip = "Refresh tests tree"
210+ view = "flat"
211+ onClick = { handleRefresh }
212+ disabled = { isRunning || ! isInitialized || isRefreshLoading }
213+ />
214+ ) }
215+ { isRunTestsAvailable && (
216+ < IconButton
217+ className = { styles . iconButton }
218+ icon = { < Icon className = { classNames ( { [ styles . isRunning ] : isRunning } ) } data = { Play } height = { 14 } /> }
219+ tooltip = { < > Run { selectedOrVisible } ⋅ < Hotkey value = "shift+r" view = "light" /> </ > }
220+ view = { 'flat' }
221+ onClick = { handleRun }
222+ disabled = { isRunning || ! isInitialized }
223+ />
211224 ) }
212225 { isRunTestsAvailable && hasRunTestOptions && < Popover
213226 content = { < div className = { styles . runOptionsContainer } > < ExtensionPoint name = { ExtensionPointName . RunTestOptions } > </ ExtensionPoint > </ div > }
0 commit comments