Skip to content

Commit 397ea60

Browse files
committed
ReplButton: disable when hub doesn't support it
Fixes: pybricks/support#743
1 parent 964c18f commit 397ea60

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/toolbar/buttons/repl/ReplButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ afterEach(() => {
1414

1515
it('should dispatch action when clicked', async () => {
1616
const [user, button, dispatch] = testRender(<ReplButton id="test-repl-button" />, {
17-
hub: { runtime: HubRuntimeState.Idle },
17+
hub: { hasRepl: true, runtime: HubRuntimeState.Idle },
1818
});
1919

2020
await user.click(button.getByRole('button', { name: 'REPL' }));

src/toolbar/buttons/repl/ReplButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import icon from './icon.svg';
1313
type ReplButtonProps = Pick<ActionButtonProps, 'id'>;
1414

1515
const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
16-
const { runtime, useLegacyDownload } = useSelector((s) => s.hub);
16+
const { runtime, useLegacyDownload, hasRepl } = useSelector((s) => s.hub);
1717
const i18n = useI18n();
1818
const dispatch = useDispatch();
1919

@@ -28,7 +28,7 @@ const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
2828
label={i18n.translate('label')}
2929
tooltip={i18n.translate('tooltip')}
3030
icon={icon}
31-
enabled={runtime === HubRuntimeState.Idle}
31+
enabled={hasRepl && runtime === HubRuntimeState.Idle}
3232
onAction={action}
3333
/>
3434
);

0 commit comments

Comments
 (0)