Skip to content

Commit 6f885be

Browse files
authored
Disable exp push when experiment is running in the workspace (#4343)
1 parent 623af67 commit 6f885be

File tree

4 files changed

+70
-15
lines changed

4 files changed

+70
-15
lines changed

webview/src/experiments/components/App.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,4 +1956,28 @@ describe('App', () => {
19561956
})
19571957
})
19581958
})
1959+
1960+
describe('Experiment git remote status indicator', () => {
1961+
it('should not allow pushing an experiment when an experiment is running in the workspace', () => {
1962+
renderTable()
1963+
1964+
fireEvent.click(screen.getByTestId('exp-f13bca-push-experiment'))
1965+
1966+
expect(mockPostMessage).not.toHaveBeenCalledWith({
1967+
payload: ['exp-f13bca'],
1968+
type: MessageFromWebviewType.PUSH_EXPERIMENT
1969+
})
1970+
})
1971+
1972+
it('should allow pushing an experiment when an experiment is not running in the workspace', () => {
1973+
renderTableWithoutRunningExperiments()
1974+
1975+
fireEvent.click(screen.getByTestId('exp-f13bca-push-experiment'))
1976+
1977+
expect(mockPostMessage).toHaveBeenCalledWith({
1978+
payload: ['exp-f13bca'],
1979+
type: MessageFromWebviewType.PUSH_EXPERIMENT
1980+
})
1981+
})
1982+
})
19591983
})

webview/src/experiments/components/table/body/Cell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const RowExpansionButton: React.FC<RowProp> = ({ row }) =>
3535
/>
3636
</button>
3737
) : (
38-
<span className={styles.rowArrowContainer} />
38+
<span className={styles.emptyRowArrowContainer} />
3939
)
4040

4141
export const StubCell: React.FC<

webview/src/experiments/components/table/body/ExperimentStatusIndicator.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import { VSCodeProgressRing } from '@vscode/webview-ui-toolkit/react'
33
import cx from 'classnames'
4+
import { useSelector } from 'react-redux'
45
import {
56
ExperimentStatus,
67
GitRemoteStatus,
@@ -12,6 +13,7 @@ import { clickAndEnterProps } from '../../../../util/props'
1213
import { pushExperiment } from '../../../util/messages'
1314
import { Cloud, CloudUpload } from '../../../../shared/components/icons'
1415
import { Icon } from '../../../../shared/components/Icon'
16+
import { ExperimentsState } from '../../../store'
1517

1618
type ExperimentStatusIndicatorProps = {
1719
status: ExperimentStatus | undefined
@@ -22,22 +24,35 @@ type ExperimentStatusIndicatorProps = {
2224
export const ExperimentStatusIndicator: React.FC<
2325
ExperimentStatusIndicatorProps
2426
> = ({ id, status, gitRemoteStatus }) => {
27+
const { hasRunningWorkspaceExperiment } = useSelector(
28+
(state: ExperimentsState) => state.tableData
29+
)
30+
2531
if (isRunning(status) || gitRemoteStatus === GitRemoteStatus.PUSHING) {
2632
return (
2733
<VSCodeProgressRing className={cx(styles.running, 'chromatic-ignore')} />
2834
)
2935
}
3036

3137
if (gitRemoteStatus === GitRemoteStatus.NOT_ON_REMOTE) {
38+
const tooltipContent =
39+
'Experiment not found on remote' +
40+
(hasRunningWorkspaceExperiment ? '' : '\nClick to push')
41+
3242
return (
33-
<CellHintTooltip
34-
tooltipContent={'Experiment not found on remote\nClick to push'}
35-
>
43+
<CellHintTooltip tooltipContent={tooltipContent}>
3644
<div
3745
className={styles.upload}
38-
{...clickAndEnterProps(() => pushExperiment(id))}
46+
{...clickAndEnterProps(
47+
() => !hasRunningWorkspaceExperiment && pushExperiment(id)
48+
)}
3949
>
40-
<Icon className={styles.cloudBox} icon={CloudUpload} />
50+
<Icon
51+
data-testid={`${id}-push-experiment`}
52+
aria-disabled={false}
53+
className={styles.cloudBox}
54+
icon={CloudUpload}
55+
/>
4156
</div>
4257
</CellHintTooltip>
4358
)

webview/src/experiments/components/table/styles.module.scss

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ $badge-size: 0.85rem;
3030
margin: 12px 6px;
3131
}
3232

33+
%rowArrowContainer {
34+
width: 20px;
35+
height: 32px;
36+
padding: 0;
37+
flex: 0 0 20px;
38+
right: 6px;
39+
display: inline-block;
40+
position: relative;
41+
border: none;
42+
background: none;
43+
}
44+
3345
%truncateLeftParent {
3446
overflow: hidden;
3547
text-overflow: ellipsis;
@@ -657,6 +669,11 @@ $badge-size: 0.85rem;
657669
@extend %iconBox;
658670

659671
padding: 1px;
672+
673+
&[aria-disabled='true'] {
674+
cursor: default;
675+
opacity: 0.4;
676+
}
660677
}
661678

662679
.cloudIndicator {
@@ -690,18 +707,17 @@ $badge-size: 0.85rem;
690707
}
691708

692709
.rowArrowContainer {
693-
width: 20px;
694-
height: 32px;
695-
padding: 0;
696-
flex: 0 0 20px;
697-
right: 6px;
698-
display: inline-block;
699-
position: relative;
700-
border: none;
701-
background: none;
710+
@extend %rowArrowContainer;
711+
702712
cursor: pointer;
703713
}
704714

715+
.emptyRowArrowContainer {
716+
@extend %rowArrowContainer;
717+
718+
cursor: default;
719+
}
720+
705721
.expandedRowArrow {
706722
@extend %expandableRowArrow;
707723

0 commit comments

Comments
 (0)