ReplButton: disable when hub doesn't support it

Fixes: https://github.com/pybricks/support/issues/743
This commit is contained in:
David Lechner
2022-10-21 16:26:43 -05:00
parent 964c18f12e
commit 397ea60354
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ afterEach(() => {
it('should dispatch action when clicked', async () => {
const [user, button, dispatch] = testRender(<ReplButton id="test-repl-button" />, {
hub: { runtime: HubRuntimeState.Idle },
hub: { hasRepl: true, runtime: HubRuntimeState.Idle },
});
await user.click(button.getByRole('button', { name: 'REPL' }));
+2 -2
View File
@@ -13,7 +13,7 @@ import icon from './icon.svg';
type ReplButtonProps = Pick<ActionButtonProps, 'id'>;
const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
const { runtime, useLegacyDownload } = useSelector((s) => s.hub);
const { runtime, useLegacyDownload, hasRepl } = useSelector((s) => s.hub);
const i18n = useI18n();
const dispatch = useDispatch();
@@ -28,7 +28,7 @@ const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
label={i18n.translate('label')}
tooltip={i18n.translate('tooltip')}
icon={icon}
enabled={runtime === HubRuntimeState.Idle}
enabled={hasRepl && runtime === HubRuntimeState.Idle}
onAction={action}
/>
);