Skip to content

Commit 2075279

Browse files
feat: add disabled and hover tooltip to "Run" button when user has not selected a measurement (#5496)
1 parent d8e36d1 commit 2075279

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/dataExplorer/components/ResultsPane.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ const ResultsPane: FC = () => {
8888
setQuery,
8989
range,
9090
setRange,
91+
selection,
9192
} = useContext(PersistanceContext)
9293

94+
const submitButtonDisabled = !text || !selection.measurement
95+
96+
const disabledTitleText = submitButtonDisabled
97+
? 'Select measurement before running script'
98+
: ''
99+
93100
const download = () => {
94101
event('CSV Download Initiated')
95102
basic(text, {
@@ -197,7 +204,8 @@ const ResultsPane: FC = () => {
197204
className="submit-btn"
198205
text="Run"
199206
icon={IconFont.Play}
200-
submitButtonDisabled={!text}
207+
submitButtonDisabled={submitButtonDisabled}
208+
disabledTitleText={disabledTitleText}
201209
queryStatus={status}
202210
onSubmit={submit}
203211
onNotify={fakeNotify}

src/timeMachine/components/SubmitQueryButton.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface OwnProps {
3535
icon?: IconFont
3636
testID?: string
3737
className?: string
38+
disabledTitleText?: string // Text to be displayed on hover tooltip when the button is disabled
3839
}
3940

4041
type ReduxProps = ConnectedProps<typeof connector>
@@ -86,7 +87,15 @@ class SubmitQueryButton extends PureComponent<Props> {
8687
}
8788

8889
public render() {
89-
const {color, text, queryStatus, icon, testID, className} = this.props
90+
const {
91+
color,
92+
text,
93+
queryStatus,
94+
icon,
95+
testID,
96+
className,
97+
disabledTitleText,
98+
} = this.props
9099
if (queryStatus === RemoteDataState.Loading && this.state.timer) {
91100
return (
92101
<Button
@@ -112,6 +121,7 @@ class SubmitQueryButton extends PureComponent<Props> {
112121
color={color ?? ComponentColor.Primary}
113122
testID={testID}
114123
style={{minWidth: '100px'}}
124+
disabledTitleText={disabledTitleText}
115125
/>
116126
)
117127
}

0 commit comments

Comments
 (0)