@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.js
CHANGED
|
@@ -22,7 +22,7 @@ import Api from "./api/general-api.js";
|
|
|
22
22
|
import { changeNotificationSetting, getDeviceAlerts, getDeviceMonitorConfig, getIssueCountsByType, getLatestDeviceAlerts } from "./monitorSlice/thunks.js";
|
|
23
23
|
import { cancelFileUpload, checkReleasesExistence, createArtifact, editArtifact, generateManifest, getArtifactInstallCount, getArtifactUrl, getDeltaGenerationJobDetails, getDeltaGenerationJobs, getExistingManifestTags, getExistingReleaseTags, getExistingSoftwareTags, getManifest, getManifests, getRelease, getReleases, getSoftware, getSoftwareList, getUpdateTypes, removeArtifact, removeManifest, removeManifests, removeRelease, removeReleases, selectManifest, selectRelease, setManifestsListState, setReleaseTags, setReleasesListState, setReleasesTags, setSingleReleaseTags, setSoftwareListState, updateManifestInfo, updateReleaseInfo, uploadArtifact, uploadManifest } from "./releasesSlice/thunks.js";
|
|
24
24
|
import Api$1 from "./api/users-api.js";
|
|
25
|
-
import { attributeDuplicateFilter, customSort, dateRangeToUnix, deepCompare, duplicateFilter, extractErrorMessage, getDemoDeviceAddress,
|
|
25
|
+
import { attributeDuplicateFilter, customSort, dateRangeToUnix, deepCompare, duplicateFilter, extractErrorMessage, getDemoDeviceAddress, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
|
|
26
26
|
import Cookies from "universal-cookie";
|
|
27
27
|
import dayjs from "dayjs";
|
|
28
28
|
import Tracking from "@northern.tech/utils/tracking";
|
|
@@ -709,7 +709,8 @@ const reduceReceivedDevices = (devices, ids, state, status) => devices.reduce((a
|
|
|
709
709
|
device.created_ts = getEarliestTs(getEarliestTs(system.created_ts, device.created_ts), stateDevice.created_ts);
|
|
710
710
|
device.updated_ts = device.attributes ? device.updated_ts : stateDevice.updated_ts;
|
|
711
711
|
device.isNew = new Date(device.created_ts) > new Date(state.app.newThreshold);
|
|
712
|
-
|
|
712
|
+
const lastCheckIn = device.check_in_time_exact ?? device.check_in_time_rounded;
|
|
713
|
+
device.isOffline = new Date(lastCheckIn) < new Date(state.app.offlineThreshold) || lastCheckIn === void 0;
|
|
713
714
|
device.attributes = device.attributes ? {
|
|
714
715
|
...storedAttributes,
|
|
715
716
|
...inventory
|
|
@@ -1181,7 +1182,15 @@ const getDevicesWithAuth = createAppAsyncThunk(`${sliceName$2}/getDevicesWithAut
|
|
|
1181
1182
|
dispatch(actions$2.receivedDevices(devicesById));
|
|
1182
1183
|
return receivedDevices;
|
|
1183
1184
|
});
|
|
1184
|
-
const
|
|
1185
|
+
const getSnackbarMessage = (skipped, done, failed = 0) => {
|
|
1186
|
+
pluralize.addIrregularRule("its", "their");
|
|
1187
|
+
const skipText = skipped ? `${skipped} ${pluralize("devices", skipped)} ${pluralize("have", skipped)} more than one pending authset. Expand ${pluralize("this", skipped)} ${pluralize("device", skipped)} to individually adjust ${pluralize("their", skipped)} authorization status. ` : "";
|
|
1188
|
+
const failedText = failed ? `${failed} ${pluralize("device", failed)} could not be updated. You may have reached your device limit. ` : "";
|
|
1189
|
+
return `${done ? `${done} ${pluralize("device", done)} ${pluralize("was", done)} updated successfully. ` : ""}${skipText}${failedText}`;
|
|
1190
|
+
};
|
|
1191
|
+
const updateDeviceAuth = createAppAsyncThunk(`${sliceName$2}/updateDeviceAuth`, ({ deviceId, authId, status }, { dispatch, getState }) => Api.put(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar$2("Device authorization status was updated successfully"))])).catch((err) => {
|
|
1192
|
+
return 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);
|
|
1193
|
+
}).then(() => Promise.resolve(dispatch(actions$2.maybeUpdateDevicesByStatus({
|
|
1185
1194
|
deviceId,
|
|
1186
1195
|
authId
|
|
1187
1196
|
})))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getDeviceListState(getState()).refreshTrigger }))));
|
|
@@ -1199,15 +1208,17 @@ const updateDevicesAuth = createAppAsyncThunk(`${sliceName$2}/updateDevicesAuth`
|
|
|
1199
1208
|
})).unwrap().catch((err) => commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
|
|
1200
1209
|
});
|
|
1201
1210
|
return Promise.allSettled(deviceAuthUpdates).then((results) => {
|
|
1202
|
-
const { skipped, count } = results.reduce((accu, item) => {
|
|
1203
|
-
if (item.status === "rejected") accu.
|
|
1211
|
+
const { skipped, failed, count } = results.reduce((accu, item) => {
|
|
1212
|
+
if (item.status === "rejected") if (item.reason) accu.failed = accu.failed + 1;
|
|
1213
|
+
else accu.skipped = accu.skipped + 1;
|
|
1204
1214
|
else accu.count = accu.count + 1;
|
|
1205
1215
|
return accu;
|
|
1206
1216
|
}, {
|
|
1207
1217
|
skipped: 0,
|
|
1218
|
+
failed: 0,
|
|
1208
1219
|
count: 0
|
|
1209
1220
|
});
|
|
1210
|
-
return dispatch(setSnackbar$2(getSnackbarMessage(skipped, count)));
|
|
1221
|
+
return dispatch(setSnackbar$2(getSnackbarMessage(skipped, count, failed)));
|
|
1211
1222
|
});
|
|
1212
1223
|
});
|
|
1213
1224
|
});
|