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

mendersoftware / gui / 1113439055

19 Dec 2023 09:01PM UTC coverage: 82.752% (-17.2%) from 99.964%
1113439055

Pull #4258

gitlab-ci

mender-test-bot
chore: Types update

Signed-off-by: Mender Test Bot <mender@northern.tech>
Pull Request #4258: chore: Types update

4326 of 6319 branches covered (0.0%)

8348 of 10088 relevant lines covered (82.75%)

189.39 hits per line

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

74.07
/src/js/components/common/docslink.js
1
// Copyright 2023 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 React, { forwardRef, useState } from 'react';
15
import { useSelector } from 'react-redux';
16

17
import { Description as DescriptionIcon } from '@mui/icons-material';
18
import { Chip, Collapse, chipClasses } from '@mui/material';
19
import { makeStyles } from 'tss-react/mui';
20

21
import { TIMEOUTS } from '../../constants/appConstants';
22
import { getDocsVersion, getFeatures } from '../../selectors';
23
import { useDebounce } from '../../utils/debouncehook';
24
import { MenderTooltipClickable } from './mendertooltip';
25

26
const useStyles = makeStyles()(theme => ({
183✔
27
  iconAura: {
28
    position: 'absolute',
29
    top: -6,
30
    bottom: -4,
31
    left: -7,
32
    right: -6.5,
33
    border: `1px dashed ${theme.palette.text.disabled}`,
34
    borderRadius: '50%',
35
    '&.hovering': {
36
      borderColor: 'transparent'
37
    }
38
  },
39
  chip: {
40
    borderStyle: 'dashed',
41
    [`.${chipClasses.deleteIcon}`]: {
42
      fontSize: 'smaller'
43
    },
44
    '&.not-hovering': {
45
      borderColor: 'transparent',
46
      color: theme.palette.text.disabled,
47
      [`.${chipClasses.deleteIcon}`]: {
48
        color: theme.palette.text.disabled
49
      },
50
      [`.${chipClasses.label}`]: {
51
        paddingLeft: 0,
52
        visibility: 'collapse'
53
      }
54
    }
55
  }
56
}));
57

58
export const DOCSTIPS = {
183✔
59
  deviceConfig: { id: 'deviceConfig', path: 'add-ons/configure' },
60
  dynamicGroups: { id: 'dynamicGroups', path: 'overview/device-group#dynamic-group' },
61
  phasedDeployments: { id: 'phasedDeployments', path: 'overview/customize-the-update-process' },
62
  pausedDeployments: { id: 'pausedDeployments', path: 'overview/customize-the-update-process#synchronized-updates' },
63
  retryDeployments: { id: 'retryDeployments', path: 'overview/deployment' },
64
  releases: { id: 'releases', path: 'overview/artifact' }
65
};
66

67
export const DocsTooltip = ({ anchor = {}, id = '', ...props }) => {
183✔
68
  const [isHovering, setIsHovering] = useState(false);
866✔
69
  const debouncedHovering = useDebounce(isHovering, TIMEOUTS.debounceDefault);
866✔
70
  const docsVersion = useSelector(getDocsVersion);
866✔
71
  const { isHosted } = useSelector(getFeatures);
866✔
72
  const { classes } = useStyles();
866✔
73
  const { content, path } = DOCSTIPS[id] || {};
866✔
74
  const target = `https://docs.mender.io/${docsVersion}${path}`;
866✔
75

76
  const onClick = () => {
866✔
77
    const docsParams = { headers: { 'x-mender-docs': docsVersion } };
×
78
    fetch(target, isHosted ? {} : docsParams);
×
79
    window.open(target, '_blank');
×
80
  };
81

82
  const hoverClass = debouncedHovering ? 'hovering' : 'not-hovering';
866!
83
  return (
866✔
84
    <MenderTooltipClickable
85
      placement="bottom-start"
86
      disableFocusListener={false}
87
      disableHoverListener={false}
88
      disableTouchListener={false}
89
      style={anchor}
90
      title={content}
91
      {...props}
92
    >
93
      <Chip
94
        color="primary"
95
        className={`${classes.chip} ${hoverClass}`}
96
        label={
97
          <Collapse in={debouncedHovering} orientation="horizontal">
98
            Learn more
99
          </Collapse>
100
        }
101
        deleteIcon={
102
          <div className="relative">
103
            <DescriptionIcon fontSize="small" />
104
            <div className={`${classes.iconAura} ${hoverClass}`} />
105
          </div>
106
        }
107
        onClick={onClick}
108
        onDelete={onClick}
109
        onMouseOver={() => setIsHovering(true)}
×
110
        onMouseOut={() => setIsHovering(false)}
×
111
        variant="outlined"
112
      />
113
    </MenderTooltipClickable>
114
  );
115
};
116

117
export const DocsLink = forwardRef(({ children, className = '', path, title = '', ...remainder }, ref) => {
183✔
118
  const docsVersion = useSelector(getDocsVersion);
233✔
119
  const { isHosted } = useSelector(getFeatures);
233✔
120
  const target = `https://docs.mender.io/${docsVersion}${path}`;
233✔
121

122
  const onClickHandler = () => {
233✔
123
    const docsParams = { headers: { 'x-mender-docs': docsVersion } };
×
124
    fetch(target, isHosted ? {} : docsParams);
×
125
  };
126

127
  return (
233✔
128
    // eslint-disable-next-line react/jsx-no-target-blank
129
    <a className={className} {...remainder} href={target} onClick={onClickHandler} ref={ref} target="_blank" rel={isHosted ? 'noopener noreferrer' : ''}>
233✔
130
      {children ? children : title}
233✔
131
    </a>
132
  );
133
});
134

135
DocsLink.displayName = 'DocsLink';
183✔
136

137
export default DocsLink;
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