@northern.tech/store 0.41.2 → 0.42.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.
Files changed (225) hide show
  1. package/dist/actions.d.cts +9 -10
  2. package/dist/actions.d.ts +9 -10
  3. package/dist/api/general-api.cjs +1 -1
  4. package/dist/api/general-api.cjs.map +1 -1
  5. package/dist/api/general-api.d.cts +0 -1
  6. package/dist/api/general-api.d.ts +0 -1
  7. package/dist/api/general-api.js +1 -1
  8. package/dist/api/users-api.cjs +1 -1
  9. package/dist/api/users-api.d.cts +1 -6
  10. package/dist/api/users-api.d.ts +1 -6
  11. package/dist/appSlice/constants.cjs +0 -5
  12. package/dist/appSlice/constants.cjs.map +1 -1
  13. package/dist/appSlice/constants.d.cts +1 -1
  14. package/dist/appSlice/constants.d.ts +1 -1
  15. package/dist/appSlice/constants.js +0 -5
  16. package/dist/appSlice/constants.js.map +1 -1
  17. package/dist/appSlice/index.cjs.map +1 -1
  18. package/dist/appSlice/index.d.cts +1 -1
  19. package/dist/appSlice/index.d.ts +1 -1
  20. package/dist/appSlice/index.js +1 -1
  21. package/dist/appSlice/mocks.d.cts +1 -2
  22. package/dist/appSlice/mocks.d.ts +1 -2
  23. package/dist/appSlice/selectors.cjs.map +1 -1
  24. package/dist/appSlice/selectors.d.cts +9 -10
  25. package/dist/appSlice/selectors.d.ts +9 -10
  26. package/dist/appSlice/thunks.d.cts +2 -3
  27. package/dist/appSlice/thunks.d.ts +2 -3
  28. package/dist/auth.cjs +1 -1
  29. package/dist/auth.d.cts +3 -10
  30. package/dist/auth.d.ts +3 -10
  31. package/dist/auth.js +1 -1
  32. package/dist/commonConstants.d.cts +1 -1
  33. package/dist/commonConstants.d.ts +1 -1
  34. package/dist/commonConstants.js +1 -1
  35. package/dist/commonSelectors.cjs +4 -3
  36. package/dist/commonSelectors.cjs.map +1 -1
  37. package/dist/commonSelectors.d.cts +20 -21
  38. package/dist/commonSelectors.d.ts +20 -21
  39. package/dist/commonSelectors.js +4 -3
  40. package/dist/commonSelectors.js.map +1 -1
  41. package/dist/{constants-Sn4gnNA3.d.ts → constants-B3Jdkn2b.d.cts} +2 -5
  42. package/dist/{constants-Sn4gnNA3.d.cts → constants-B3Jdkn2b.d.ts} +2 -5
  43. package/dist/{constants-CzjK2gV-.d.ts → constants-B_H4squx.d.ts} +4 -4
  44. package/dist/{constants-D9o0Cnk_.d.ts → constants-C6TIYaY4.d.cts} +1 -2
  45. package/dist/{constants-D9o0Cnk_.d.cts → constants-C6TIYaY4.d.ts} +1 -2
  46. package/dist/{constants-6kYRTdox.d.ts → constants-CEwun8TL.d.cts} +3 -2
  47. package/dist/{constants-6kYRTdox.d.cts → constants-CEwun8TL.d.ts} +3 -2
  48. package/dist/constants-C_SC_VKE.cjs.map +1 -1
  49. package/dist/{constants-xpheFFkA.js → constants-CerzXHnQ.js} +3 -3
  50. package/dist/{constants-xpheFFkA.js.map → constants-CerzXHnQ.js.map} +1 -1
  51. package/dist/{constants-DAi2zOZN.d.cts → constants-Rl3FJzFf.d.cts} +4 -4
  52. package/dist/{constants-B_7FCJQX.d.ts → constants-nKSWZ8oD.d.cts} +3 -8
  53. package/dist/{constants-B_7FCJQX.d.cts → constants-nKSWZ8oD.d.ts} +3 -8
  54. package/dist/constants.cjs +2 -0
  55. package/dist/constants.d.cts +6 -6
  56. package/dist/constants.d.ts +6 -6
  57. package/dist/constants.js +3 -3
  58. package/dist/deploymentsSlice/constants.d.cts +1 -1
  59. package/dist/deploymentsSlice/constants.d.ts +1 -1
  60. package/dist/deploymentsSlice/constants.js +1 -1
  61. package/dist/deploymentsSlice/index.cjs.map +1 -1
  62. package/dist/deploymentsSlice/index.d.cts +1 -1
  63. package/dist/deploymentsSlice/index.d.ts +1 -1
  64. package/dist/deploymentsSlice/index.js +1 -1
  65. package/dist/deploymentsSlice/mocks.d.cts +1 -2
  66. package/dist/deploymentsSlice/mocks.d.ts +1 -2
  67. package/dist/deploymentsSlice/selectors.cjs.map +1 -1
  68. package/dist/deploymentsSlice/selectors.d.cts +9 -10
  69. package/dist/deploymentsSlice/selectors.d.ts +9 -10
  70. package/dist/deploymentsSlice/selectors.js +1 -1
  71. package/dist/deploymentsSlice/thunks.d.cts +7 -13
  72. package/dist/deploymentsSlice/thunks.d.ts +7 -13
  73. package/dist/devicesSlice/constants.d.cts +1 -1
  74. package/dist/devicesSlice/constants.d.ts +1 -1
  75. package/dist/devicesSlice/constants.js +1 -1
  76. package/dist/devicesSlice/index.cjs +1 -1
  77. package/dist/devicesSlice/index.cjs.map +1 -1
  78. package/dist/devicesSlice/index.d.cts +2 -2
  79. package/dist/devicesSlice/index.d.ts +2 -2
  80. package/dist/devicesSlice/index.js +2 -2
  81. package/dist/devicesSlice/index.js.map +1 -1
  82. package/dist/devicesSlice/mocks.js +1 -1
  83. package/dist/devicesSlice/selectors.cjs.map +1 -1
  84. package/dist/devicesSlice/selectors.d.cts +9 -10
  85. package/dist/devicesSlice/selectors.d.ts +9 -10
  86. package/dist/devicesSlice/selectors.js +1 -1
  87. package/dist/devicesSlice/thunks.cjs +1 -2
  88. package/dist/devicesSlice/thunks.d.cts +11 -23
  89. package/dist/devicesSlice/thunks.d.ts +11 -23
  90. package/dist/devicesSlice/thunks.js +2 -2
  91. package/dist/{index-Bb4yvvgG.d.ts → index-B8td4-rY.d.ts} +1 -2
  92. package/dist/{index-C5oQrJGU.d.ts → index-BAGyeC-q.d.ts} +2 -3
  93. package/dist/{index-CgPgKMve.d.cts → index-BgF6rhXn.d.cts} +3 -4
  94. package/dist/{index-CnH51JfB.d.ts → index-Bs0c1-WY.d.ts} +4 -9
  95. package/dist/{index-BtGhTFBc.d.ts → index-Bvyf8OO6.d.ts} +9 -13
  96. package/dist/{index-m1c0qk2s.d.ts → index-C8uiyxnb.d.ts} +2 -3
  97. package/dist/{index-CSOj22xK.d.cts → index-C_LGDJN2.d.cts} +2 -3
  98. package/dist/{index-H9zg_3UV.d.ts → index-ChKTa1aL.d.ts} +2 -3
  99. package/dist/{index-vXsWdis1.d.cts → index-CiQ95u1W.d.cts} +9 -13
  100. package/dist/{index-DBUt8xVc.d.ts → index-CoObjWL4.d.cts} +1 -2
  101. package/dist/{index-DBUt8xVc.d.cts → index-CoObjWL4.d.ts} +1 -2
  102. package/dist/{index-BCErsO5h.d.ts → index-CpfhQHfg.d.ts} +3 -4
  103. package/dist/{index-BQCnJ5gh.d.cts → index-Ctj2r57a.d.cts} +2 -3
  104. package/dist/{index-Dn1SqQYh.d.cts → index-DeOpb2oK.d.cts} +4 -9
  105. package/dist/{index-VEayiYkv.d.cts → index-DiAjzARZ.d.cts} +2 -3
  106. package/dist/{index-EPmsL6Lb.d.cts → index-mvxjivTJ.d.cts} +1 -2
  107. package/dist/liststatehook.cjs.map +1 -1
  108. package/dist/liststatehook.d.cts +0 -1
  109. package/dist/liststatehook.d.ts +0 -1
  110. package/dist/locationutils.cjs +36 -28
  111. package/dist/locationutils.cjs.map +1 -1
  112. package/dist/locationutils.d.cts +14 -67
  113. package/dist/locationutils.d.ts +14 -67
  114. package/dist/locationutils.js +37 -29
  115. package/dist/locationutils.js.map +1 -1
  116. package/dist/monitorSlice/constants.d.cts +1 -1
  117. package/dist/monitorSlice/constants.d.ts +1 -1
  118. package/dist/monitorSlice/index.cjs.map +1 -1
  119. package/dist/monitorSlice/index.d.cts +1 -1
  120. package/dist/monitorSlice/index.d.ts +1 -1
  121. package/dist/monitorSlice/index.js +1 -1
  122. package/dist/monitorSlice/mocks.d.cts +1 -2
  123. package/dist/monitorSlice/mocks.d.ts +1 -2
  124. package/dist/monitorSlice/mocks.js +1 -1
  125. package/dist/monitorSlice/selectors.d.cts +1 -2
  126. package/dist/monitorSlice/selectors.d.ts +1 -2
  127. package/dist/monitorSlice/thunks.d.cts +4 -5
  128. package/dist/monitorSlice/thunks.d.ts +4 -5
  129. package/dist/monitorSlice/thunks.js +1 -1
  130. package/dist/onboardingSlice/index.cjs.map +1 -1
  131. package/dist/onboardingSlice/index.d.cts +1 -1
  132. package/dist/onboardingSlice/index.d.ts +1 -1
  133. package/dist/onboardingSlice/mocks.d.cts +1 -2
  134. package/dist/onboardingSlice/mocks.d.ts +1 -2
  135. package/dist/onboardingSlice/selectors.d.cts +2 -3
  136. package/dist/onboardingSlice/selectors.d.ts +2 -3
  137. package/dist/onboardingSlice/thunks.d.cts +4 -4
  138. package/dist/onboardingSlice/thunks.d.ts +4 -4
  139. package/dist/organizationSlice/constants.js +1 -1
  140. package/dist/organizationSlice/index.cjs.map +1 -1
  141. package/dist/organizationSlice/index.d.cts +1 -1
  142. package/dist/organizationSlice/index.d.ts +1 -1
  143. package/dist/organizationSlice/index.js +1 -1
  144. package/dist/organizationSlice/mocks.d.cts +3 -3
  145. package/dist/organizationSlice/mocks.d.ts +3 -3
  146. package/dist/organizationSlice/mocks.js +1 -1
  147. package/dist/organizationSlice/selectors.cjs.map +1 -1
  148. package/dist/organizationSlice/selectors.d.cts +11 -16
  149. package/dist/organizationSlice/selectors.d.ts +11 -16
  150. package/dist/organizationSlice/selectors.js +1 -1
  151. package/dist/organizationSlice/thunks.d.cts +6 -7
  152. package/dist/organizationSlice/thunks.d.ts +6 -7
  153. package/dist/organizationSlice/types.d.cts +1 -1
  154. package/dist/organizationSlice/types.d.ts +1 -1
  155. package/dist/releasesSlice/constants.cjs +2 -0
  156. package/dist/releasesSlice/constants.cjs.map +1 -1
  157. package/dist/releasesSlice/constants.d.cts +2 -2
  158. package/dist/releasesSlice/constants.d.ts +2 -2
  159. package/dist/releasesSlice/constants.js +2 -1
  160. package/dist/releasesSlice/constants.js.map +1 -1
  161. package/dist/releasesSlice/index.cjs.map +1 -1
  162. package/dist/releasesSlice/index.d.cts +1 -1
  163. package/dist/releasesSlice/index.d.ts +1 -1
  164. package/dist/releasesSlice/index.js +1 -1
  165. package/dist/releasesSlice/mocks.js +1 -1
  166. package/dist/releasesSlice/selectors.cjs.map +1 -1
  167. package/dist/releasesSlice/selectors.d.cts +9 -10
  168. package/dist/releasesSlice/selectors.d.ts +9 -10
  169. package/dist/releasesSlice/thunks.cjs +1 -1
  170. package/dist/releasesSlice/thunks.cjs.map +1 -1
  171. package/dist/releasesSlice/thunks.d.cts +4 -5
  172. package/dist/releasesSlice/thunks.d.ts +4 -5
  173. package/dist/releasesSlice/thunks.js +1 -1
  174. package/dist/{rolldown-runtime-D6vf50IK.cjs → rolldown-runtime-VH7oDXx4.cjs} +1 -1
  175. package/dist/sockethook.cjs +1 -2
  176. package/dist/sockethook.cjs.map +1 -1
  177. package/dist/sockethook.d.cts +1 -8
  178. package/dist/sockethook.d.ts +1 -8
  179. package/dist/sockethook.js +1 -2
  180. package/dist/sockethook.js.map +1 -1
  181. package/dist/{store-CkgokFlk.d.ts → store-CPptM5Ts.d.ts} +27 -48
  182. package/dist/{store-CGP5pCH8.d.cts → store-CUUm1GTI.d.cts} +27 -48
  183. package/dist/store.cjs.map +1 -1
  184. package/dist/store.d.cts +1 -1
  185. package/dist/store.d.ts +1 -1
  186. package/dist/store.js +1 -1
  187. package/dist/storehooks.cjs +30 -20
  188. package/dist/storehooks.cjs.map +1 -1
  189. package/dist/storehooks.d.cts +13 -4
  190. package/dist/storehooks.d.ts +13 -4
  191. package/dist/storehooks.js +31 -22
  192. package/dist/storehooks.js.map +1 -1
  193. package/dist/thunks.cjs +16 -112
  194. package/dist/thunks.cjs.map +1 -1
  195. package/dist/thunks.d.cts +2 -2
  196. package/dist/thunks.d.ts +2 -2
  197. package/dist/thunks.js +16 -111
  198. package/dist/thunks.js.map +1 -1
  199. package/dist/{types-uHmaedGU.d.ts → types-B3qGQoMx.d.ts} +3 -4
  200. package/dist/{types-yQ0ypHMZ.d.cts → types-B80ckxiy.d.cts} +3 -4
  201. package/dist/useDeploymentDevice.cjs +1 -1
  202. package/dist/useDeploymentDevice.cjs.map +1 -1
  203. package/dist/usersSlice/constants.d.cts +1 -1
  204. package/dist/usersSlice/constants.d.ts +1 -1
  205. package/dist/usersSlice/constants.js +1 -1
  206. package/dist/usersSlice/index.cjs.map +1 -1
  207. package/dist/usersSlice/index.d.cts +1 -1
  208. package/dist/usersSlice/index.d.ts +1 -1
  209. package/dist/usersSlice/index.js +1 -1
  210. package/dist/usersSlice/mocks.d.cts +2 -3
  211. package/dist/usersSlice/mocks.d.ts +2 -3
  212. package/dist/usersSlice/mocks.js +1 -1
  213. package/dist/usersSlice/selectors.cjs.map +1 -1
  214. package/dist/usersSlice/selectors.d.cts +10 -11
  215. package/dist/usersSlice/selectors.d.ts +10 -11
  216. package/dist/usersSlice/selectors.js +1 -1
  217. package/dist/usersSlice/thunks.d.cts +5 -6
  218. package/dist/usersSlice/thunks.d.ts +5 -6
  219. package/dist/utils.cjs +2 -2
  220. package/dist/utils.cjs.map +1 -1
  221. package/dist/utils.d.cts +1 -1
  222. package/dist/utils.d.ts +1 -1
  223. package/dist/utils.js +3 -3
  224. package/dist/utils.js.map +1 -1
  225. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"storehooks.cjs","names":["Cookies","durationDayJs","storeActions","createAppAsyncThunk","getOnboardingStateSelector","stringToBoolean","getSessionInfo","DEVICE_STATES","getDeviceById","useAppDispatch","useAppSelector","getIsEnterprise","getFeatures","getDevicesByStatusSelector","getUserSettingsSelector","getUserCapabilities","getOfflineThresholdSettings","getGlobalSettingsSelector","getSortedFilteringAttributes","getIsServiceProvider","getUserSettings","getGlobalSettings","getUserOrganization","getRoles","getDeviceAttributes","getDeploymentsByStatus","DEPLOYMENT_STATES","getDevicesByStatus","getDynamicGroups","getGroups","getIntegrations","getReleases","getAllDeviceCounts","getDeviceLimits","saveUserSettings","timeUnits","TIMEOUTS","saveGlobalSettings","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsEnterprise,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || window.location.hostname.includes('hosted.mender.io')\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const isEnterprise = useAppSelector(getIsEnterprise);\n const { hasMultitenancy, isHosted } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback((): Promise<unknown[]> => {\n const tasks: Promise<unknown>[] = [\n dispatch(parseEnvironmentInfo()).unwrap(),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ];\n const multitenancy = hasMultitenancy || isHosted || isEnterprise;\n if (multitenancy) {\n tasks.push(dispatch(getUserOrganization()).unwrap());\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isHosted, isEnterprise]);\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\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;CAAgB,CAC9C;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,iBAAiB,CAAC,CAAC,WAAW,gBAAgB,IAAI,CAAC;CACrD,GAAG,CAAC,QAAQ,gBAAgB,CAAC;CAE7B,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB;CACpB,GAAG,CAAC,mBAAmB,YAAY,CAAC;CAEpC,OAAO,EAAE,aAAa;AACxB"}
1
+ {"version":3,"file":"storehooks.cjs","names":["Cookies","durationDayJs","storeActions","locations","createAppAsyncThunk","getOnboardingStateSelector","stringToBoolean","getSessionInfo","getUserOrganization","getFeatures","DEVICE_STATES","getDeviceById","useAppDispatch","useState","useAppSelector","getDevicesByStatusSelector","getUserSettingsSelector","getUserCapabilities","getOfflineThresholdSettings","getGlobalSettingsSelector","getSortedFilteringAttributes","getIsServiceProvider","useRef","useCallback","getUserSettings","getGlobalSettings","getRoles","getDeviceAttributes","getDeploymentsByStatus","DEPLOYMENT_STATES","getDevicesByStatus","getDynamicGroups","getGroups","getIntegrations","getReleases","getAllDeviceCounts","getDeviceLimits","actions","saveUserSettings","timeUnits","TIMEOUTS","saveGlobalSettings","extractErrorMessage","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport actions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, locations, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\n// a host is hosted when it is one of the known hosted domains or a subdomain of one (e.g. staging.hosted.mender.io),\n// except for per-PR preview deployments whose leading label looks like <component>-pr-<number> (e.g. os-pr-2012.staging.hosted.mender.io)\nconst hostedDomains = Object.values(locations).map(({ location }) => location);\nconst isPreviewDeployment = (hostname: string) => /^[^.]+-pr-\\d+\\./.test(hostname);\nconst isHostedHostname = (hostname: string) =>\n !isPreviewDeployment(hostname) && hostedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || isHostedHostname(window.location.hostname)\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\n// probes the organization endpoint to classify the deployment: reaching it means the deployment is multitenant,\n// which - when not hosted - identifies an on-prem enterprise installation, while an unreachable endpoint identifies\n// a single-tenant OS installation. hosted deployments keep their plan-derived enterprise status (getIsEnterprise).\n// must run after parseEnvironmentInfo so the final isHosted value is available in the store.\nexport const probeOrganizationCapabilities = createAppAsyncThunk(`app/probeOrganizationCapabilities`, (_, { dispatch, getState }) =>\n dispatch(getUserOrganization())\n .unwrap()\n .then(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: true, isEnterprise: true }));\n }\n })\n .catch(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: false, isEnterprise: false }));\n }\n })\n);\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const { hasMultitenancy } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback(\n (): Promise<unknown[]> =>\n Promise.all([\n // parse the environment first so isHosted is set before the organization probe classifies the deployment type\n dispatch(parseEnvironmentInfo())\n .unwrap()\n .then(() => dispatch(probeOrganizationCapabilities()).unwrap()),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ]),\n [dispatch]\n );\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n } else {\n tasks.push(Promise.resolve(dispatch(actions.setDeviceLimits({ micro: 0, standard: -1, system: 0 }))));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,UAAU,IAAIA,iBAAAA,QAAQ;AAC5B,MAAA,QAAM,OAAOC,yBAAAA,OAAa;AAE1B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BC;AAIvG,MAAM,gBAAgB,OAAO,OAAOC,2BAAAA,SAAS,CAAC,CAAC,KAAK,EAAE,eAAe,QAAQ;AAC7E,MAAM,uBAAuB,aAAqB,kBAAkB,KAAK,QAAQ;AACjF,MAAM,oBAAoB,aACxB,CAAC,oBAAoB,QAAQ,KAAK,cAAc,MAAK,WAAU,aAAa,UAAU,SAAS,SAAS,IAAI,QAAQ,CAAC;AAEvH,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AASA,MAAa,uBAAuBC,cAAAA,oBAAoB,6BAA6B,GAAG,EA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mBAAmB,CAAC,CAAC,GAC9C;EAAC;EAAU;EAAiB;CAAgB,CAC9C;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,iBAAiB,CAAC,CAAC,WAAW,gBAAgB,IAAI,CAAC;CACrD,GAAG,CAAC,QAAQ,gBAAgB,CAAC;CAE7B,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB;CACpB,GAAG,CAAC,mBAAmB,YAAY,CAAC;CAEpC,OAAO,EAAE,aAAa;AACxB"}
@@ -1,6 +1,5 @@
1
- import { i as UserSession } from "./index-CgPgKMve.cjs";
2
- import { r as RootState, t as AppDispatch } from "./store-CGP5pCH8.cjs";
3
-
1
+ import { i as UserSession } from "./index-BgF6rhXn.cjs";
2
+ import { r as RootState, t as AppDispatch } from "./store-CUUm1GTI.cjs";
4
3
  //#region src/storehooks.d.ts
5
4
  declare const parseEnvironmentInfo: import("@reduxjs/toolkit").AsyncThunk<[{
6
5
  payload: UserSession;
@@ -33,9 +32,19 @@ declare const parseEnvironmentInfo: import("@reduxjs/toolkit").AsyncThunk<[{
33
32
  fulfilledMeta?: unknown;
34
33
  rejectedMeta?: unknown;
35
34
  }>;
35
+ declare const probeOrganizationCapabilities: import("@reduxjs/toolkit").AsyncThunk<void, void, {
36
+ dispatch: AppDispatch;
37
+ state: RootState;
38
+ extra?: unknown;
39
+ rejectValue?: unknown;
40
+ serializedErrorType?: unknown;
41
+ pendingMeta?: unknown;
42
+ fulfilledMeta?: unknown;
43
+ rejectedMeta?: unknown;
44
+ }>;
36
45
  declare const useAppInit: (userId: string | undefined) => {
37
46
  coreInitDone: boolean;
38
47
  };
39
48
  //#endregion
40
- export { parseEnvironmentInfo, useAppInit };
49
+ export { parseEnvironmentInfo, probeOrganizationCapabilities, useAppInit };
41
50
  //# sourceMappingURL=storehooks.d.cts.map
@@ -1,6 +1,5 @@
1
- import { i as UserSession } from "./index-BCErsO5h.js";
2
- import { r as RootState, t as AppDispatch } from "./store-CkgokFlk.js";
3
-
1
+ import { i as UserSession } from "./index-CpfhQHfg.js";
2
+ import { r as RootState, t as AppDispatch } from "./store-CPptM5Ts.js";
4
3
  //#region src/storehooks.d.ts
5
4
  declare const parseEnvironmentInfo: import("@reduxjs/toolkit").AsyncThunk<[{
6
5
  payload: UserSession;
@@ -33,9 +32,19 @@ declare const parseEnvironmentInfo: import("@reduxjs/toolkit").AsyncThunk<[{
33
32
  fulfilledMeta?: unknown;
34
33
  rejectedMeta?: unknown;
35
34
  }>;
35
+ declare const probeOrganizationCapabilities: import("@reduxjs/toolkit").AsyncThunk<void, void, {
36
+ dispatch: AppDispatch;
37
+ state: RootState;
38
+ extra?: unknown;
39
+ rejectValue?: unknown;
40
+ serializedErrorType?: unknown;
41
+ pendingMeta?: unknown;
42
+ fulfilledMeta?: unknown;
43
+ rejectedMeta?: unknown;
44
+ }>;
36
45
  declare const useAppInit: (userId: string | undefined) => {
37
46
  coreInitDone: boolean;
38
47
  };
39
48
  //#endregion
40
- export { parseEnvironmentInfo, useAppInit };
49
+ export { parseEnvironmentInfo, probeOrganizationCapabilities, useAppInit };
41
50
  //# sourceMappingURL=storehooks.d.ts.map
@@ -1,4 +1,5 @@
1
- import { Bt as timeUnits, Nt as TIMEOUTS, gt as DEPLOYMENT_STATES, u as DEVICE_STATES } from "./constants-xpheFFkA.js";
1
+ import { locations } from "./appSlice/constants.js";
2
+ import { Pt as TIMEOUTS, Vt as timeUnits, _t as DEPLOYMENT_STATES, u as DEVICE_STATES } from "./constants-CerzXHnQ.js";
2
3
  import actions_default from "./actions.js";
3
4
  import { getSessionInfo } from "./auth.js";
4
5
  import { getFeatures } from "./appSlice/selectors.js";
@@ -6,7 +7,7 @@ import { getDevicesByStatus, getSortedFilteringAttributes } from "./devicesSlice
6
7
  import { getIsServiceProvider } from "./organizationSlice/selectors.js";
7
8
  import { stringToBoolean } from "./utils.js";
8
9
  import { getGlobalSettings, getOfflineThresholdSettings, getUserSettings } from "./usersSlice/selectors.js";
9
- import { getIsEnterprise, getOnboardingState, getUserCapabilities } from "./commonSelectors.js";
10
+ import { getOnboardingState, getUserCapabilities } from "./commonSelectors.js";
10
11
  import { createAppAsyncThunk, useAppDispatch, useAppSelector } from "./store.js";
11
12
  import { getReleases } from "./releasesSlice/thunks.js";
12
13
  import { getAllDeviceCounts, getDeploymentsByStatus, getDeviceAttributes, getDeviceById, getDeviceLimits, getDevicesByStatus as getDevicesByStatus$1, getDynamicGroups, getGlobalSettings as getGlobalSettings$1, getGroups, getIntegrations, getOnboardingState as getOnboardingState$1, getRoles, getUserOrganization, getUserSettings as getUserSettings$1, saveGlobalSettings, saveUserSettings } from "./thunks.js";
@@ -19,6 +20,9 @@ import durationDayJs from "dayjs/plugin/duration.js";
19
20
  const cookies = new Cookies();
20
21
  dayjs.extend(durationDayJs);
21
22
  const { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = actions_default;
23
+ const hostedDomains = Object.values(locations).map(({ location }) => location);
24
+ const isPreviewDeployment = (hostname) => /^[^.]+-pr-\d+\./.test(hostname);
25
+ const isHostedHostname = (hostname) => !isPreviewDeployment(hostname) && hostedDomains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
22
26
  const featureFlags = [
23
27
  "hasAiEnabled",
24
28
  "hasAuditlogs",
@@ -64,7 +68,7 @@ const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_,
64
68
  ...accu,
65
69
  [flag]: stringToBoolean(features[flag])
66
70
  }), {}),
67
- isHosted: stringToBoolean(features.isHosted) || window.location.hostname.includes("hosted.mender.io")
71
+ isHosted: stringToBoolean(features.isHosted) || isHostedHostname(window.location.hostname)
68
72
  };
69
73
  onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;
70
74
  versionInfo = {
@@ -81,6 +85,17 @@ const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_,
81
85
  dispatch(actions_default.setEnvironmentData(environmentData))
82
86
  ]);
83
87
  });
88
+ const probeOrganizationCapabilities = createAppAsyncThunk(`app/probeOrganizationCapabilities`, (_, { dispatch, getState }) => dispatch(getUserOrganization()).unwrap().then(() => {
89
+ if (!getFeatures(getState()).isHosted) dispatch(actions_default.setFeatures({
90
+ hasMultitenancy: true,
91
+ isEnterprise: true
92
+ }));
93
+ }).catch(() => {
94
+ if (!getFeatures(getState()).isHosted) dispatch(actions_default.setFeatures({
95
+ hasMultitenancy: false,
96
+ isEnterprise: false
97
+ }));
98
+ }));
84
99
  const maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }) => {
85
100
  if (!onboardingState.showTips || onboardingState.complete) return tasks;
86
101
  return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce((accu, id) => {
@@ -91,8 +106,7 @@ const maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, t
91
106
  const useAppInit = (userId) => {
92
107
  const dispatch = useAppDispatch();
93
108
  const [coreInitDone, setCoreInitDone] = useState(false);
94
- const isEnterprise = useAppSelector(getIsEnterprise);
95
- const { hasMultitenancy, isHosted } = useAppSelector(getFeatures);
109
+ const { hasMultitenancy } = useAppSelector(getFeatures);
96
110
  const devicesByStatus = useAppSelector(getDevicesByStatus);
97
111
  const onboardingState = useAppSelector(getOnboardingState);
98
112
  const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettings);
@@ -103,21 +117,12 @@ const useAppInit = (userId) => {
103
117
  const isServiceProvider = useAppSelector(getIsServiceProvider);
104
118
  const coreInitRunning = useRef(false);
105
119
  const fullInitRunning = useRef(false);
106
- const retrieveCoreData = useCallback(() => {
107
- const tasks = [
108
- dispatch(parseEnvironmentInfo()).unwrap(),
109
- dispatch(getUserSettings$1()).unwrap(),
110
- dispatch(getGlobalSettings$1()).unwrap(),
111
- Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get("firstLoginAfterSignup")))))
112
- ];
113
- if (hasMultitenancy || isHosted || isEnterprise) tasks.push(dispatch(getUserOrganization()).unwrap());
114
- return Promise.all(tasks);
115
- }, [
116
- dispatch,
117
- hasMultitenancy,
118
- isHosted,
119
- isEnterprise
120
- ]);
120
+ const retrieveCoreData = useCallback(() => Promise.all([
121
+ dispatch(parseEnvironmentInfo()).unwrap().then(() => dispatch(probeOrganizationCapabilities()).unwrap()),
122
+ dispatch(getUserSettings$1()).unwrap(),
123
+ dispatch(getGlobalSettings$1()).unwrap(),
124
+ Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get("firstLoginAfterSignup")))))
125
+ ]), [dispatch]);
121
126
  const retrieveAppData = useCallback(() => {
122
127
  if (isServiceProvider) return Promise.resolve(dispatch(getRoles()));
123
128
  const tasks = [
@@ -140,7 +145,11 @@ const useAppInit = (userId) => {
140
145
  if (hasMultitenancy) {
141
146
  tasks.push(dispatch(getDeviceLimits()));
142
147
  tasks.push(dispatch(getRoles()));
143
- }
148
+ } else tasks.push(Promise.resolve(dispatch(actions_default.setDeviceLimits({
149
+ micro: 0,
150
+ standard: -1,
151
+ system: 0
152
+ }))));
144
153
  return Promise.all(tasks);
145
154
  }, [
146
155
  dispatch,
@@ -225,6 +234,6 @@ const useAppInit = (userId) => {
225
234
  return { coreInitDone };
226
235
  };
227
236
  //#endregion
228
- export { parseEnvironmentInfo, useAppInit };
237
+ export { parseEnvironmentInfo, probeOrganizationCapabilities, useAppInit };
229
238
 
230
239
  //# sourceMappingURL=storehooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"storehooks.js","names":["storeActions","getOnboardingStateSelector","getDevicesByStatusSelector","getUserSettingsSelector","getGlobalSettingsSelector","getUserSettings","getGlobalSettings","getDevicesByStatus","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsEnterprise,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || window.location.hostname.includes('hosted.mender.io')\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const isEnterprise = useAppSelector(getIsEnterprise);\n const { hasMultitenancy, isHosted } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback((): Promise<unknown[]> => {\n const tasks: Promise<unknown>[] = [\n dispatch(parseEnvironmentInfo()).unwrap(),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ];\n const multitenancy = hasMultitenancy || isHosted || isEnterprise;\n if (multitenancy) {\n tasks.push(dispatch(getUserOrganization()).unwrap());\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isHosted, isEnterprise]);\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4DA,MAAM,UAAU,IAAI,QAAQ;AAC5B,MAAM,OAAO,aAAa;AAE1B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BA;AAEvG,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AASA,MAAa,uBAAuB,oBAAoB,6BAA6B,GAAG,EAAE,UAAU,eAAe;CACjH,MAAM,QAAQ,SAAS;CACvB,IAAI,qBAAqBC,mBAA2B,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,KAAK,MAAM,OAAO,aAAa,QAAQ,oBAAoB,KAAK,OAAO;CAChJ,IAAI,mBAAmB;CACvB,IAAI,kBAA2C,CAAC;CAChD,IAAI,sBAAyC,CAAC;CAC9C,IAAI,cAA2B,CAAC;CAChC,MAAM,qBAAqB,OAAO;CAClC,IAAI,oBAAoB;EACtB,MAAM,EAAE,WAAW,CAAC,GAAG,kBAAkB,MAAM,mBAAmB,YAAY;EAC9E,mBAAmB,OAAO,IAAI,KAAK;EACnC,MAAM,WAAW,MAAM;EACvB,kBAAkB,iBAAiB,QAAQ,MAAM,UAAU;GAAE,GAAG;IAAO,OAAO,mBAAmB,SAAS,SAAS;EAA+B,IAAI,CAAC,CAAC;EACxJ,sBAAsB;GACpB,GAAG,aAAa,QAA2B,MAAM,UAAU;IAAE,GAAG;KAAO,OAAO,gBAAgB,SAAS,KAAK;GAAE,IAAI,CAAC,CAAC;GACpH,UAAU,gBAAgB,SAAS,QAAQ,KAAK,OAAO,SAAS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;EACjH,IAAI,CAAC,gBAAgB,gBAAgB,QACnC,MAAM,KAAK,SAAS,mBAAmB,EAAE,cAAc;GAAE,WAAW,gBAAgB;GAAI,OAAO;EAAW,EAAE,CAAC,CAAC,CAAC;OAC1G,IAAI,OAAO,iBAAiB,UAAU;GAE3C,IAAI,YAAoB;GACxB,IAAI,cAAc,aAChB,YAAY;GAEd,MAAM,KAAK,SAAS,mBAAmB,EAAE,cAAc;IAAE;IAAW,OAAO;GAAW,EAAE,CAAC,CAAC,CAAC;EAC7F;EACA,MAAM,KAAK,QAAQ,QAAQ,SAASP,gBAAa,eAAe,CAAC,CAAC,CAAC;EACnE,OAAO,QAAQ,IAAI,KAAK;CAC1B,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,oBAAoB,kBAEtB,gBAAgB,CAAC,CACd,KAAK,gBAAgB,CAAC,CAEtB,OAAM,QAAO,QAAQ,IAAI,oBAAoB,GAAG,CAAC,CAAC,CAAC,CACnD,WAAW,SAASQ,qBAAmB,CAAC,CAAC,GAC9C;EAAC;EAAU;EAAiB;CAAgB,CAC9C;CAEA,gBAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,iBAAiB,CAAC,CAAC,WAAW,gBAAgB,IAAI,CAAC;CACrD,GAAG,CAAC,QAAQ,gBAAgB,CAAC;CAE7B,gBAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB;CACpB,GAAG,CAAC,mBAAmB,YAAY,CAAC;CAEpC,OAAO,EAAE,aAAa;AACxB"}
1
+ {"version":3,"file":"storehooks.js","names":["storeActions","getOnboardingStateSelector","getDevicesByStatusSelector","getUserSettingsSelector","getGlobalSettingsSelector","getUserSettings","getGlobalSettings","getDevicesByStatus","actions","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport actions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, locations, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\n// a host is hosted when it is one of the known hosted domains or a subdomain of one (e.g. staging.hosted.mender.io),\n// except for per-PR preview deployments whose leading label looks like <component>-pr-<number> (e.g. os-pr-2012.staging.hosted.mender.io)\nconst hostedDomains = Object.values(locations).map(({ location }) => location);\nconst isPreviewDeployment = (hostname: string) => /^[^.]+-pr-\\d+\\./.test(hostname);\nconst isHostedHostname = (hostname: string) =>\n !isPreviewDeployment(hostname) && hostedDomains.some(domain => hostname === domain || hostname.endsWith(`.${domain}`));\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasDeviceFlags',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docsVersion?: string;\n version?: string;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, version } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || isHostedHostname(window.location.hostname)\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docsVersion: isNaN(parseInt(version.charAt(0))) ? '' : version.split('.').slice(0, 2).join('.'),\n version\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation(versionInfo)),\n dispatch(storeActions.setEnvironmentData(environmentData))\n ]);\n});\n\n// probes the organization endpoint to classify the deployment: reaching it means the deployment is multitenant,\n// which - when not hosted - identifies an on-prem enterprise installation, while an unreachable endpoint identifies\n// a single-tenant OS installation. hosted deployments keep their plan-derived enterprise status (getIsEnterprise).\n// must run after parseEnvironmentInfo so the final isHosted value is available in the store.\nexport const probeOrganizationCapabilities = createAppAsyncThunk(`app/probeOrganizationCapabilities`, (_, { dispatch, getState }) =>\n dispatch(getUserOrganization())\n .unwrap()\n .then(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: true, isEnterprise: true }));\n }\n })\n .catch(() => {\n if (!getFeatures(getState()).isHosted) {\n dispatch(storeActions.setFeatures({ hasMultitenancy: false, isEnterprise: false }));\n }\n })\n);\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const { hasMultitenancy } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback(\n (): Promise<unknown[]> =>\n Promise.all([\n // parse the environment first so isHosted is set before the organization probe classifies the deployment type\n dispatch(parseEnvironmentInfo())\n .unwrap()\n .then(() => dispatch(probeOrganizationCapabilities()).unwrap()),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ]),\n [dispatch]\n );\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n } else {\n tasks.push(Promise.resolve(dispatch(actions.setDeviceLimits({ micro: 0, standard: -1, system: 0 }))));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4DA,MAAM,UAAU,IAAI,QAAQ;AAC5B,MAAM,OAAO,aAAa;AAE1B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BA;AAIvG,MAAM,gBAAgB,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,EAAE,eAAe,QAAQ;AAC7E,MAAM,uBAAuB,aAAqB,kBAAkB,KAAK,QAAQ;AACjF,MAAM,oBAAoB,aACxB,CAAC,oB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5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
2
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
3
  const require_appSlice_constants = require("./appSlice/constants.cjs");
4
4
  const require_constants = require("./constants-C_SC_VKE.cjs");
5
5
  const require_onboardingSlice_constants = require("./onboardingSlice/constants.cjs");
@@ -201,7 +201,6 @@ const cleanPhases = (phases) => phases?.map(({ batch_size, batch_size_devices, s
201
201
  batch_size_devices,
202
202
  start_ts
203
203
  }));
204
- const MAX_PREVIOUS_PHASES_COUNT = 5;
205
204
  const createDeployment = require_store.createAppAsyncThunk(`${require_deploymentsSlice_index.sliceName}/createDeployment`, ({ newDeployment }, { dispatch, getState }) => {
206
205
  let request;
207
206
  const { name, artifact_name, retries, update_control_map, autogenerate_delta } = newDeployment;
@@ -270,7 +269,7 @@ const createDeployment = require_store.createAppAsyncThunk(`${require_deployment
270
269
  const standardPhases = (0, _northern_tech_utils_helpers.standardizePhases)(uniform_phases ? [uniform_phases] : phases);
271
270
  const prevPhases = previousPhases.map(_northern_tech_utils_helpers.standardizePhases);
272
271
  if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => (0, _northern_tech_utils_helpers.deepCompare)(phase, oldPhase))))) prevPhases.push(standardPhases);
273
- newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
272
+ newSettings.previousPhases = prevPhases.slice(-5);
274
273
  }
275
274
  tasks.push(dispatch(saveGlobalSettings(newSettings)));
276
275
  }
@@ -495,14 +494,6 @@ const defaultAttributes = [
495
494
  scope: "inventory",
496
495
  attribute: "device_type"
497
496
  },
498
- {
499
- scope: "inventory",
500
- attribute: "mender_is_gateway"
501
- },
502
- {
503
- scope: "inventory",
504
- attribute: "mender_gateway_system_id"
505
- },
506
497
  {
507
498
  scope: "inventory",
508
499
  attribute: require_releasesSlice_constants.rootfsImageVersion
@@ -602,7 +593,8 @@ const addStaticGroup = require_store.createAppAsyncThunk(`${require_devicesSlice
602
593
  })).catch((err) => require_store.commonErrorHandler(err, `Group could not be updated:`, dispatch)));
603
594
  const removeReportsByGroupName = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/removeReportsByGroupName`, (groupName, { dispatch, getState }) => {
604
595
  if (!groupName) return Promise.resolve();
605
- dispatch(saveUserSettings({ reports: require_commonSelectors.getDeviceReportsForUser(getState()).filter((report) => report.group !== groupName) }));
596
+ const filteredReports = require_commonSelectors.getDeviceReportsForUser(getState()).filter((report) => report.group !== groupName);
597
+ dispatch(saveUserSettings({ reports: filteredReports }));
606
598
  });
607
599
  const removeStaticGroup = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/removeStaticGroup`, (groupName, { dispatch }) => require_api_general_api.default.delete(`${_northern_tech_utils_constants.inventoryApiUrl}/groups/${groupName}`).then(() => Promise.all([
608
600
  dispatch(require_devicesSlice_index.actions.removeGroup(groupName)),
@@ -882,11 +874,6 @@ const getTestDeviceCount = require_store.createAppAsyncThunk(`${require_devicesS
882
874
  attribute: "test_device",
883
875
  type: _northern_tech_utils_constants.DEVICE_FILTERING_OPTIONS.$eq.key,
884
876
  value: "true"
885
- }, {
886
- scope: "identity",
887
- attribute: "status",
888
- type: _northern_tech_utils_constants.DEVICE_FILTERING_OPTIONS.$eq.key,
889
- value: _northern_tech_utils_constants.DEVICE_STATES.accepted
890
877
  }],
891
878
  attributes: [{
892
879
  scope: "identity",
@@ -1205,7 +1192,8 @@ const getSnackbarMessage = (skipped, done, failed = 0) => {
1205
1192
  return `${done ? `${done} ${(0, pluralize.default)("device", done)} ${(0, pluralize.default)("was", done)} updated successfully. ` : ""}${skipText}${failedText}`;
1206
1193
  };
1207
1194
  const updateDeviceAuth = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/updateDeviceAuth`, ({ deviceId, authId, status }, { dispatch, getState }) => require_api_general_api.default.put(`${_northern_tech_utils_constants.deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar$2("Device authorization status was updated successfully"))])).catch((err) => {
1208
- return require_store.commonErrorHandler(err, err.response?.status === 422 ? "Device limit reached: You have reached your limit of accepted devices." : "There was a problem updating the device authorization status:", dispatch);
1195
+ const errorContext = err.response?.status === 422 ? "Device limit reached: You have reached your limit of accepted devices." : "There was a problem updating the device authorization status:";
1196
+ return require_store.commonErrorHandler(err, errorContext, dispatch);
1209
1197
  }).then(() => Promise.resolve(dispatch(require_devicesSlice_index.actions.maybeUpdateDevicesByStatus({
1210
1198
  deviceId,
1211
1199
  authId
@@ -1365,93 +1353,10 @@ const prepareSearchArguments = ({ filters, group, state, status }) => {
1365
1353
  filterTerms
1366
1354
  };
1367
1355
  };
1368
- const getSystemDevices = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/getSystemDevices`, (options, { dispatch, getState }) => {
1369
- const { id, page = defaultPage$1, perPage = defaultPerPage$1, sortOptions = [] } = options;
1370
- const state = getState();
1371
- const { hasFullFiltering } = require_commonSelectors.getTenantCapabilities(state);
1372
- if (!hasFullFiltering) return Promise.resolve();
1373
- const { attributes: deviceAttributes = {} } = require_devicesSlice_selectors.getDeviceById(state, id);
1374
- const { mender_gateway_system_id = "" } = deviceAttributes;
1375
- const filters = [{
1376
- ...require_constants.emptyFilter,
1377
- key: "mender_is_gateway",
1378
- operator: _northern_tech_utils_constants.DEVICE_FILTERING_OPTIONS.$ne.key,
1379
- value: "true",
1380
- scope: "inventory"
1381
- }, {
1382
- ...require_constants.emptyFilter,
1383
- key: "mender_gateway_system_id",
1384
- value: mender_gateway_system_id,
1385
- scope: "inventory"
1386
- }];
1387
- const { attributes, filterTerms } = prepareSearchArguments({
1388
- filters,
1389
- state
1390
- });
1391
- return require_api_general_api.default.post(`${_northern_tech_utils_constants.inventoryApiUrlV2}/filters/search`, {
1392
- page,
1393
- per_page: perPage,
1394
- filters: filterTerms,
1395
- sort: sortOptions,
1396
- attributes
1397
- }).catch((err) => require_store.commonErrorHandler(err, `There was an error getting system devices device ${id}.`, dispatch, "Please check your connection.")).then(({ data, headers }) => {
1398
- const state = getState();
1399
- const { devicesById, ids } = reduceReceivedDevices(data, [], state);
1400
- const device = {
1401
- ...require_devicesSlice_selectors.getDeviceById(state, id),
1402
- systemDeviceIds: ids,
1403
- systemDeviceTotal: Number(headers[_northern_tech_utils_constants.headerNames.total])
1404
- };
1405
- return Promise.resolve(dispatch(require_devicesSlice_index.actions.receivedDevices({
1406
- ...devicesById,
1407
- [id]: device
1408
- })));
1409
- });
1410
- });
1411
- const getGatewayDevices = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
1412
- const state = getState();
1413
- const { attributes = {} } = require_devicesSlice_selectors.getDeviceById(state, deviceId);
1414
- const { mender_gateway_system_id = "" } = attributes;
1415
- const filters = [
1416
- {
1417
- ...require_constants.emptyFilter,
1418
- key: "id",
1419
- operator: _northern_tech_utils_constants.DEVICE_FILTERING_OPTIONS.$ne.key,
1420
- value: deviceId,
1421
- scope: "identity"
1422
- },
1423
- {
1424
- ...require_constants.emptyFilter,
1425
- key: "mender_is_gateway",
1426
- value: "true",
1427
- scope: "inventory"
1428
- },
1429
- {
1430
- ...require_constants.emptyFilter,
1431
- key: "mender_gateway_system_id",
1432
- value: mender_gateway_system_id,
1433
- scope: "inventory"
1434
- }
1435
- ];
1436
- const { attributes: attributeSelection, filterTerms } = prepareSearchArguments({
1437
- filters,
1438
- state
1439
- });
1440
- return require_api_general_api.default.post(`${_northern_tech_utils_constants.inventoryApiUrlV2}/filters/search`, {
1441
- page: 1,
1442
- per_page: 500,
1443
- filters: filterTerms,
1444
- attributes: attributeSelection
1445
- }).then(({ data }) => {
1446
- const { ids } = reduceReceivedDevices(data, [], getState());
1447
- const tasks = ids.map((deviceId) => dispatch(getDeviceInfo(deviceId)));
1448
- tasks.push(Promise.resolve(dispatch(require_devicesSlice_index.actions.receivedDevice({
1449
- id: deviceId,
1450
- gatewayIds: ids
1451
- }))));
1452
- return Promise.all(tasks);
1453
- });
1454
- });
1356
+ const getDeviceComponents = require_store.createAppAsyncThunk(`${require_devicesSlice_index.sliceName}/getDeviceComponents`, (deviceId, { dispatch }) => require_api_general_api.default.get(`${_northern_tech_utils_constants.inventoryApiUrlV2alpha1}/devices/${deviceId}/components`).then(({ data }) => dispatch(require_devicesSlice_index.actions.receivedDevice({
1357
+ id: deviceId,
1358
+ components: data
1359
+ }))).catch((err) => require_store.commonErrorHandler(err, `There was an error retrieving components for device ${deviceId}.`, dispatch, require_store.commonErrorFallback)));
1455
1360
  //#endregion
1456
1361
  //#region src/onboardingSlice/thunks.ts
1457
1362
  const cookies$2 = new universal_cookie.default();
@@ -1790,7 +1695,8 @@ const setTenantsListState = require_store.createAppAsyncThunk(`${require_organiz
1790
1695
  return dispatch(require_organizationSlice_index.actions.setTenantListState({ ...nextState }));
1791
1696
  });
1792
1697
  const editTenant = require_store.createAppAsyncThunk(`${require_organizationSlice_index.sliceName}/editDeviceLimit`, ({ deviceLimits, id, name }, { dispatch, getState }) => {
1793
- const device_limits = require_utils.convertToBackendSPLimits(deviceLimits, require_organizationSlice_selectors.getSpLimits(getState()));
1698
+ const spLimits = require_organizationSlice_selectors.getSpLimits(getState());
1699
+ const device_limits = require_utils.convertToBackendSPLimits(deviceLimits, spLimits);
1794
1700
  return require_api_general_api.default.put(`${_northern_tech_utils_constants.tenantadmApiUrlv2}/tenants/${id}/child`, {
1795
1701
  device_limits,
1796
1702
  name
@@ -1999,7 +1905,8 @@ const loginUser = require_store.createAppAsyncThunk(`${require_usersSlice_index.
1999
1905
  }).then(({ text: token, contentType }) => {
2000
1906
  if (contentType?.includes(_northern_tech_utils_constants.APPLICATION_JSON_CONTENT_TYPE)) {
2001
1907
  const { id, kind } = token;
2002
- const ssoLoginUrl = require_constants.SSO_TYPES[kind.split("/")[1]].getStartUrl(id);
1908
+ const type = kind.split("/")[1];
1909
+ const ssoLoginUrl = require_constants.SSO_TYPES[type].getStartUrl(id);
2003
1910
  window.location.replace(ssoLoginUrl);
2004
1911
  return;
2005
1912
  }
@@ -2035,9 +1942,7 @@ const passwordResetComplete = require_store.createAppAsyncThunk(`${require_users
2035
1942
  password: newPassword
2036
1943
  }).catch((err = {}) => {
2037
1944
  const { error, response = {} } = err;
2038
- let errorMsg = "";
2039
- if (response.status == 400) errorMsg = "the link you are using expired or the request is not valid, please try again.";
2040
- else errorMsg = error;
1945
+ const errorMsg = response.status == 400 ? "the link you are using expired or the request is not valid, please try again." : error;
2041
1946
  dispatch(setSnackbar("The password reset request cannot be processed: " + errorMsg));
2042
1947
  return Promise.reject(err);
2043
1948
  }));
@@ -2594,6 +2499,7 @@ exports.getDeviceAlerts = require_monitorSlice_thunks.getDeviceAlerts;
2594
2499
  exports.getDeviceAttributes = getDeviceAttributes;
2595
2500
  exports.getDeviceAuth = getDeviceAuth;
2596
2501
  exports.getDeviceById = getDeviceById;
2502
+ exports.getDeviceComponents = getDeviceComponents;
2597
2503
  exports.getDeviceConfig = getDeviceConfig;
2598
2504
  exports.getDeviceConnect = getDeviceConnect;
2599
2505
  exports.getDeviceDeployments = getDeviceDeployments;
@@ -2610,7 +2516,6 @@ exports.getDynamicGroups = getDynamicGroups;
2610
2516
  exports.getExistingManifestTags = require_releasesSlice_thunks.getExistingManifestTags;
2611
2517
  exports.getExistingReleaseTags = require_releasesSlice_thunks.getExistingReleaseTags;
2612
2518
  exports.getExistingSoftwareTags = require_releasesSlice_thunks.getExistingSoftwareTags;
2613
- exports.getGatewayDevices = getGatewayDevices;
2614
2519
  exports.getGlobalSettings = getGlobalSettings;
2615
2520
  exports.getGroupDevices = getGroupDevices;
2616
2521
  exports.getGroups = getGroups;
@@ -2633,7 +2538,6 @@ exports.getSoftware = require_releasesSlice_thunks.getSoftware;
2633
2538
  exports.getSoftwareList = require_releasesSlice_thunks.getSoftwareList;
2634
2539
  exports.getSsoConfigById = getSsoConfigById;
2635
2540
  exports.getSsoConfigs = getSsoConfigs;
2636
- exports.getSystemDevices = getSystemDevices;
2637
2541
  exports.getTargetLocation = getTargetLocation;
2638
2542
  exports.getTenants = getTenants;
2639
2543
  exports.getTestDeviceCount = getTestDeviceCount;