• 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

100.0
/frontend/src/js/common-ui/EnterpriseNotification.tsx
1
// Copyright 2019 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 { useState } from 'react';
2✔
15
import { useSelector } from 'react-redux';
2✔
16
import { Link } from 'react-router-dom';
2✔
17

2✔
18
import { Chip } from '@mui/material';
2✔
19
import { withStyles } from 'tss-react/mui';
2✔
20

2✔
21
import { ADDONS, BENEFITS, PLANS } from '@northern.tech/store/constants';
2✔
22
import { getTenantCapabilities } from '@northern.tech/store/selectors';
2✔
23
import { yes } from '@northern.tech/utils/helpers';
2✔
24

2✔
25
import MenderTooltip, { MenderTooltipClickable } from './helptips/MenderTooltip';
2✔
26

2✔
27
const PlansTooltip = withStyles(MenderTooltip, ({ palette }) => ({
275✔
28
  arrow: {
2✔
29
    color: palette.tooltip?.tierTipBackground ?? palette.grey[100]
2✔
30
  },
2✔
31
  tooltip: {
2✔
32
    backgroundColor: palette.tooltip?.tierTipBackground ?? palette.grey[100],
2✔
33
    maxWidth: 300
2✔
34
  }
2✔
35
}));
2✔
36

2✔
37
const PlanChip = withStyles(Chip, ({ palette }) => ({
274✔
38
  root: {
2✔
39
    backgroundColor: palette.tooltip?.tierTipBackground ?? palette.grey[100],
2✔
40
    color: palette.text.disabled,
2✔
41
    textTransform: 'uppercase',
2✔
42
    '&:hover': {
2✔
43
      fontWeight: 'bold'
2✔
44
    }
2✔
45
  }
2✔
46
}));
2✔
47

2✔
48
export const DefaultUpgradeNotification = props => (
40✔
49
  <div {...props}>
4✔
50
    This feature is not available on your plan. <Link to="/subscription">Upgrade</Link> to enable it
2✔
51
  </div>
2✔
52
);
2✔
53

2✔
54
const EnterpriseNotification = ({ className = '', id = BENEFITS.default.id }) => {
40✔
55
  const [isOpen, setIsOpen] = useState(false);
715✔
56
  const tenantCapabilities = useSelector(getTenantCapabilities);
715✔
57
  const { isEnterprise, plan: currentPlan } = tenantCapabilities;
715✔
58
  const { benefit, requiredAddon = '', requiredPlan = PLANS.os.id } = BENEFITS[id];
715✔
59
  const hasAddon = requiredAddon ? ADDONS[requiredAddon].needs.every(need => tenantCapabilities[need]) : false;
715✔
60

2✔
61
  const currentPlanIndex = Object.keys(PLANS).indexOf(currentPlan);
715✔
62
  const requiredPlanIndex = Object.keys(PLANS).indexOf(requiredPlan);
715✔
63
  const shouldShow = requiredPlanIndex > currentPlanIndex;
715✔
64
  // we have to explicitly check for the plan requirement here, since the default value prevents us from relying on the `shouldShow` result
2✔
65
  if (isEnterprise || (BENEFITS[id].requiredPlan && !shouldShow) || (requiredAddon && hasAddon)) {
715✔
66
    return null;
442✔
67
  }
2✔
68
  const content = requiredAddon ? (
275✔
69
    <>
2✔
70
      Add the <b>{ADDONS[requiredAddon].title}</b> add-on to {benefit}.
2✔
71
    </>
2✔
72
  ) : (
2✔
73
    <>
2✔
74
      Upgrade to the <b>{PLANS[requiredPlan].name}</b> plan {requiredPlanIndex === Object.keys(PLANS).length - 1 ? '' : 'or higher '}to gain access to {benefit}
2✔
75
      .
2✔
76
    </>
2✔
77
  );
2✔
78
  return (
715✔
79
    <MenderTooltipClickable
2✔
80
      onOpenChange={setIsOpen}
2✔
81
      title={
2✔
82
        <div>
2✔
83
          {content}
2✔
84
          <div className="flexbox space-between margin-top-small">
2✔
85
            <Link to="/subscription">Upgrade now</Link>
2✔
UNCOV
86
            <span className="link" onClick={() => setIsOpen(false)}>
2✔
87
              Close
2✔
88
            </span>
2✔
89
          </div>
2✔
90
        </div>
2✔
91
      }
2✔
92
      tooltipComponent={PlansTooltip}
2✔
93
      visibility={isOpen}
2✔
94
    >
2✔
95
      <PlanChip className={className} onClick={yes} label={PLANS[requiredPlan].name} />
2✔
96
    </MenderTooltipClickable>
2✔
97
  );
2✔
98
};
2✔
99

2✔
100
export default EnterpriseNotification;
2✔
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