Skip to content

Commit b736e81

Browse files
authored
fix: run button does not cause any visual reaction when pressed
1 parent bae8472 commit b736e81

File tree

2 files changed

+51
-33
lines changed

2 files changed

+51
-33
lines changed

lib/static/new-ui/components/TreeActionsToolbar/index.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
}
2121

2222
.selected-container {
23+
--g-color-line-brand: white;
2324
--g-button-text-color: white;
2425
--g-button-text-color-hover: white;
2526
--g-button-background-color-hover: rgba(255, 255, 255, 0.1);

lib/static/new-ui/components/TreeActionsToolbar/index.tsx

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Icon} from '@gravity-ui/uikit';
1+
import {Icon, Spin} from '@gravity-ui/uikit';
22
import classNames from 'classnames';
33
import {
44
ArrowUturnCcwLeft,
@@ -28,6 +28,7 @@ import {
2828
import {ImageEntity, TreeViewMode} from '@/static/new-ui/types/store';
2929
import {CHECKED, INDETERMINATE} from '@/constants/checked-statuses';
3030
import {IconButton} from '@/static/new-ui/components/IconButton';
31+
import {TestStatus} from '@/constants';
3132
import {
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

Comments
 (0)