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

mendersoftware / mender-server / 10423

11 Nov 2025 04:53PM UTC coverage: 74.435% (-0.1%) from 74.562%
10423

push

gitlab-ci

web-flow
Merge pull request #1071 from mendersoftware/dependabot/npm_and_yarn/frontend/main/development-dependencies-92732187be

3868 of 5393 branches covered (71.72%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

176 existing lines in 95 files now uncovered.

64605 of 86597 relevant lines covered (74.6%)

7.74 hits per line

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

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

2✔
16
import DeviceIdentityDisplay from '@northern.tech/common-ui/DeviceIdentity';
2✔
17
import Time from '@northern.tech/common-ui/Time';
2✔
18
import { DEPLOYMENT_ROUTES, auditlogTypes, canAccess } from '@northern.tech/store/constants';
2✔
19

2✔
20
const ArtifactLink = ({ item }) => <Link to={`/releases/${item.object.artifact.name}`}>View artifact</Link>;
7✔
21
const DeploymentLink = ({ item }) => <Link to={`${DEPLOYMENT_ROUTES.finished.route}?open=true&id=${item.object.id}`}>View deployment</Link>;
20✔
22
const DeviceLink = ({ item }) => <Link to={`/devices?id=${item.object.id}`}>View device</Link>;
7✔
23
const DeviceRejectedLink = ({ item }) => <Link to={`/devices/rejected?id=${item.object.id}`}>View device</Link>;
7✔
24
const TerminalSessionLink = () => <a>View session log</a>;
20✔
25
const ChangeFallback = props => {
7✔
26
  const {
2✔
27
    item: { change = '-' }
2✔
28
  } = props;
20✔
29
  return <div className="text-overflow">{change}</div>;
20✔
30
};
2✔
31

2✔
32
const FallbackFormatter = props => {
7✔
33
  let result = '';
2✔
34
  try {
2✔
35
    result = JSON.stringify(props);
2✔
36
  } catch (error) {
2✔
37
    console.log(error);
2✔
38
  }
2✔
39
  return <div>{result}</div>;
2✔
40
};
2✔
41

2✔
42
const ArtifactFormatter = ({ artifact }) => <div>{artifact.name}</div>;
7✔
43
const DeploymentFormatter = ({ deployment }) => <div>{deployment.name}</div>;
20✔
44
const DeviceFormatter = ({ id }) => <DeviceIdentityDisplay device={{ id }} />;
20✔
45
const UserFormatter = ({ user }) => <div>{user.email}</div>;
20✔
46
const TenantFormatter = ({ tenant }) => <div>{tenant.name}</div>;
7✔
47

2✔
48
const defaultAccess = canAccess;
7✔
49
const changeMap = {
7✔
50
  default: { component: 'div', actionFormatter: FallbackFormatter, title: 'defaultTitle', accessCheck: defaultAccess },
2✔
UNCOV
51
  artifact: { actionFormatter: ArtifactFormatter, component: ArtifactLink, accessCheck: ({ canReadReleases }) => canReadReleases },
2✔
52
  deployment: {
2✔
53
    actionFormatter: DeploymentFormatter,
2✔
54
    component: DeploymentLink,
2✔
55
    accessCheck: ({ canReadDeployments }) => canReadDeployments
20✔
56
  },
2✔
57
  deviceDecommissioned: { actionFormatter: DeviceFormatter, component: 'div', accessCheck: defaultAccess },
2✔
UNCOV
58
  deviceRejected: { actionFormatter: DeviceFormatter, component: DeviceRejectedLink, accessCheck: ({ canReadDevices }) => canReadDevices },
2✔
UNCOV
59
  deviceGeneral: { actionFormatter: DeviceFormatter, component: DeviceLink, accessCheck: ({ canReadDevices }) => canReadDevices },
2✔
60
  deviceTerminalSession: { actionFormatter: DeviceFormatter, component: TerminalSessionLink, accessCheck: defaultAccess },
2✔
61
  user: { actionFormatter: UserFormatter, component: ChangeFallback, accessCheck: defaultAccess },
2✔
62
  user_access_token: { actionFormatter: FallbackFormatter, component: ChangeFallback, accessCheck: defaultAccess },
2✔
63
  tenant: { actionFormatter: TenantFormatter, component: ChangeFallback, accessCheck: defaultAccess }
2✔
64
};
2✔
65

2✔
66
const mapChangeToContent = item => {
7✔
67
  let content = changeMap[item.object.type];
110✔
68
  if (content) {
110✔
69
    return content;
74✔
70
  } else if (item.object.type === 'device' && item.action.includes('terminal')) {
38!
71
    content = changeMap.deviceTerminalSession;
38✔
UNCOV
72
  } else if (item.object.type === 'device' && item.action.includes('reject')) {
2!
73
    content = changeMap.deviceRejected;
2✔
74
  } else if (item.object.type === 'device' && item.action.includes('decommission')) {
2!
75
    content = changeMap.deviceDecommissioned;
2✔
76
  } else if (item.object.type === 'device') {
2!
77
    content = changeMap.deviceGeneral;
2✔
78
  } else {
2✔
79
    content = changeMap.default;
2✔
80
  }
2✔
81
  return content;
38✔
82
};
2✔
83

2✔
84
const actorMap = {
7✔
85
  user: 'email',
2✔
86
  device: 'id'
2✔
87
};
2✔
88

2✔
89
export const UserDescriptor = (item, index) => <div key={`${item.time}-${index} `}>{item.actor[actorMap[item.actor.type]]}</div>;
56✔
90
export const ActionDescriptor = (item, index) => (
7✔
91
  <div className="uppercased" key={`${item.time}-${index}`}>
56✔
92
    {item.action}
2✔
93
  </div>
2✔
94
);
2✔
95
export const TypeDescriptor = (item, index) => (
7✔
96
  <div className="capitalized" key={`${item.time}-${index}`}>
56✔
97
    {auditlogTypes[item.object.type]?.title ?? item.object.type}
2!
98
  </div>
2✔
99
);
2✔
100
export const ChangeDescriptor = (item, index) => {
7✔
101
  const FormatterComponent = mapChangeToContent(item).actionFormatter;
56✔
102
  return <FormatterComponent key={`${item.time}-${index}`} {...item.object} />;
56✔
103
};
2✔
104
export const ChangeDetailsDescriptor = (item, index, userCapabilities) => {
7✔
105
  const { component: Comp, accessCheck } = mapChangeToContent(item);
56✔
106
  const key = `${item.time}-${index}`;
56✔
107
  return accessCheck(userCapabilities) ? <Comp key={key} item={item} /> : <div key={key} />;
56!
108
};
2✔
109
export const TimeWrapper = (item, index) => <Time key={`${item.time}-${index}`} value={item.time} />;
56✔
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