@nordicsemiconductor/pc-nrfconnect-shared 246.0.0 → 248.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env tsx
2
+ export declare const sameRepoURLs: (url1: string, url2: string) => boolean;
2
3
  declare const runChecks: ({ checkChangelogHasCurrentEntry, }: {
3
4
  checkChangelogHasCurrentEntry: boolean;
4
5
  }) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"check-app-properties.d.ts","sourceRoot":"","sources":["../../../scripts/check-app-properties.ts"],"names":[],"mappings":";AAkLA,QAAA,MAAM,SAAS,GAAI,oCAEhB;IACC,6BAA6B,EAAE,OAAO,CAAC;CAC1C,SAKA,CAAC;AAOF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"check-app-properties.d.ts","sourceRoot":"","sources":["../../../scripts/check-app-properties.ts"],"names":[],"mappings":";AAmEA,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,YAUtD,CAAC;AAuGF,QAAA,MAAM,SAAS,GAAI,oCAEhB;IACC,6BAA6B,EAAE,OAAO,CAAC;CAC1C,SAKA,CAAC;AAOF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=check-app-properties.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-app-properties.test.d.ts","sourceRoot":"","sources":["../../../scripts/check-app-properties.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmCloseDialog.d.ts","sourceRoot":"","sources":["../../../../src/ConfirmBeforeClose/ConfirmCloseDialog.tsx"],"names":[],"mappings":";AAqBA,wBAgEE"}
1
+ {"version":3,"file":"ConfirmCloseDialog.d.ts","sourceRoot":"","sources":["../../../../src/ConfirmBeforeClose/ConfirmCloseDialog.tsx"],"names":[],"mappings":";AAuBA,wBAiEE"}
@@ -7,12 +7,16 @@ export interface ConfirmBeforeCloseApp {
7
7
  onClose?: () => void;
8
8
  }
9
9
  export type ConfirmBeforeCloseOptionalTitle = Optional<ConfirmBeforeCloseApp, 'title'>;
10
+ type OnCompleteAction = 'close' | 'reload';
10
11
  export interface ConfirmBeforeCloseState {
11
12
  confirmCloseApp: ConfirmBeforeCloseApp[];
12
13
  showCloseDialog: boolean;
14
+ actionOnAllComplete: OnCompleteAction;
13
15
  }
14
- export declare const reducer: import("redux").Reducer<ConfirmBeforeCloseState>, addConfirmBeforeClose: import("@reduxjs/toolkit").ActionCreatorWithPayload<ConfirmBeforeCloseOptionalTitle, "confirmBeforeCloseDialog/addConfirmBeforeClose">, setShowCloseDialog: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "confirmBeforeCloseDialog/setShowCloseDialog">, clearConfirmBeforeClose: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "confirmBeforeCloseDialog/clearConfirmBeforeClose">;
16
+ export declare const reducer: import("redux").Reducer<ConfirmBeforeCloseState>, addConfirmBeforeClose: import("@reduxjs/toolkit").ActionCreatorWithPayload<ConfirmBeforeCloseOptionalTitle, "confirmBeforeCloseDialog/addConfirmBeforeClose">, setShowCloseDialog: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "confirmBeforeCloseDialog/setShowCloseDialog">, clearConfirmBeforeClose: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "confirmBeforeCloseDialog/clearConfirmBeforeClose">, setActionOnAllComplete: import("@reduxjs/toolkit").ActionCreatorWithPayload<OnCompleteAction, "confirmBeforeCloseDialog/setActionOnAllComplete">;
15
17
  export declare const getNextConfirmDialog: (state: RootState) => ConfirmBeforeCloseApp | undefined;
16
18
  export declare const getShowConfirmCloseDialog: (state: RootState) => boolean;
19
+ export declare const getActionOnComplete: (state: RootState) => OnCompleteAction;
17
20
  export declare const preventAppCloseUntilComplete: (dialogInfo: Omit<ConfirmBeforeCloseOptionalTitle, "id">, promise: Promise<unknown>, abortController?: AbortController) => AppThunk;
21
+ export {};
18
22
  //# sourceMappingURL=confirmBeforeCloseSlice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"confirmBeforeCloseSlice.d.ts","sourceRoot":"","sources":["../../../../src/ConfirmBeforeClose/confirmBeforeCloseSlice.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,+BAA+B,GAAG,QAAQ,CAClD,qBAAqB,EACrB,OAAO,CACV,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACpC,eAAe,EAAE,qBAAqB,EAAE,CAAC;IACzC,eAAe,EAAE,OAAO,CAAC;CAC5B;AAyCD,eAAO,MACH,OAAO,oDAEH,qBAAqB,0IACrB,kBAAkB,+GAClB,uBAAuB,iHAEtB,CAAC;AAEV,eAAO,MAAM,oBAAoB,GAAI,OAAO,SAAS,sCAGlC,CAAC;AAEpB,eAAO,MAAM,yBAAyB,GAAI,OAAO,SAAS,YACR,CAAC;AAEnD,eAAO,MAAM,4BAA4B,GAEjC,YAAY,IAAI,CAAC,+BAA+B,EAAE,IAAI,CAAC,EACvD,SAAS,OAAO,CAAC,OAAO,CAAC,EACzB,kBAAkB,eAAe,KAClC,QAcF,CAAC"}
1
+ {"version":3,"file":"confirmBeforeCloseSlice.d.ts","sourceRoot":"","sources":["../../../../src/ConfirmBeforeClose/confirmBeforeCloseSlice.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,+BAA+B,GAAG,QAAQ,CAClD,qBAAqB,EACrB,OAAO,CACV,CAAC;AAEF,KAAK,gBAAgB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC3C,MAAM,WAAW,uBAAuB;IACpC,eAAe,EAAE,qBAAqB,EAAE,CAAC;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,gBAAgB,CAAC;CACzC;AA6CD,eAAO,MACH,OAAO,oDAEH,qBAAqB,0IACrB,kBAAkB,+GAClB,uBAAuB,mHACvB,sBAAsB,0HAErB,CAAC;AAEV,eAAO,MAAM,oBAAoB,GAAI,OAAO,SAAS,sCAGlC,CAAC;AAEpB,eAAO,MAAM,yBAAyB,GAAI,OAAO,SAAS,YACR,CAAC;AAEnD,eAAO,MAAM,mBAAmB,GAAI,OAAO,SAAS,qBACE,CAAC;AAEvD,eAAO,MAAM,4BAA4B,GAEjC,YAAY,IAAI,CAAC,+BAA+B,EAAE,IAAI,CAAC,EACvD,SAAS,OAAO,CAAC,OAAO,CAAC,EACzB,kBAAkB,eAAe,KAClC,QAcF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AppThunk } from '../store';
2
+ export declare const onUserConfirmAll: () => AppThunk;
3
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../../src/ConfirmBeforeClose/effects.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,eAAO,MAAM,gBAAgB,QAAO,QAOnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FactoryResetButton.d.ts","sourceRoot":"","sources":["../../../../src/FactoryReset/FactoryResetButton.tsx"],"names":[],"mappings":"AAMA,OAAc,EAAE,KAAK,EAAE,EAAoB,MAAM,OAAO,CAAC;AAGzD,OAAe,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAK/D,UAAU,KAAK;IACX,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAKD,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,KAAK,CAsDjC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"FactoryResetButton.d.ts","sourceRoot":"","sources":["../../../../src/FactoryReset/FactoryResetButton.tsx"],"names":[],"mappings":"AAMA,OAAc,EAAE,KAAK,EAAE,EAAoB,MAAM,OAAO,CAAC;AAIzD,OAAe,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAM/D,UAAU,KAAK;IACX,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAKD,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,KAAK,CAwDjC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "246.0.0",
3
+ "version": "248.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
package/release_notes.md CHANGED
@@ -1,3 +1,4 @@
1
- ### Changed
1
+ ### Fixed
2
2
 
3
- - Aligned Card component styles with old implementation.
3
+ - In case app is executing important task application will properly reopen when
4
+ resetting defaults.
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright (c) 2026 Nordic Semiconductor ASA
3
+ *
4
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
+ */
6
+
7
+ import { sameRepoURLs } from './check-app-properties';
8
+
9
+ describe('sameRepoURLs', () => {
10
+ it('accepts equal URLs', () => {
11
+ expect(
12
+ sameRepoURLs(
13
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
14
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
15
+ ),
16
+ ).toBe(true);
17
+ });
18
+
19
+ it('rejects different URLs', () => {
20
+ expect(
21
+ sameRepoURLs(
22
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
23
+ 'https://github.com/nordicsemi/pc-nrfconnect-shared',
24
+ ),
25
+ ).toBe(false);
26
+ });
27
+
28
+ it('ignores a .git postfix on either URL', () => {
29
+ expect(
30
+ sameRepoURLs(
31
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk.git',
32
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
33
+ ),
34
+ ).toBe(true);
35
+ expect(
36
+ sameRepoURLs(
37
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
38
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk.git',
39
+ ),
40
+ ).toBe(true);
41
+ });
42
+
43
+ it('treats the protocol https and git as the same', () => {
44
+ expect(
45
+ sameRepoURLs(
46
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
47
+ 'git@github.com:nordicsemi/pc-nrfconnect-ppk.git',
48
+ ),
49
+ ).toBe(true);
50
+ });
51
+
52
+ it('ignores the host name for the git protocol', () => {
53
+ expect(
54
+ sameRepoURLs(
55
+ 'https://github.com/nordicsemi/pc-nrfconnect-ppk',
56
+ 'git@nordic-git:nordicsemi/pc-nrfconnect-ppk.git',
57
+ ),
58
+ ).toBe(true);
59
+ });
60
+ });
@@ -65,6 +65,18 @@ const mustContainOneOf = (
65
65
  }
66
66
  };
67
67
 
68
+ export const sameRepoURLs = (url1: string, url2: string) => {
69
+ const withoutPostfix = (gitUrl: string) => gitUrl.replace(/\.git$/, '');
70
+
71
+ const withoutProtocol = (gitUrl: string) =>
72
+ gitUrl.replace(/^git@[^:]+:/, 'github.com/').replace(/^https:\/\//, '');
73
+
74
+ const stripped = (gitUrl: string) =>
75
+ withoutProtocol(withoutPostfix(gitUrl));
76
+
77
+ return stripped(url1) === stripped(url2);
78
+ };
79
+
68
80
  const checkRepoUrl = (packageJson: PackageJsonApp) => {
69
81
  if (!existsSync('./.git')) {
70
82
  return;
@@ -75,17 +87,7 @@ const checkRepoUrl = (packageJson: PackageJsonApp) => {
75
87
  }).trimEnd();
76
88
  const declaredGitUrl = packageJson.repository?.url;
77
89
 
78
- const withoutPostfix = (gitUrl?: string) => gitUrl?.replace(/\.git$/, '');
79
-
80
- const withoutProtocol = (gitUrl?: string) =>
81
- gitUrl
82
- ?.replace(/^git@github\.com:/, 'github.com/')
83
- .replace(/^https:\/\//, '');
84
-
85
- const stripped = (gitUrl?: string) =>
86
- withoutProtocol(withoutPostfix(gitUrl));
87
-
88
- if (stripped(realGitUrl) !== stripped(declaredGitUrl)) {
90
+ if (declaredGitUrl == null || !sameRepoURLs(realGitUrl, declaredGitUrl)) {
89
91
  fail(
90
92
  `package.json says the repository is located at \`${declaredGitUrl}\` but \`git remote get-url origin\` says it is at \`${realGitUrl}\`.`,
91
93
  );
@@ -16,8 +16,10 @@ import {
16
16
  type ConfirmBeforeCloseApp,
17
17
  getNextConfirmDialog,
18
18
  getShowConfirmCloseDialog,
19
+ setActionOnAllComplete,
19
20
  setShowCloseDialog,
20
21
  } from './confirmBeforeCloseSlice';
22
+ import { onUserConfirmAll } from './effects';
21
23
 
22
24
  export default () => {
23
25
  const dispatch = useDispatch();
@@ -34,7 +36,7 @@ export default () => {
34
36
  if (confirmedDialog.onClose) confirmedDialog.onClose();
35
37
  });
36
38
  setConfirmedDialogs([]);
37
- getCurrentWindow().close();
39
+ dispatch(onUserConfirmAll());
38
40
  }
39
41
  }, [nextConfirmDialog, dispatch, showCloseDialog, confirmedDialogs]);
40
42
 
@@ -78,6 +80,7 @@ export default () => {
78
80
  dispatch(addConfirmBeforeClose(confirmedDialog)),
79
81
  );
80
82
  setConfirmedDialogs([]);
83
+ dispatch(setActionOnAllComplete('close'));
81
84
  }}
82
85
  >
83
86
  {nextConfirmDialog?.message}
@@ -24,14 +24,17 @@ export type ConfirmBeforeCloseOptionalTitle = Optional<
24
24
  'title'
25
25
  >;
26
26
 
27
+ type OnCompleteAction = 'close' | 'reload';
27
28
  export interface ConfirmBeforeCloseState {
28
29
  confirmCloseApp: ConfirmBeforeCloseApp[];
29
30
  showCloseDialog: boolean;
31
+ actionOnAllComplete: OnCompleteAction;
30
32
  }
31
33
 
32
34
  const initialState: ConfirmBeforeCloseState = {
33
35
  confirmCloseApp: [],
34
36
  showCloseDialog: false,
37
+ actionOnAllComplete: 'close',
35
38
  };
36
39
 
37
40
  const slice = createSlice({
@@ -65,6 +68,9 @@ const slice = createSlice({
65
68
  setShowCloseDialog(state, action: PayloadAction<boolean>) {
66
69
  state.showCloseDialog = action.payload;
67
70
  },
71
+ setActionOnAllComplete(state, action: PayloadAction<OnCompleteAction>) {
72
+ state.actionOnAllComplete = action.payload;
73
+ },
68
74
  },
69
75
  });
70
76
 
@@ -74,6 +80,7 @@ export const {
74
80
  addConfirmBeforeClose,
75
81
  setShowCloseDialog,
76
82
  clearConfirmBeforeClose,
83
+ setActionOnAllComplete,
77
84
  },
78
85
  } = slice;
79
86
 
@@ -85,6 +92,9 @@ export const getNextConfirmDialog = (state: RootState) =>
85
92
  export const getShowConfirmCloseDialog = (state: RootState) =>
86
93
  state.confirmBeforeCloseDialog.showCloseDialog;
87
94
 
95
+ export const getActionOnComplete = (state: RootState) =>
96
+ state.confirmBeforeCloseDialog.actionOnAllComplete;
97
+
88
98
  export const preventAppCloseUntilComplete =
89
99
  (
90
100
  dialogInfo: Omit<ConfirmBeforeCloseOptionalTitle, 'id'>,
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (c) 2024 Nordic Semiconductor ASA
3
+ *
4
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
+ */
6
+
7
+ import { getCurrentWindow } from '@electron/remote';
8
+
9
+ import type { AppThunk } from '../store';
10
+ import { getActionOnComplete } from './confirmBeforeCloseSlice';
11
+
12
+ export const onUserConfirmAll = (): AppThunk => (_, getState) => {
13
+ const actionType = getActionOnComplete(getState());
14
+ if (actionType === 'close') {
15
+ getCurrentWindow().close();
16
+ } else {
17
+ getCurrentWindow().reload();
18
+ }
19
+ };
@@ -5,9 +5,11 @@
5
5
  */
6
6
 
7
7
  import React, { type FC, useRef, useState } from 'react';
8
+ import { useDispatch } from 'react-redux';
8
9
  import { getCurrentWindow } from '@electron/remote';
9
10
 
10
11
  import Button, { type ButtonVariants } from '../Button/Button';
12
+ import { setActionOnAllComplete } from '../ConfirmBeforeClose/confirmBeforeCloseSlice';
11
13
  import { Dialog, DialogButton } from '../Dialog/Dialog';
12
14
  import logger from '../logging';
13
15
  import { getAppSpecificStore as store } from '../utils/persistentStore';
@@ -32,11 +34,13 @@ const FactoryResetButton: FC<Props> = ({
32
34
  classNames,
33
35
  large = false,
34
36
  }) => {
37
+ const dispatch = useDispatch();
35
38
  const [showDialog, setShowDialog] = useState(false);
36
39
  useRef(); // showdialog
37
40
  const defaultResetFn = () => {
38
41
  store().clear();
39
42
  logger.info('Successfully restored defaults');
43
+ dispatch(setActionOnAllComplete('reload'));
40
44
  getCurrentWindow().reload();
41
45
  };
42
46