• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 944676341

pending completion
944676341

Pull #3875

gitlab-ci

mzedel
chore: aligned snapshots with updated design

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3875: MEN-5414

4469 of 6446 branches covered (69.33%)

230 of 266 new or added lines in 43 files covered. (86.47%)

1712 existing lines in 161 files now uncovered.

8406 of 10170 relevant lines covered (82.65%)

196.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.24
/src/js/selectors/index.js
1
// Copyright 2020 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import { createSelector } from '@reduxjs/toolkit';
15

16
import { defaultReports } from '../actions/deviceActions';
17
import { mapUserRolesToUiPermissions } from '../actions/userActions';
18
import { PLANS } from '../constants/appConstants';
19
import { DEPLOYMENT_STATES } from '../constants/deploymentConstants';
20
import {
21
  ALL_DEVICES,
22
  ATTRIBUTE_SCOPES,
23
  DEVICE_ISSUE_OPTIONS,
24
  DEVICE_LIST_MAXIMUM_LENGTH,
25
  DEVICE_ONLINE_CUTOFF,
26
  DEVICE_STATES,
27
  EXTERNAL_PROVIDER,
28
  UNGROUPED_GROUP
29
} from '../constants/deviceConstants';
30
import { rolesByName, twoFAStates, uiPermissionsById } from '../constants/userConstants';
31
import { attributeDuplicateFilter, duplicateFilter, getDemoDeviceAddress as getDemoDeviceAddressHelper, versionCompare } from '../helpers';
32

33
const getAppDocsVersion = state => state.app.docsVersion;
1,392✔
34
export const getFeatures = state => state.app.features;
18,246✔
35
const getTooltipsById = state => state.users.tooltips.byId;
1,462✔
36
export const getRolesById = state => state.users.rolesById;
1,608✔
37
export const getOrganization = state => state.organization.organization;
6,711✔
38
export const getAcceptedDevices = state => state.devices.byStatus.accepted;
7,490✔
39
const getDevicesByStatus = state => state.devices.byStatus;
1,442✔
40
export const getDevicesById = state => state.devices.byId;
10,918✔
41
export const getDeviceReports = state => state.devices.reports;
3,561✔
42
export const getGroupsById = state => state.devices.groups.byId;
2,925✔
43
const getSelectedGroup = state => state.devices.groups.selectedGroup;
187✔
44
const getSearchedDevices = state => state.app.searchState.deviceIds;
1,043✔
45
const getListedDevices = state => state.devices.deviceList.deviceIds;
187✔
46
const getFilteringAttributes = state => state.devices.filteringAttributes;
1,184✔
47
export const getDeviceFilters = state => state.devices.filters || [];
202!
48
const getFilteringAttributesFromConfig = state => state.devices.filteringAttributesConfig.attributes;
1,150✔
49
export const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({
187✔
50
  ...filteringAttributes,
51
  identityAttributes: [...filteringAttributes.identityAttributes, 'id']
52
}));
53
export const getDeviceLimit = state => state.devices.limit;
1,998✔
54
const getDevicesList = state => Object.values(state.devices.byId);
187✔
55
const getOnboarding = state => state.onboarding;
1,548✔
56
export const getShowHelptips = state => state.users.showHelptips;
11,868✔
57
export const getGlobalSettings = state => state.users.globalSettings;
3,722✔
58
const getIssueCountsByType = state => state.monitor.issueCounts.byType;
1,158✔
59
export const getReleasesById = state => state.releases.byId;
1,913✔
60
const getReleaseTags = state => state.releases.releaseTags;
187✔
61
const getListedReleases = state => state.releases.releasesList.releaseIds;
187✔
62
export const getExternalIntegrations = state => state.organization.externalDeviceIntegrations;
187✔
63
const getDeploymentsById = state => state.deployments.byId;
2,609✔
64
export const getDeploymentsByStatus = state => state.deployments.byStatus;
1,926✔
65
export const getVersionInformation = state => state.app.versionInformation;
1,178✔
66
const getCurrentUserId = state => state.users.currentUser;
2,785✔
67
const getUsersById = state => state.users.byId;
1,635✔
68
export const getCurrentUser = createSelector([getUsersById, getCurrentUserId], (usersById, userId) => usersById[userId] ?? {});
187✔
69
export const getUserSettings = state => state.users.userSettings;
10,656✔
70
export const getIsPreview = createSelector([getVersionInformation], ({ Integration }) => versionCompare(Integration, 'next') > -1);
187✔
71

72
export const getDeploymentsSelectionState = state => state.deployments.selectionState;
2,197✔
73

74
export const getMappedDeploymentSelection = createSelector(
187✔
75
  [getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],
1,171✔
76
  (selectionState, deploymentsState, deploymentsById) => {
77
    const { selection = [] } = selectionState[deploymentsState] ?? {};
1,140!
78
    return selection.reduce((accu, id) => {
1,140✔
79
      if (deploymentsById[id]) {
2,078!
80
        accu.push(deploymentsById[id]);
2,078✔
81
      }
82
      return accu;
2,078✔
83
    }, []);
84
  }
85
);
86

87
export const getDeploymentRelease = createSelector(
187✔
88
  [getDeploymentsById, getDeploymentsSelectionState, getReleasesById],
89
  (deploymentsById, { selectedId }, releasesById) => {
90
    const deployment = deploymentsById[selectedId] || {};
150✔
91
    return deployment.artifact_name && releasesById[deployment.artifact_name] ? releasesById[deployment.artifact_name] : { device_types_compatible: [] };
150✔
92
  }
93
);
94

95
export const getHas2FA = createSelector(
187✔
96
  [getCurrentUser],
97
  currentUser => currentUser.hasOwnProperty('tfa_status') && currentUser.tfa_status === twoFAStates.enabled
5✔
98
);
99

100
export const getDemoDeviceAddress = createSelector([getDevicesList, getOnboarding], (devices, { approach, demoArtifactPort }) => {
187✔
101
  const demoDeviceAddress = `http://${getDemoDeviceAddressHelper(devices, approach)}`;
6✔
102
  return demoArtifactPort ? `${demoDeviceAddress}:${demoArtifactPort}` : demoDeviceAddress;
6!
103
});
104

105
export const getDeviceReportsForUser = createSelector(
187✔
106
  [getUserSettings, getCurrentUserId, getGlobalSettings, getDevicesById],
107
  ({ reports }, currentUserId, globalSettings, devicesById) => {
108
    return reports || globalSettings[`${currentUserId}-reports`] || (Object.keys(devicesById).length ? defaultReports : []);
49✔
109
  }
110
);
111

112
const listItemMapper = (byId, ids, { defaultObject = {}, cutOffSize = DEVICE_LIST_MAXIMUM_LENGTH }) => {
187✔
113
  return ids.slice(0, cutOffSize).reduce((accu, id) => {
1,104✔
114
    if (id && byId[id]) {
270!
115
      accu.push({ ...defaultObject, ...byId[id] });
270✔
116
    }
117
    return accu;
270✔
118
  }, []);
119
};
120

121
const listTypeDeviceIdMap = {
187✔
122
  deviceList: getListedDevices,
123
  search: getSearchedDevices
124
};
125
const getDeviceMappingDefaults = () => ({ defaultObject: { auth_sets: [] }, cutOffSize: DEVICE_LIST_MAXIMUM_LENGTH });
1,071✔
126
export const getMappedDevicesList = createSelector(
187✔
127
  [getDevicesById, (state, listType) => listTypeDeviceIdMap[listType](state), getDeviceMappingDefaults],
1,071✔
128
  listItemMapper
129
);
130

131
export const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>
187✔
132
  Object.values(DEVICE_STATES).reduce((accu, state) => {
412✔
133
    accu[state] = byStatus[state].total || 0;
1,648✔
134
    return accu;
1,648✔
135
  }, {})
136
);
137

138
export const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});
1,529✔
139

140
export const getDeviceConfigDeployment = createSelector([getDeviceById, getDeploymentsById], (device, deploymentsById) => {
187✔
141
  const { config = {} } = device;
5✔
142
  const { deployment_id: configDeploymentId } = config;
5✔
143
  const deviceConfigDeployment = deploymentsById[configDeploymentId] || {};
5✔
144
  return { device, deviceConfigDeployment };
5✔
145
});
146

147
export const getSelectedGroupInfo = createSelector(
187✔
148
  [getAcceptedDevices, getGroupsById, getSelectedGroup],
149
  ({ total: acceptedDeviceTotal }, groupsById, selectedGroup) => {
150
    let groupCount = acceptedDeviceTotal;
7✔
151
    let groupFilters = [];
7✔
152
    if (selectedGroup && groupsById[selectedGroup]) {
7✔
153
      groupCount = groupsById[selectedGroup].total;
2✔
154
      groupFilters = groupsById[selectedGroup].filters || [];
2!
155
    }
156
    return { groupCount, selectedGroup, groupFilters };
7✔
157
  }
158
);
159

160
const defaultIdAttribute = Object.freeze({ attribute: 'id', scope: ATTRIBUTE_SCOPES.identity });
187✔
161
export const getIdAttribute = createSelector([getGlobalSettings], ({ id_attribute = { ...defaultIdAttribute } }) => id_attribute);
187✔
162

163
export const getLimitMaxed = createSelector([getAcceptedDevices, getDeviceLimit], ({ total: acceptedDevices = 0 }, deviceLimit) =>
187!
164
  Boolean(deviceLimit && deviceLimit <= acceptedDevices)
7✔
165
);
166

167
export const getFilterAttributes = createSelector(
187✔
168
  [getGlobalSettings, getFilteringAttributes],
169
  ({ previousFilters }, { identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }) => {
170
    const deviceNameAttribute = { key: 'name', value: 'Name', scope: ATTRIBUTE_SCOPES.tags, category: ATTRIBUTE_SCOPES.tags, priority: 1 };
4✔
171
    const deviceIdAttribute = { key: 'id', value: 'Device ID', scope: ATTRIBUTE_SCOPES.identity, category: ATTRIBUTE_SCOPES.identity, priority: 1 };
4✔
172
    const checkInAttribute = { key: 'check_in_time', value: 'Latest activity', scope: ATTRIBUTE_SCOPES.system, category: ATTRIBUTE_SCOPES.system, priority: 4 };
4✔
173
    const updateAttribute = { ...checkInAttribute, key: 'updated_ts', value: 'Last inventory update' };
4✔
174
    const firstRequestAttribute = { key: 'created_ts', value: 'First request', scope: ATTRIBUTE_SCOPES.system, category: ATTRIBUTE_SCOPES.system, priority: 4 };
4✔
175
    const attributes = [
4✔
UNCOV
176
      ...previousFilters.map(item => ({
×
177
        ...item,
178
        value: deviceIdAttribute.key === item.key ? deviceIdAttribute.value : item.key,
×
179
        category: 'recently used',
180
        priority: 0
181
      })),
182
      deviceNameAttribute,
183
      deviceIdAttribute,
184
      ...identityAttributes.map(item => ({ key: item, value: item, scope: ATTRIBUTE_SCOPES.identity, category: ATTRIBUTE_SCOPES.identity, priority: 1 })),
5✔
185
      ...inventoryAttributes.map(item => ({ key: item, value: item, scope: ATTRIBUTE_SCOPES.inventory, category: ATTRIBUTE_SCOPES.inventory, priority: 2 })),
18✔
UNCOV
186
      ...tagAttributes.map(item => ({ key: item, value: item, scope: ATTRIBUTE_SCOPES.tags, category: ATTRIBUTE_SCOPES.tags, priority: 3 })),
×
187
      checkInAttribute,
188
      updateAttribute,
189
      firstRequestAttribute,
190
      ...systemAttributes.map(item => ({ key: item, value: item, scope: ATTRIBUTE_SCOPES.system, category: ATTRIBUTE_SCOPES.system, priority: 4 }))
3✔
191
    ];
192
    return attributeDuplicateFilter(attributes, 'key');
4✔
193
  }
194
);
195

196
// eslint-disable-next-line no-unused-vars
197
export const getGroupsByIdWithoutUngrouped = createSelector([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);
187✔
198

199
export const getGroups = createSelector([getGroupsById], groupsById => {
187✔
200
  const groupNames = Object.keys(groupsById).sort();
13✔
201
  const groupedGroups = Object.entries(groupsById)
13✔
202
    .sort((a, b) => a[0].localeCompare(b[0]))
44✔
203
    .reduce(
204
      (accu, [groupname, group]) => {
205
        const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;
37✔
206
        const groupItem = { ...group, groupId: name, name: groupname };
37✔
207
        if (group.filters.length > 0) {
37✔
208
          if (groupname !== UNGROUPED_GROUP.id) {
24✔
209
            accu.dynamic.push(groupItem);
13✔
210
          } else {
211
            accu.ungrouped.push(groupItem);
11✔
212
          }
213
        } else {
214
          accu.static.push(groupItem);
13✔
215
        }
216
        return accu;
37✔
217
      },
218
      { dynamic: [], static: [], ungrouped: [] }
219
    );
220
  return { groupNames, ...groupedGroups };
13✔
221
});
222

223
export const getDeviceTwinIntegrations = createSelector([getExternalIntegrations], integrations =>
187✔
224
  integrations.filter(integration => integration.id && EXTERNAL_PROVIDER[integration.provider]?.deviceTwin)
4✔
225
);
226

227
export const getOfflineThresholdSettings = createSelector([getGlobalSettings], ({ offlineThreshold }) => ({
187✔
228
  interval: offlineThreshold?.interval || DEVICE_ONLINE_CUTOFF.interval,
26✔
229
  intervalUnit: offlineThreshold?.intervalUnit || DEVICE_ONLINE_CUTOFF.intervalName
26✔
230
}));
231

232
export const getOnboardingState = createSelector(
187✔
233
  [getOnboarding, getShowHelptips, getUserSettings],
234
  ({ complete, progress, showTips, ...remainder }, showHelptips, { onboarding = {} }) => ({
99!
235
    showHelptips,
236
    ...remainder,
237
    ...onboarding,
238
    complete,
239
    progress,
240
    showTips
241
  })
242
);
243

244
export const getTooltipsState = createSelector([getTooltipsById, getUserSettings], (byId, { tooltips = {} }) =>
187✔
245
  Object.entries(byId).reduce(
56✔
246
    (accu, [id, value]) => {
NEW
247
      accu[id] = { ...accu[id], ...value };
×
NEW
248
      return accu;
×
249
    },
250
    { ...tooltips }
251
  )
252
);
253

254
export const getDocsVersion = createSelector([getAppDocsVersion, getFeatures], (appDocsVersion, { isHosted }) => {
187✔
255
  // if hosted, use latest docs version
256
  const docsVersion = appDocsVersion ? `${appDocsVersion}/` : 'development/';
44!
257
  return isHosted ? '' : docsVersion;
44✔
258
});
259

260
export const getIsEnterprise = createSelector(
187✔
261
  [getOrganization, getFeatures],
262
  ({ plan = PLANS.os.id }, { isEnterprise, isHosted }) => isEnterprise || (isHosted && plan === PLANS.enterprise.id)
79✔
263
);
264

265
export const getAttributesList = createSelector(
187✔
266
  [getFilteringAttributes, getFilteringAttributesFromConfig],
267
  ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>
40!
268
    [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)
20✔
269
);
270

271
export const getRolesList = createSelector([getRolesById], rolesById => Object.entries(rolesById).map(([id, role]) => ({ id, ...role })));
187✔
272

273
export const getUserRoles = createSelector(
187✔
274
  [getCurrentUser, getRolesById, getIsEnterprise, getFeatures, getOrganization],
275
  (currentUser, rolesById, isEnterprise, { isHosted, hasMultitenancy }, { plan = PLANS.os.id }) => {
9✔
276
    const isAdmin = currentUser.roles?.length
67✔
277
      ? currentUser.roles.some(role => role === rolesByName.admin)
60✔
278
      : !(hasMultitenancy || isEnterprise || (isHosted && plan !== PLANS.os.id));
15!
279
    const uiPermissions = isAdmin
67✔
280
      ? mapUserRolesToUiPermissions([rolesByName.admin], rolesById)
281
      : mapUserRolesToUiPermissions(currentUser.roles || [], rolesById);
6✔
282
    return { isAdmin, uiPermissions };
67✔
283
  }
284
);
285

286
const hasPermission = (thing, permission) => Object.values(thing).some(permissions => permissions.includes(permission));
309✔
287

288
export const getUserCapabilities = createSelector([getUserRoles], ({ uiPermissions }) => {
187✔
289
  const canManageReleases = hasPermission(uiPermissions.releases, uiPermissionsById.manage.value);
60✔
290
  const canReadReleases = canManageReleases || hasPermission(uiPermissions.releases, uiPermissionsById.read.value);
60✔
291
  const canUploadReleases = canManageReleases || hasPermission(uiPermissions.releases, uiPermissionsById.upload.value);
60✔
292

293
  const canAuditlog = uiPermissions.auditlog.includes(uiPermissionsById.read.value);
60✔
294

295
  const canReadUsers = uiPermissions.userManagement.includes(uiPermissionsById.read.value);
60✔
296
  const canManageUsers = uiPermissions.userManagement.includes(uiPermissionsById.manage.value);
60✔
297

298
  const canReadDevices = hasPermission(uiPermissions.groups, uiPermissionsById.read.value);
60✔
299
  const canWriteDevices = Object.values(uiPermissions.groups).some(
60✔
300
    groupPermissions => groupPermissions.includes(uiPermissionsById.read.value) && groupPermissions.length > 1
57✔
301
  );
302
  const canTroubleshoot = hasPermission(uiPermissions.groups, uiPermissionsById.connect.value);
60✔
303
  const canManageDevices = hasPermission(uiPermissions.groups, uiPermissionsById.manage.value);
60✔
304
  const canConfigure = hasPermission(uiPermissions.groups, uiPermissionsById.configure.value);
60✔
305

306
  const canDeploy = uiPermissions.deployments.includes(uiPermissionsById.deploy.value) || hasPermission(uiPermissions.groups, uiPermissionsById.deploy.value);
60✔
307
  const canReadDeployments = uiPermissions.deployments.includes(uiPermissionsById.read.value);
60✔
308

309
  return {
60✔
310
    canAuditlog,
311
    canConfigure,
312
    canDeploy,
313
    canManageDevices,
314
    canManageReleases,
315
    canManageUsers,
316
    canReadDeployments,
317
    canReadDevices,
318
    canReadReleases,
319
    canReadUsers,
320
    canTroubleshoot,
321
    canUploadReleases,
322
    canWriteDevices,
323
    groupsPermissions: uiPermissions.groups,
324
    releasesPermissions: uiPermissions.releases
325
  };
326
});
327

328
export const getTenantCapabilities = createSelector(
187✔
329
  [getFeatures, getOrganization, getIsEnterprise],
330
  (
331
    {
332
      hasAddons,
333
      hasAuditlogs: isAuditlogEnabled,
334
      hasDeviceConfig: isDeviceConfigEnabled,
335
      hasDeviceConnect: isDeviceConnectEnabled,
336
      hasMonitor: isMonitorEnabled,
337
      isHosted
338
    },
339
    { addons = [], plan = PLANS.os.id },
12✔
340
    isEnterprise
341
  ) => {
342
    const canDelta = isEnterprise || plan === PLANS.professional.id;
48✔
343
    const hasAuditlogs = isAuditlogEnabled && (!isHosted || isEnterprise || plan === PLANS.professional.id);
48!
344
    const hasDeviceConfig = hasAddons || (isDeviceConfigEnabled && (!isHosted || addons.some(addon => addon.name === 'configure' && Boolean(addon.enabled))));
48!
345
    const hasDeviceConnect =
346
      hasAddons || (isDeviceConnectEnabled && (!isHosted || addons.some(addon => addon.name === 'troubleshoot' && Boolean(addon.enabled))));
48!
347
    const hasMonitor = hasAddons || (isMonitorEnabled && (!isHosted || addons.some(addon => addon.name === 'monitor' && Boolean(addon.enabled))));
48!
348
    return {
48✔
349
      canDelta,
350
      canRetry: canDelta,
351
      canSchedule: canDelta,
352
      hasAuditlogs,
353
      hasDeviceConfig,
354
      hasDeviceConnect,
355
      hasFullFiltering: canDelta,
356
      hasMonitor,
357
      isEnterprise,
358
      plan
359
    };
360
  }
361
);
362

363
export const getAvailableIssueOptionsByType = createSelector(
187✔
364
  [getFeatures, getTenantCapabilities, getIssueCountsByType],
365
  ({ hasReporting }, { hasFullFiltering, hasMonitor }, issueCounts) =>
366
    Object.values(DEVICE_ISSUE_OPTIONS).reduce((accu, { isCategory, key, needsFullFiltering, needsMonitor, needsReporting, title }) => {
17✔
367
      if (isCategory || (needsReporting && !hasReporting) || (needsFullFiltering && !hasFullFiltering) || (needsMonitor && !hasMonitor)) {
102✔
368
        return accu;
96✔
369
      }
370
      accu[key] = { count: issueCounts[key].filtered, key, title };
6✔
371
      return accu;
6✔
372
    }, {})
373
);
374

375
export const getDeviceTypes = createSelector([getAcceptedDevices, getDevicesById], ({ deviceIds = [] }, devicesById) =>
187!
376
  Object.keys(
1✔
377
    deviceIds.slice(0, 200).reduce((accu, item) => {
378
      const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};
2!
379
      accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {
2✔
380
        if (deviceType.length > 1) {
2!
381
          deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;
2!
382
        }
383
        return deviceTypeAccu;
2✔
384
      }, accu);
385
      return accu;
2✔
386
    }, {})
387
  )
388
);
389

390
export const getGroupNames = createSelector([getGroupsById, getUserRoles, (_, options = {}) => options], (groupsById, { uiPermissions }, { staticOnly }) => {
1,444✔
391
  // eslint-disable-next-line no-unused-vars
392
  const { [UNGROUPED_GROUP.id]: ungrouped, ...groups } = groupsById;
1,444✔
393
  if (staticOnly) {
1,444!
UNCOV
394
    return Object.keys(uiPermissions.groups).sort();
×
395
  }
396
  return Object.keys(
1,444✔
397
    Object.entries(groups).reduce((accu, [groupName, group]) => {
398
      if (group.filterId || uiPermissions.groups[ALL_DEVICES]) {
2,840✔
399
        accu[groupName] = group;
1,912✔
400
      }
401
      return accu;
2,840✔
402
    }, uiPermissions.groups)
403
  ).sort();
404
});
405

406
const getReleaseMappingDefaults = () => ({});
187✔
407
export const getReleasesList = createSelector([getReleasesById, getListedReleases, getReleaseMappingDefaults], listItemMapper);
187✔
408

409
export const getReleaseTagsById = createSelector([getReleaseTags], releaseTags => releaseTags.reduce((accu, key) => ({ ...accu, [key]: key }), {}));
187✔
410

411
const relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished];
187✔
412
export const DEPLOYMENT_CUTOFF = 3;
187✔
413
export const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>
187✔
414
  Object.entries(deploymentsByStatus).reduce(
409✔
415
    (accu, [state, byStatus]) => {
416
      if (!relevantDeploymentStates.includes(state) || !byStatus.deploymentIds.length) {
1,636✔
417
        return accu;
433✔
418
      }
419
      accu[state] = byStatus.deploymentIds
1,203✔
420
        .reduce((accu, id) => {
421
          if (deploymentsById[id]) {
2,340✔
422
            accu.push(deploymentsById[id]);
2,334✔
423
          }
424
          return accu;
2,340✔
425
        }, [])
426
        .slice(0, DEPLOYMENT_CUTOFF);
427
      accu.total += byStatus.total;
1,203✔
428
      return accu;
1,203✔
429
    },
430
    { total: 0 }
431
  )
432
);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc