Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCD-660: Disable write button on click, enable on write finished #29

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

import React from 'react';
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import {
Button,
Expand All @@ -21,22 +21,32 @@ import { getConfigArray } from './features/Configuration/boardControllerConfigSl
export default () => {
logger.debug('Rendering SidePanel');

const [isWriting, setWriting] = useState(false);

const device = useSelector(selectedDevice);
const configData = useSelector(getConfigArray);

return (
<SidePanel className="side-panel">
<CollapsibleGroup defaultCollapsed={false} heading="Actions">
<Button
disabled={!device}
disabled={!device || isWriting}
variant="primary"
className="tw-w-full"
onClick={() => {
onClick={async event => {
const button = event.currentTarget;
// Set isWriting flag for user ui feedback
setWriting(true);
if (!device) {
return;
}
NrfutilDeviceLib.boardController(device, configData);
await NrfutilDeviceLib.boardController(
device,
configData
);
logger.info('Configuration written');
// Clear isWriting flag for user ui feedback
setWriting(false);
}}
>
Write config
Expand Down