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

mendersoftware / gui / 1015445845

25 Sep 2023 09:43AM UTC coverage: 82.537% (-17.4%) from 99.964%
1015445845

Pull #4028

gitlab-ci

mzedel
chore: aligned release retrieval with v2 api models

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

4355 of 6315 branches covered (0.0%)

184 of 206 new or added lines in 19 files covered. (89.32%)

1724 existing lines in 164 files now uncovered.

8323 of 10084 relevant lines covered (82.54%)

208.49 hits per line

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

96.98
/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 { READ_STATES, 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,415✔
34
export const getFeatures = state => state.app.features;
18,285✔
35
export const getTooltipsById = state => state.users.tooltips.byId;
2,517✔
36
export const getRolesById = state => state.users.rolesById;
1,642✔
37
export const getOrganization = state => state.organization.organization;
6,775✔
38
export const getAcceptedDevices = state => state.devices.byStatus.accepted;
7,414✔
39
const getDevicesByStatus = state => state.devices.byStatus;
1,467✔
40
export const getDevicesById = state => state.devices.byId;
27,782✔
41
export const getDeviceReports = state => state.devices.reports;
3,527✔
42
export const getGroupsById = state => state.devices.groups.byId;
2,971✔
43
const getSelectedGroup = state => state.devices.groups.selectedGroup;
185✔
44
const getSearchedDevices = state => state.app.searchState.deviceIds;
1,036✔
45
const getListedDevices = state => state.devices.deviceList.deviceIds;
185✔
46
const getFilteringAttributes = state => state.devices.filteringAttributes;
1,173✔
47
export const getDeviceFilters = state => state.devices.filters || [];
197!
48
const getFilteringAttributesFromConfig = state => state.devices.filteringAttributesConfig.attributes;
1,144✔
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,946✔
54
const getDevicesList = state => Object.values(state.devices.byId);
185✔
55
const getOnboarding = state => state.onboarding;
1,516✔
56
export const getGlobalSettings = state => state.users.globalSettings;
3,906✔
57
const getIssueCountsByType = state => state.monitor.issueCounts.byType;
1,151✔
58
const getSelectedReleaseId = state => state.releases.selectedRelease;
185✔
59
export const getReleasesById = state => state.releases.byId;
2,227✔
60
export const getReleaseTags = state => state.releases.tags;
260✔
61
export const getReleaseListState = state => state.releases.releasesList;
1,223✔
62
const getListedReleases = state => state.releases.releasesList.releaseIds;
185✔
63
export const getUpdateTypes = state => state.releases.updateTypes;
185✔
64
export const getExternalIntegrations = state => state.organization.externalDeviceIntegrations;
185✔
65
const getDeploymentsById = state => state.deployments.byId;
2,691✔
66
export const getDeploymentsByStatus = state => state.deployments.byStatus;
1,935✔
67
export const getVersionInformation = state => state.app.versionInformation;
1,127✔
68
const getCurrentUserId = state => state.users.currentUser;
2,855✔
69
const getUsersById = state => state.users.byId;
1,711✔
70
export const getCurrentUser = createSelector([getUsersById, getCurrentUserId], (usersById, userId) => usersById[userId] ?? {});
185✔
71
export const getUserSettings = state => state.users.userSettings;
10,546✔
72
export const getIsPreview = createSelector([getVersionInformation], ({ Integration }) => versionCompare(Integration, 'next') > -1);
185✔
73

74
export const getShowHelptips = createSelector([getTooltipsById], tooltips =>
185✔
75
  Object.values(tooltips).reduce((accu, { readState }) => accu || readState === READ_STATES.unread, false)
4!
76
);
77

78
export const getDeploymentsSelectionState = state => state.deployments.selectionState;
2,363✔
79

80
export const getMappedDeploymentSelection = createSelector(
185✔
81
  [getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],
1,225✔
82
  (selectionState, deploymentsState, deploymentsById) => {
83
    const { selection = [] } = selectionState[deploymentsState] ?? {};
1,191!
84
    return selection.reduce((accu, id) => {
1,191✔
85
      if (deploymentsById[id]) {
2,161!
86
        accu.push(deploymentsById[id]);
2,161✔
87
      }
88
      return accu;
2,161✔
89
    }, []);
90
  }
91
);
92

93
export const getDeploymentRelease = createSelector(
185✔
94
  [getDeploymentsById, getDeploymentsSelectionState, getReleasesById],
95
  (deploymentsById, { selectedId }, releasesById) => {
96
    const deployment = deploymentsById[selectedId] || {};
164✔
97
    return deployment.artifact_name && releasesById[deployment.artifact_name] ? releasesById[deployment.artifact_name] : { device_types_compatible: [] };
164✔
98
  }
99
);
100

101
export const getHas2FA = createSelector(
185✔
102
  [getCurrentUser],
103
  currentUser => currentUser.hasOwnProperty('tfa_status') && currentUser.tfa_status === twoFAStates.enabled
5✔
104
);
105

106
export const getDemoDeviceAddress = createSelector([getDevicesList, getOnboarding], (devices, { approach, demoArtifactPort }) => {
185✔
107
  const demoDeviceAddress = `http://${getDemoDeviceAddressHelper(devices, approach)}`;
3✔
108
  return demoArtifactPort ? `${demoDeviceAddress}:${demoArtifactPort}` : demoDeviceAddress;
3!
109
});
110

111
export const getDeviceReportsForUser = createSelector(
185✔
112
  [getUserSettings, getCurrentUserId, getGlobalSettings, getDevicesById],
113
  ({ reports }, currentUserId, globalSettings, devicesById) => {
114
    return reports || globalSettings[`${currentUserId}-reports`] || (Object.keys(devicesById).length ? defaultReports : []);
49✔
115
  }
116
);
117

118
const listItemMapper = (byId, ids, { defaultObject = {}, cutOffSize = DEVICE_LIST_MAXIMUM_LENGTH }) => {
185✔
119
  return ids.slice(0, cutOffSize).reduce((accu, id) => {
1,104✔
120
    if (id && byId[id]) {
330!
121
      accu.push({ ...defaultObject, ...byId[id] });
330✔
122
    }
123
    return accu;
330✔
124
  }, []);
125
};
126

127
const listTypeDeviceIdMap = {
185✔
128
  deviceList: getListedDevices,
129
  search: getSearchedDevices
130
};
131
const getDeviceMappingDefaults = () => ({ defaultObject: { auth_sets: [] }, cutOffSize: DEVICE_LIST_MAXIMUM_LENGTH });
1,063✔
132
export const getMappedDevicesList = createSelector(
185✔
133
  [getDevicesById, (state, listType) => listTypeDeviceIdMap[listType](state), getDeviceMappingDefaults],
1,063✔
134
  listItemMapper
135
);
136

137
export const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>
185✔
138
  Object.values(DEVICE_STATES).reduce((accu, state) => {
412✔
139
    accu[state] = byStatus[state].total || 0;
1,648✔
140
    return accu;
1,648✔
141
  }, {})
142
);
143

144
export const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});
1,572✔
145

146
export const getDeviceConfigDeployment = createSelector([getDeviceById, getDeploymentsById], (device, deploymentsById) => {
185✔
147
  const { config = {} } = device;
7✔
148
  const { deployment_id: configDeploymentId } = config;
7✔
149
  const deviceConfigDeployment = deploymentsById[configDeploymentId] || {};
7✔
150
  return { device, deviceConfigDeployment };
7✔
151
});
152

153
export const getSelectedGroupInfo = createSelector(
185✔
154
  [getAcceptedDevices, getGroupsById, getSelectedGroup],
155
  ({ total: acceptedDeviceTotal }, groupsById, selectedGroup) => {
156
    let groupCount = acceptedDeviceTotal;
7✔
157
    let groupFilters = [];
7✔
158
    if (selectedGroup && groupsById[selectedGroup]) {
7✔
159
      groupCount = groupsById[selectedGroup].total;
2✔
160
      groupFilters = groupsById[selectedGroup].filters || [];
2!
161
    }
162
    return { groupCount, selectedGroup, groupFilters };
7✔
163
  }
164
);
165

166
const defaultIdAttribute = Object.freeze({ attribute: 'id', scope: ATTRIBUTE_SCOPES.identity });
185✔
167
export const getIdAttribute = createSelector([getGlobalSettings], ({ id_attribute = { ...defaultIdAttribute } }) => id_attribute);
185✔
168

169
export const getLimitMaxed = createSelector([getAcceptedDevices, getDeviceLimit], ({ total: acceptedDevices = 0 }, deviceLimit) =>
185!
170
  Boolean(deviceLimit && deviceLimit <= acceptedDevices)
7✔
171
);
172

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

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

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

229
export const getDeviceTwinIntegrations = createSelector([getExternalIntegrations], integrations =>
185✔
230
  integrations.filter(integration => integration.id && EXTERNAL_PROVIDER[integration.provider]?.deviceTwin)
4✔
231
);
232

233
export const getOfflineThresholdSettings = createSelector([getGlobalSettings], ({ offlineThreshold }) => ({
185✔
234
  interval: offlineThreshold?.interval || DEVICE_ONLINE_CUTOFF.interval,
26✔
235
  intervalUnit: offlineThreshold?.intervalUnit || DEVICE_ONLINE_CUTOFF.intervalName
26✔
236
}));
237

238
export const getOnboardingState = createSelector([getOnboarding, getUserSettings], ({ complete, progress, showTips, ...remainder }, { onboarding = {} }) => ({
185!
239
  ...remainder,
240
  ...onboarding,
241
  complete,
242
  progress,
243
  showTips
244
}));
245

246
export const getTooltipsState = createSelector([getTooltipsById, getUserSettings], (byId, { tooltips = {} }) =>
185✔
247
  Object.entries(byId).reduce(
58✔
248
    (accu, [id, value]) => {
UNCOV
249
      accu[id] = { ...accu[id], ...value };
×
UNCOV
250
      return accu;
×
251
    },
252
    { ...tooltips }
253
  )
254
);
255

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

262
export const getIsEnterprise = createSelector(
185✔
263
  [getOrganization, getFeatures],
264
  ({ plan = PLANS.os.id }, { isEnterprise, isHosted }) => isEnterprise || (isHosted && plan === PLANS.enterprise.id)
81✔
265
);
266

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

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

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

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

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

295
  const canAuditlog = uiPermissions.auditlog.includes(uiPermissionsById.read.value);
62✔
296

297
  const canReadUsers = uiPermissions.userManagement.includes(uiPermissionsById.read.value);
62✔
298
  const canManageUsers = uiPermissions.userManagement.includes(uiPermissionsById.manage.value);
62✔
299

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

308
  const canDeploy = uiPermissions.deployments.includes(uiPermissionsById.deploy.value) || hasPermission(uiPermissions.groups, uiPermissionsById.deploy.value);
62✔
309
  const canReadDeployments = uiPermissions.deployments.includes(uiPermissionsById.read.value);
62✔
310

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

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

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

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

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

408
const getReleaseMappingDefaults = () => ({});
185✔
409
export const getReleasesList = createSelector([getReleasesById, getListedReleases, getReleaseMappingDefaults], listItemMapper);
185✔
410

411
export const getReleaseTagsById = createSelector([getReleaseTags], releaseTags => releaseTags.reduce((accu, key) => ({ ...accu, [key]: key }), {}));
185✔
412
export const getHasReleases = createSelector(
185✔
413
  [getReleaseListState, getReleasesById],
414
  ({ searchTotal, total }, byId) => !!(Object.keys(byId).length || total || searchTotal)
35!
415
);
416

417
export const getSelectedRelease = createSelector([getReleasesById, getSelectedReleaseId], (byId, id) => byId[id] ?? {});
185✔
418

419
const relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished];
185✔
420
export const DEPLOYMENT_CUTOFF = 3;
185✔
421
export const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>
185✔
422
  Object.entries(deploymentsByStatus).reduce(
409✔
423
    (accu, [state, byStatus]) => {
424
      if (!relevantDeploymentStates.includes(state) || !byStatus.deploymentIds.length) {
1,636✔
425
        return accu;
433✔
426
      }
427
      accu[state] = byStatus.deploymentIds
1,203✔
428
        .reduce((accu, id) => {
429
          if (deploymentsById[id]) {
2,340✔
430
            accu.push(deploymentsById[id]);
2,334✔
431
          }
432
          return accu;
2,340✔
433
        }, [])
434
        .slice(0, DEPLOYMENT_CUTOFF);
435
      accu.total += byStatus.total;
1,203✔
436
      return accu;
1,203✔
437
    },
438
    { total: 0 }
439
  )
440
);
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