From 2ff9dfe6d6886d9358594b5c44c7d62d75a62cec Mon Sep 17 00:00:00 2001 From: Kyle Micallef Bonnici Date: Fri, 23 Feb 2024 15:23:32 +0100 Subject: [PATCH] feat: update shared --- package-lock.json | 8 +- package.json | 2 +- src/appReducer.ts | 2 - src/components/Cards/Buck/BuckCard.tsx | 8 +- src/components/Cards/LDO/LDOCard.tsx | 5 +- src/components/Cards/Power/PowerCard.tsx | 8 +- src/components/Charger/Jeita.tsx | 5 +- .../Profiling/Dialog/ConfigurationDialog.tsx | 17 ++-- .../Profiling/Dialog/ProfilingWizard.tsx | 22 +++-- .../AddEditProfileDialog.tsx | 5 +- .../AddEditProjectDialog.tsx | 11 ++- .../useProfilingProjects.tsx | 4 +- src/components/SidePanel/SidePanel.tsx | 5 +- .../SystemFeatures/PowerFailure.tsx | 5 +- src/components/SystemFeatures/Timer.tsx | 5 +- src/components/SystemFeatures/VBus.tsx | 5 +- .../confirmBeforeClose/ConfirmCloseDialog.tsx | 87 ------------------- .../confirmBeforeCloseSlice.ts | 72 --------------- src/index.tsx | 2 - 19 files changed, 66 insertions(+), 212 deletions(-) delete mode 100644 src/features/confirmBeforeClose/ConfirmCloseDialog.tsx delete mode 100644 src/features/confirmBeforeClose/confirmBeforeCloseSlice.ts diff --git a/package-lock.json b/package-lock.json index 6800e725..4c4ef6ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.2.0", "license": "SEE LICENSE IN LICENSE", "devDependencies": { - "@nordicsemiconductor/pc-nrfconnect-shared": "^157.0.0", + "@nordicsemiconductor/pc-nrfconnect-shared": "^160.0.0", "chart.js": "^4.0.1", "chartjs-adapter-date-fns": "^2.0.1", "react-chartjs-2": "^5.0.1", @@ -2878,9 +2878,9 @@ } }, "node_modules/@nordicsemiconductor/pc-nrfconnect-shared": { - "version": "157.0.0", - "resolved": "https://registry.npmjs.org/@nordicsemiconductor/pc-nrfconnect-shared/-/pc-nrfconnect-shared-157.0.0.tgz", - "integrity": "sha512-+/xiejw5JAx9IAMupMKRoZ2hr8vgOfG7J6Dsz/145o9+y54wNbOcfWA2vEvZA7YebCYaskYS9FRFadcAzn1umA==", + "version": "160.0.0", + "resolved": "https://registry.npmjs.org/@nordicsemiconductor/pc-nrfconnect-shared/-/pc-nrfconnect-shared-160.0.0.tgz", + "integrity": "sha512-6dwJvK9nc42X20BvVMWAnfwRmwX+1BeS5C1XvHvx/0LeeKLqy7jXBf7ulNf9ny9XLpJ8Lgs3uBI7muZiAzggfg==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 3385d2dc..fbb66d93 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "prepare": "husky install" }, "devDependencies": { - "@nordicsemiconductor/pc-nrfconnect-shared": "^157.0.0", + "@nordicsemiconductor/pc-nrfconnect-shared": "^160.0.0", "chart.js": "^4.0.1", "chartjs-adapter-date-fns": "^2.0.1", "react-chartjs-2": "^5.0.1", diff --git a/src/appReducer.ts b/src/appReducer.ts index 0c0512d3..575c98a5 100644 --- a/src/appReducer.ts +++ b/src/appReducer.ts @@ -7,7 +7,6 @@ import { NrfConnectState } from '@nordicsemiconductor/pc-nrfconnect-shared'; import { combineReducers } from 'redux'; -import confirmBeforeCloseReducer from './features/confirmBeforeClose/confirmBeforeCloseSlice'; import downloadBatteryModelSlice from './features/pmicControl/downloadBatteryModelSlice'; import pmicControlReducer from './features/pmicControl/pmicControlSlice'; import profilingProjectsReducer from './features/pmicControl/profilingProjectsSlice.'; @@ -20,7 +19,6 @@ type AppState = ReturnType; export interface RootState extends NrfConnectState {} const appReducer = combineReducers({ - confirmBeforeClose: confirmBeforeCloseReducer, profilingProjects: profilingProjectsReducer, profiling: profilingReducer, pmicControl: pmicControlReducer, diff --git a/src/components/Cards/Buck/BuckCard.tsx b/src/components/Cards/Buck/BuckCard.tsx index 77290368..55f0a1bd 100644 --- a/src/components/Cards/Buck/BuckCard.tsx +++ b/src/components/Cards/Buck/BuckCard.tsx @@ -9,7 +9,7 @@ import { Card, classNames, Dropdown, - NumberInputSliderWithUnit, + NumberInput, StateSelector, Toggle, } from '@nordicsemiconductor/pc-nrfconnect-shared'; @@ -160,7 +160,7 @@ export default ({ disabled={disabled} /> -
@@ -177,10 +177,11 @@ export default ({ value={internalVOut} onChange={setInternalVOut} onChangeComplete={onVOutChange} + showSlider /> {!summary && ( <> -
@@ -197,6 +198,7 @@ export default ({ value={internalRetVOut} onChange={setInternalRetVOut} onChangeComplete={onRetVOutChange} + showSlider /> -
@@ -135,6 +135,7 @@ export default ({ onChangeComplete={value => npmDevice.setLdoVoltage(index, value) } + showSlider /> {!summary && ( diff --git a/src/components/Cards/Power/PowerCard.tsx b/src/components/Cards/Power/PowerCard.tsx index 3df7dbad..134af502 100644 --- a/src/components/Cards/Power/PowerCard.tsx +++ b/src/components/Cards/Power/PowerCard.tsx @@ -9,7 +9,7 @@ import { Card, classNames, Dropdown, - NumberInputSliderWithUnit, + NumberInput, Toggle, } from '@nordicsemiconductor/pc-nrfconnect-shared'; @@ -94,7 +94,7 @@ export default ({
} > -
@@ -109,8 +109,9 @@ export default ({ value={internalVTerm} onChange={setInternalVTerm} onChangeComplete={v => npmDevice.setChargerVTerm(v)} + showSlider /> -
@@ -125,6 +126,7 @@ export default ({ value={internalIChg} onChange={setInternalIChg} onChangeComplete={v => npmDevice.setChargerIChg(v)} + showSlider /> {!summary && ( diff --git a/src/components/Charger/Jeita.tsx b/src/components/Charger/Jeita.tsx index e6460ea2..89bda870 100644 --- a/src/components/Charger/Jeita.tsx +++ b/src/components/Charger/Jeita.tsx @@ -11,7 +11,7 @@ import { classNames, Dropdown, NumberInlineInput, - NumberInputSliderWithUnit, + NumberInput, Slider, Toggle, } from '@nordicsemiconductor/pc-nrfconnect-shared'; @@ -281,7 +281,7 @@ export default ({ {npmDevice.getChargerJeitaRange().max}°C
-
@@ -296,6 +296,7 @@ export default ({ onChange={value => setInternalVTermr(value)} onChangeComplete={npmDevice.setChargerVTermR} disabled={disabled} + showSlider /> { value={name} />
-
@@ -206,7 +207,8 @@ export default ({ isVisible }: { isVisible: boolean }) => { onChange={setUpperVCutOff} /> -
@@ -225,7 +227,8 @@ export default ({ isVisible }: { isVisible: boolean }) => { onChange={setLowerVCutOff} /> -
@@ -244,7 +247,8 @@ export default ({ isVisible }: { isVisible: boolean }) => { }} /> -
@@ -289,7 +293,8 @@ export default ({ isVisible }: { isVisible: boolean }) => { {temperatures.map((temp, index) => (
- { const index = useSelector(getProfileIndex); const ccProfilingState = useSelector(getCcProfilingState); const abortAction = useSelector(getAbort); - const showCloseAppDialog = useSelector(getShowConfirmCloseDialog); + const confirmCloseDialogOpen = useSelector(isConfirmCloseDialogOpen); const pmicState = useSelector(getPmicState); const [initializing, setInitializing] = useState(false); @@ -376,32 +374,32 @@ export default () => { )} {profilingStage === 'Configuration' && ( )} {profilingStage === 'Checklist' && ( )} {profilingStage === 'Charging' && ( )} {profilingStage === 'Resting' && ( )} {profilingStage === 'Profiling' && ( )} {profilingStage === 'Complete' && ( )}
diff --git a/src/components/Profiling/ProfilingProjects/AddEditProfileDialog.tsx b/src/components/Profiling/ProfilingProjects/AddEditProfileDialog.tsx index cf68c089..dfdde46e 100644 --- a/src/components/Profiling/ProfilingProjects/AddEditProfileDialog.tsx +++ b/src/components/Profiling/ProfilingProjects/AddEditProfileDialog.tsx @@ -11,7 +11,7 @@ import { DialogButton, GenericDialog, Group, - NumberInputSliderWithUnit, + NumberInput, } from '@nordicsemiconductor/pc-nrfconnect-shared'; import path from 'path'; @@ -102,7 +102,7 @@ export default ({ >
- Temperature @@ -115,6 +115,7 @@ export default ({ max: 85, }} onChange={value => setTemperature(value)} + showSlider />
diff --git a/src/components/Profiling/ProfilingProjects/AddEditProjectDialog.tsx b/src/components/Profiling/ProfilingProjects/AddEditProjectDialog.tsx index 8fc0f4a2..30bd7058 100644 --- a/src/components/Profiling/ProfilingProjects/AddEditProjectDialog.tsx +++ b/src/components/Profiling/ProfilingProjects/AddEditProjectDialog.tsx @@ -11,7 +11,7 @@ import { DialogButton, GenericDialog, Group, - NumberInputSliderWithUnit, + NumberInput, } from '@nordicsemiconductor/pc-nrfconnect-shared'; import { showSaveDialog } from '../../../actions/fileActions'; @@ -131,7 +131,8 @@ export default ({ value={name} />
- Capacity @@ -142,7 +143,8 @@ export default ({ range={{ min: 32, max: 3000 }} onChange={setCapacity} /> - V @@ -159,7 +161,8 @@ export default ({ }} onChange={setUpperVCutOff} /> -
diff --git a/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx b/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx index 00fc7cdf..901a35e7 100644 --- a/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx +++ b/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx @@ -6,11 +6,11 @@ import React, { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; - import { addConfirmBeforeClose, clearConfirmBeforeClose, -} from '../../../features/confirmBeforeClose/confirmBeforeCloseSlice'; +} from '@nordicsemiconductor/pc-nrfconnect-shared'; + import { getProjectProfileProgress, getRecentProjects, diff --git a/src/components/SidePanel/SidePanel.tsx b/src/components/SidePanel/SidePanel.tsx index 5533d9fc..ee15da65 100644 --- a/src/components/SidePanel/SidePanel.tsx +++ b/src/components/SidePanel/SidePanel.tsx @@ -9,7 +9,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { Button, CollapsibleGroup, - NumberInputSliderWithUnit, + NumberInput, SidePanel, StartStopButton, } from '@nordicsemiconductor/pc-nrfconnect-shared'; @@ -136,7 +136,8 @@ export default () => { /> - {
} > - <> diff --git a/src/components/SystemFeatures/Timer.tsx b/src/components/SystemFeatures/Timer.tsx index 8733d1e5..054c5fc1 100644 --- a/src/components/SystemFeatures/Timer.tsx +++ b/src/components/SystemFeatures/Timer.tsx @@ -8,7 +8,7 @@ import React, { useEffect, useMemo, useState } from 'react'; import { Card, Dropdown, - NumberInputSliderWithUnit, + NumberInput, } from '@nordicsemiconductor/pc-nrfconnect-shared'; import { DocumentationTooltip } from '../../features/pmicControl/npm/documentation/documentation'; @@ -134,7 +134,7 @@ export default ({ npmDevice, timerConfig, disabled }: GPIOProperties) => { } disabled={disabled} /> - Timer Period @@ -155,6 +155,7 @@ export default ({ npmDevice, timerConfig, disabled }: GPIOProperties) => { onChangeComplete={v => npmDevice.setTimerConfigCompare(v / prescalerMultiplier) } + showSlider /> ); diff --git a/src/components/SystemFeatures/VBus.tsx b/src/components/SystemFeatures/VBus.tsx index e54a8d01..617bcfca 100644 --- a/src/components/SystemFeatures/VBus.tsx +++ b/src/components/SystemFeatures/VBus.tsx @@ -8,7 +8,7 @@ import React, { useEffect, useState } from 'react'; import { Card, classNames, - NumberInputSliderWithUnit, + NumberInput, } from '@nordicsemiconductor/pc-nrfconnect-shared'; import { DocumentationTooltip } from '../../features/pmicControl/npm/documentation/documentation'; @@ -63,7 +63,8 @@ export default ({ npmDevice, usbPower, disabled }: VBusProperties) => {
- Current Limiter diff --git a/src/features/confirmBeforeClose/ConfirmCloseDialog.tsx b/src/features/confirmBeforeClose/ConfirmCloseDialog.tsx deleted file mode 100644 index 3b558c1c..00000000 --- a/src/features/confirmBeforeClose/ConfirmCloseDialog.tsx +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause - */ - -import React, { useEffect, useState } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; -import { getCurrentWindow } from '@electron/remote'; -import { - AppThunk, - ConfirmationDialog, -} from '@nordicsemiconductor/pc-nrfconnect-shared'; - -import { - addConfirmBeforeClose, - clearConfirmBeforeClose, - ConfirmBeforeCloseApp, - getNextConfirmDialog, - getShowConfirmCloseDialog, - setShowCloseDialog, -} from './confirmBeforeCloseSlice'; - -export default () => { - const dispatch = useDispatch(); - const [confirmedDialogs, setConfirmedDialogs] = useState< - ConfirmBeforeCloseApp[] - >([]); - - const showCloseDialog = useSelector(getShowConfirmCloseDialog); - const nextConfirmDialog = useSelector(getNextConfirmDialog); - - useEffect(() => { - if (!nextConfirmDialog && showCloseDialog) { - confirmedDialogs.forEach(confirmedDialog => { - if (confirmedDialog.onClose) confirmedDialog.onClose(); - }); - setConfirmedDialogs([]); - getCurrentWindow().close(); - } - }, [nextConfirmDialog, dispatch, showCloseDialog, confirmedDialogs]); - - useEffect(() => { - const action = (ev: BeforeUnloadEvent) => - dispatch((_, getState) => { - const hasToGetExplicitConform = - getState().app.confirmBeforeClose.confirmCloseApp.length > - 0; - if (hasToGetExplicitConform) { - dispatch(setShowCloseDialog(true)); - ev.returnValue = true; - } - }); - - window.addEventListener('beforeunload', action, true); - - return () => { - window.removeEventListener('beforeunload', action); - }; - }, [dispatch]); - - return ( - { - if (nextConfirmDialog) { - setConfirmedDialogs([ - ...confirmedDialogs, - nextConfirmDialog, - ]); - dispatch(clearConfirmBeforeClose(nextConfirmDialog.id)); - } - }} - onCancel={() => { - dispatch(setShowCloseDialog(false)); - confirmedDialogs.forEach(confirmedDialog => - dispatch(addConfirmBeforeClose(confirmedDialog)) - ); - setConfirmedDialogs([]); - }} - > - {nextConfirmDialog?.message} - - ); -}; diff --git a/src/features/confirmBeforeClose/confirmBeforeCloseSlice.ts b/src/features/confirmBeforeClose/confirmBeforeCloseSlice.ts deleted file mode 100644 index 2b2b3577..00000000 --- a/src/features/confirmBeforeClose/confirmBeforeCloseSlice.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause - */ - -import { createSlice, PayloadAction } from '@reduxjs/toolkit'; - -import type { RootState } from '../../appReducer'; - -export interface ConfirmBeforeCloseApp { - id: string; - message: React.ReactNode; - onClose?: () => void; -} - -interface confirmBeforeCloseState { - confirmCloseApp: ConfirmBeforeCloseApp[]; - showCloseDialog: boolean; -} - -const initialState: confirmBeforeCloseState = { - confirmCloseApp: [], - showCloseDialog: false, -}; - -const confirmBeforeCloseSlice = createSlice({ - name: 'confirmBeforeCloseControl', - initialState, - reducers: { - addConfirmBeforeClose( - state, - action: PayloadAction - ) { - const index = state.confirmCloseApp.findIndex( - confirmCloseApp => confirmCloseApp.id === action.payload.id - ); - - if (index !== -1) { - state.confirmCloseApp[index] = action.payload; - } else { - state.confirmCloseApp = [ - action.payload, - ...state.confirmCloseApp, - ]; - } - }, - clearConfirmBeforeClose(state, action: PayloadAction) { - state.confirmCloseApp = state.confirmCloseApp.filter( - confirmCloseApp => confirmCloseApp.id !== action.payload - ); - }, - setShowCloseDialog(state, action: PayloadAction) { - state.showCloseDialog = action.payload; - }, - }, -}); - -export const getNextConfirmDialog = (state: RootState) => - state.app.confirmBeforeClose.confirmCloseApp.length > 0 - ? state.app.confirmBeforeClose.confirmCloseApp[0] - : undefined; - -export const getShowConfirmCloseDialog = (state: RootState) => - state.app.confirmBeforeClose.showCloseDialog; - -export const { - addConfirmBeforeClose, - setShowCloseDialog, - clearConfirmBeforeClose, -} = confirmBeforeCloseSlice.actions; -export default confirmBeforeCloseSlice.reducer; diff --git a/src/index.tsx b/src/index.tsx index 38f3dc65..4bab687a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -23,7 +23,6 @@ import Profiles from './components/Profiling/ProfilingProjects/Profiles'; import Regulators from './components/Regulators/Regulators'; import SidePanel from './components/SidePanel/SidePanel'; import SystemFeatures from './components/SystemFeatures/SystemFeatures'; -import ConfirmCloseDialog from './features/confirmBeforeClose/ConfirmCloseDialog'; import NpmGenericDialog from './features/pmicControl/npm/NpmGenericDialog'; import './index.scss'; @@ -37,7 +36,6 @@ render( sidePanel={ <> -