@northern.tech/store 0.38.0 → 0.39.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.
- package/dist/thunks.cjs +16 -5
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.js +17 -6
- package/dist/thunks.js.map +1 -1
- package/package.json +3 -3
package/dist/thunks.cjs
CHANGED
|
@@ -719,7 +719,8 @@ const reduceReceivedDevices = (devices, ids, state, status) => devices.reduce((a
|
|
|
719
719
|
device.created_ts = getEarliestTs(getEarliestTs(system.created_ts, device.created_ts), stateDevice.created_ts);
|
|
720
720
|
device.updated_ts = device.attributes ? device.updated_ts : stateDevice.updated_ts;
|
|
721
721
|
device.isNew = new Date(device.created_ts) > new Date(state.app.newThreshold);
|
|
722
|
-
|
|
722
|
+
const lastCheckIn = device.check_in_time_exact ?? device.check_in_time_rounded;
|
|
723
|
+
device.isOffline = new Date(lastCheckIn) < new Date(state.app.offlineThreshold) || lastCheckIn === void 0;
|
|
723
724
|
device.attributes = device.attributes ? {
|
|
724
725
|
...storedAttributes,
|
|
725
726
|
...inventory
|
|
@@ -1191,7 +1192,15 @@ const getDevicesWithAuth = require_store.createAppAsyncThunk(`${require_devicesS
|
|
|
1191
1192
|
dispatch(require_devicesSlice_index.actions.receivedDevices(devicesById));
|
|
1192
1193
|
return receivedDevices;
|
|
1193
1194
|
});
|
|
1194
|
-
const
|
|
1195
|
+
const getSnackbarMessage = (skipped, done, failed = 0) => {
|
|
1196
|
+
pluralize.default.addIrregularRule("its", "their");
|
|
1197
|
+
const skipText = skipped ? `${skipped} ${(0, pluralize.default)("devices", skipped)} ${(0, pluralize.default)("have", skipped)} more than one pending authset. Expand ${(0, pluralize.default)("this", skipped)} ${(0, pluralize.default)("device", skipped)} to individually adjust ${(0, pluralize.default)("their", skipped)} authorization status. ` : "";
|
|
1198
|
+
const failedText = failed ? `${failed} ${(0, pluralize.default)("device", failed)} could not be updated. You may have reached your device limit. ` : "";
|
|
1199
|
+
return `${done ? `${done} ${(0, pluralize.default)("device", done)} ${(0, pluralize.default)("was", done)} updated successfully. ` : ""}${skipText}${failedText}`;
|
|
1200
|
+
};
|
|
1201
|
+
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) => {
|
|
1202
|
+
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);
|
|
1203
|
+
}).then(() => Promise.resolve(dispatch(require_devicesSlice_index.actions.maybeUpdateDevicesByStatus({
|
|
1195
1204
|
deviceId,
|
|
1196
1205
|
authId
|
|
1197
1206
|
})))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !require_devicesSlice_selectors.getDeviceListState(getState()).refreshTrigger }))));
|
|
@@ -1209,15 +1218,17 @@ const updateDevicesAuth = require_store.createAppAsyncThunk(`${require_devicesSl
|
|
|
1209
1218
|
})).unwrap().catch((err) => require_store.commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
|
|
1210
1219
|
});
|
|
1211
1220
|
return Promise.allSettled(deviceAuthUpdates).then((results) => {
|
|
1212
|
-
const { skipped, count } = results.reduce((accu, item) => {
|
|
1213
|
-
if (item.status === "rejected") accu.
|
|
1221
|
+
const { skipped, failed, count } = results.reduce((accu, item) => {
|
|
1222
|
+
if (item.status === "rejected") if (item.reason) accu.failed = accu.failed + 1;
|
|
1223
|
+
else accu.skipped = accu.skipped + 1;
|
|
1214
1224
|
else accu.count = accu.count + 1;
|
|
1215
1225
|
return accu;
|
|
1216
1226
|
}, {
|
|
1217
1227
|
skipped: 0,
|
|
1228
|
+
failed: 0,
|
|
1218
1229
|
count: 0
|
|
1219
1230
|
});
|
|
1220
|
-
return dispatch(setSnackbar$2(
|
|
1231
|
+
return dispatch(setSnackbar$2(getSnackbarMessage(skipped, count, failed)));
|
|
1221
1232
|
});
|
|
1222
1233
|
});
|
|
1223
1234
|
});
|