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

mendersoftware / gui / 988636826

01 Sep 2023 04:04AM UTC coverage: 82.384% (-17.6%) from 99.964%
988636826

Pull #3969

gitlab-ci

web-flow
chore: Bump autoprefixer from 10.4.14 to 10.4.15

Bumps [autoprefixer](https://github.com/postcss/autoprefixer) from 10.4.14 to 10.4.15.
- [Release notes](https://github.com/postcss/autoprefixer/releases)
- [Changelog](https://github.com/postcss/autoprefixer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/autoprefixer/compare/10.4.14...10.4.15)

---
updated-dependencies:
- dependency-name: autoprefixer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3969: chore: Bump autoprefixer from 10.4.14 to 10.4.15

4346 of 6321 branches covered (0.0%)

8259 of 10025 relevant lines covered (82.38%)

192.73 hits per line

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

96.88
/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,410✔
34
export const getFeatures = state => state.app.features;
18,292✔
35
export const getTooltipsById = state => state.users.tooltips.byId;
3,342✔
36
export const getRolesById = state => state.users.rolesById;
1,619✔
37
export const getOrganization = state => state.organization.organization;
6,707✔
38
export const getAcceptedDevices = state => state.devices.byStatus.accepted;
7,407✔
39
const getDevicesByStatus = state => state.devices.byStatus;
1,462✔
40
export const getDevicesById = state => state.devices.byId;
27,634✔
41
export const getDeviceReports = state => state.devices.reports;
3,532✔
42
export const getGroupsById = state => state.devices.groups.byId;
2,961✔
43
const getSelectedGroup = state => state.devices.groups.selectedGroup;
185✔
44
const getSearchedDevices = state => state.app.searchState.deviceIds;
1,037✔
45
const getListedDevices = state => state.devices.deviceList.deviceIds;
185✔
46
const getFilteringAttributes = state => state.devices.filteringAttributes;
1,174✔
47
export const getDeviceFilters = state => state.devices.filters || [];
197!
48
const getFilteringAttributesFromConfig = state => state.devices.filteringAttributesConfig.attributes;
1,145✔
49
export const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({
185✔
50
  ...filteringAttributes,
51
  identityAttributes: [...filteringAttributes.identityAttributes, 'id']
52
}));
53
export const getDeviceLimit = state => state.devices.limit;
1,951✔
54
const getDevicesList = state => Object.values(state.devices.byId);
185✔
55
const getOnboarding = state => state.onboarding;
1,511✔
56
export const getShowHelptips = state => state.users.showHelptips;
8,399✔
57
export const getGlobalSettings = state => state.users.globalSettings;
3,884✔
58
const getIssueCountsByType = state => state.monitor.issueCounts.byType;
1,152✔
59
export const getReleasesById = state => state.releases.byId;
2,095✔
60
const getReleaseTags = state => state.releases.releaseTags;
185✔
61
const getListedReleases = state => state.releases.releasesList.releaseIds;
185✔
62
export const getExternalIntegrations = state => state.organization.externalDeviceIntegrations;
185✔
63
const getDeploymentsById = state => state.deployments.byId;
2,658✔
64
export const getDeploymentsByStatus = state => state.deployments.byStatus;
1,918✔
65
export const getVersionInformation = state => state.app.versionInformation;
1,126✔
66
const getCurrentUserId = state => state.users.currentUser;
2,833✔
67
const getUsersById = state => state.users.byId;
1,688✔
68
export const getCurrentUser = createSelector([getUsersById, getCurrentUserId], (usersById, userId) => usersById[userId] ?? {});
185✔
69
export const getUserSettings = state => state.users.userSettings;
10,531✔
70
export const getIsPreview = createSelector([getVersionInformation], ({ Integration }) => versionCompare(Integration, 'next') > -1);
185✔
71

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

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

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

95
export const getHas2FA = createSelector(
185✔
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 }) => {
185✔
101
  const demoDeviceAddress = `http://${getDemoDeviceAddressHelper(devices, approach)}`;
3✔
102
  return demoArtifactPort ? `${demoDeviceAddress}:${demoArtifactPort}` : demoDeviceAddress;
3!
103
});
104

105
export const getDeviceReportsForUser = createSelector(
185✔
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 }) => {
185✔
113
  return ids.slice(0, cutOffSize).reduce((accu, id) => {
1,089✔
114
    if (id && byId[id]) {
162!
115
      accu.push({ ...defaultObject, ...byId[id] });
162✔
116
    }
117
    return accu;
162✔
118
  }, []);
119
};
120

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

131
export const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>
185✔
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,550✔
139

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

147
export const getSelectedGroupInfo = createSelector(
185✔
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 });
185✔
161
export const getIdAttribute = createSelector([getGlobalSettings], ({ id_attribute = { ...defaultIdAttribute } }) => id_attribute);
185✔
162

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

167
export const getFilterAttributes = createSelector(
185✔
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 };
3✔
171
    const deviceIdAttribute = { key: 'id', value: 'Device ID', scope: ATTRIBUTE_SCOPES.identity, category: ATTRIBUTE_SCOPES.identity, priority: 1 };
3✔
172
    const checkInAttribute = { key: 'check_in_time', value: 'Latest activity', scope: ATTRIBUTE_SCOPES.system, category: ATTRIBUTE_SCOPES.system, priority: 4 };
3✔
173
    const updateAttribute = { ...checkInAttribute, key: 'updated_ts', value: 'Last inventory update' };
3✔
174
    const firstRequestAttribute = { key: 'created_ts', value: 'First request', scope: ATTRIBUTE_SCOPES.system, category: ATTRIBUTE_SCOPES.system, priority: 4 };
3✔
175
    const attributes = [
3✔
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 })),
3✔
185
      ...inventoryAttributes.map(item => ({ key: item, value: item, scope: ATTRIBUTE_SCOPES.inventory, category: ATTRIBUTE_SCOPES.inventory, priority: 2 })),
3✔
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 }))
×
191
    ];
192
    return attributeDuplicateFilter(attributes, 'key');
3✔
193
  }
194
);
195

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

199
export const getGroups = createSelector([getGroupsById], groupsById => {
185✔
200
  const groupNames = Object.keys(groupsById).sort();
13✔
201
  const groupedGroups = Object.entries(groupsById)
13✔
202
    .sort((a, b) => a[0].localeCompare(b[0]))
40✔
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 =>
185✔
224
  integrations.filter(integration => integration.id && EXTERNAL_PROVIDER[integration.provider]?.deviceTwin)
4✔
225
);
226

227
export const getOfflineThresholdSettings = createSelector([getGlobalSettings], ({ offlineThreshold }) => ({
185✔
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([getOnboarding, getUserSettings], ({ complete, progress, showTips, ...remainder }, { onboarding = {} }) => ({
185!
233
  ...remainder,
234
  ...onboarding,
235
  complete,
236
  progress,
237
  showTips
238
}));
239

240
export const getTooltipsState = createSelector([getTooltipsById, getUserSettings], (byId, { tooltips = {} }) =>
185✔
241
  Object.entries(byId).reduce(
58✔
242
    (accu, [id, value]) => {
243
      accu[id] = { ...accu[id], ...value };
×
244
      return accu;
×
245
    },
246
    { ...tooltips }
247
  )
248
);
249

250
export const getDocsVersion = createSelector([getAppDocsVersion, getFeatures], (appDocsVersion, { isHosted }) => {
185✔
251
  // if hosted, use latest docs version
252
  const docsVersion = appDocsVersion ? `${appDocsVersion}/` : 'development/';
43!
253
  return isHosted ? '' : docsVersion;
43✔
254
});
255

256
export const getIsEnterprise = createSelector(
185✔
257
  [getOrganization, getFeatures],
258
  ({ plan = PLANS.os.id }, { isEnterprise, isHosted }) => isEnterprise || (isHosted && plan === PLANS.enterprise.id)
81✔
259
);
260

261
export const getAttributesList = createSelector(
185✔
262
  [getFilteringAttributes, getFilteringAttributesFromConfig],
263
  ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>
40!
264
    [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)
20✔
265
);
266

267
export const getRolesList = createSelector([getRolesById], rolesById => Object.entries(rolesById).map(([id, role]) => ({ id, ...role })));
185✔
268

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

282
const hasPermission = (thing, permission) => Object.values(thing).some(permissions => permissions.includes(permission));
319✔
283

284
export const getUserCapabilities = createSelector([getUserRoles], ({ uiPermissions }) => {
185✔
285
  const canManageReleases = hasPermission(uiPermissions.releases, uiPermissionsById.manage.value);
62✔
286
  const canReadReleases = canManageReleases || hasPermission(uiPermissions.releases, uiPermissionsById.read.value);
62✔
287
  const canUploadReleases = canManageReleases || hasPermission(uiPermissions.releases, uiPermissionsById.upload.value);
62✔
288

289
  const canAuditlog = uiPermissions.auditlog.includes(uiPermissionsById.read.value);
62✔
290

291
  const canReadUsers = uiPermissions.userManagement.includes(uiPermissionsById.read.value);
62✔
292
  const canManageUsers = uiPermissions.userManagement.includes(uiPermissionsById.manage.value);
62✔
293

294
  const canReadDevices = hasPermission(uiPermissions.groups, uiPermissionsById.read.value);
62✔
295
  const canWriteDevices = Object.values(uiPermissions.groups).some(
62✔
296
    groupPermissions => groupPermissions.includes(uiPermissionsById.read.value) && groupPermissions.length > 1
59✔
297
  );
298
  const canTroubleshoot = hasPermission(uiPermissions.groups, uiPermissionsById.connect.value);
62✔
299
  const canManageDevices = hasPermission(uiPermissions.groups, uiPermissionsById.manage.value);
62✔
300
  const canConfigure = hasPermission(uiPermissions.groups, uiPermissionsById.configure.value);
62✔
301

302
  const canDeploy = uiPermissions.deployments.includes(uiPermissionsById.deploy.value) || hasPermission(uiPermissions.groups, uiPermissionsById.deploy.value);
62✔
303
  const canReadDeployments = uiPermissions.deployments.includes(uiPermissionsById.read.value);
62✔
304

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

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

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

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

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

402
const getReleaseMappingDefaults = () => ({});
185✔
403
export const getReleasesList = createSelector([getReleasesById, getListedReleases, getReleaseMappingDefaults], listItemMapper);
185✔
404

405
export const getReleaseTagsById = createSelector([getReleaseTags], releaseTags => releaseTags.reduce((accu, key) => ({ ...accu, [key]: key }), {}));
185✔
406

407
const relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished];
185✔
408
export const DEPLOYMENT_CUTOFF = 3;
185✔
409
export const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>
185✔
410
  Object.entries(deploymentsByStatus).reduce(
409✔
411
    (accu, [state, byStatus]) => {
412
      if (!relevantDeploymentStates.includes(state) || !byStatus.deploymentIds.length) {
1,636✔
413
        return accu;
433✔
414
      }
415
      accu[state] = byStatus.deploymentIds
1,203✔
416
        .reduce((accu, id) => {
417
          if (deploymentsById[id]) {
2,340✔
418
            accu.push(deploymentsById[id]);
2,334✔
419
          }
420
          return accu;
2,340✔
421
        }, [])
422
        .slice(0, DEPLOYMENT_CUTOFF);
423
      accu.total += byStatus.total;
1,203✔
424
      return accu;
1,203✔
425
    },
426
    { total: 0 }
427
  )
428
);
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