mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
ReplButton: disable when hub doesn't support it
Fixes: https://github.com/pybricks/support/issues/743
This commit is contained in:
@@ -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' }));
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user