mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
hub/sagas: fix error message not shown when starting repl
- Add check for repl start command success/fail. - Show error message on fail. - Rename start repl action. - Add new did start/did fail to start repl actions. - Change terminal saga to use did start repl action to focus terminal. - Add more tests.
This commit is contained in:
committed by
David Lechner
parent
70020275a7
commit
be3afa167a
@@ -4,7 +4,7 @@
|
||||
import { act, cleanup } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { testRender } from '../../../../test';
|
||||
import { repl } from '../../../hub/actions';
|
||||
import { hubStartRepl } from '../../../hub/actions';
|
||||
import { HubRuntimeState } from '../../../hub/reducers';
|
||||
import ReplButton from './ReplButton';
|
||||
|
||||
@@ -19,5 +19,5 @@ it('should dispatch action when clicked', async () => {
|
||||
|
||||
await act(() => user.click(button.getByRole('button', { name: 'REPL' })));
|
||||
|
||||
expect(dispatch).toHaveBeenCalledWith(repl(false));
|
||||
expect(dispatch).toHaveBeenCalledWith(hubStartRepl(false));
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020-2022 The Pybricks Authors
|
||||
// Copyright (c) 2020-2023 The Pybricks Authors
|
||||
|
||||
import React, { useCallback } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { repl } from '../../../hub/actions';
|
||||
import { hubStartRepl } from '../../../hub/actions';
|
||||
import { HubRuntimeState } from '../../../hub/reducers';
|
||||
import { useSelector } from '../../../reducers';
|
||||
import ActionButton, { ActionButtonProps } from '../../ActionButton';
|
||||
@@ -18,7 +18,7 @@ const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const action = useCallback(
|
||||
() => dispatch(repl(useLegacyDownload)),
|
||||
() => dispatch(hubStartRepl(useLegacyDownload)),
|
||||
[dispatch, useLegacyDownload],
|
||||
);
|
||||
|
||||
@@ -29,6 +29,7 @@ const ReplButton: React.VoidFunctionComponent<ReplButtonProps> = ({ id }) => {
|
||||
tooltip={i18n.translate('tooltip')}
|
||||
icon={icon}
|
||||
enabled={hasRepl && runtime === HubRuntimeState.Idle}
|
||||
showProgress={runtime === HubRuntimeState.StartingRepl}
|
||||
onAction={action}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user