• 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

54.55
/src/js/components/devices/troubleshoot/terminal.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 React, { useCallback, useEffect, useMemo, useState } from 'react';
15

16
import { FitAddon } from 'xterm-addon-fit';
17
import { WebLinksAddon } from 'xterm-addon-web-links';
18

19
import { TIMEOUTS } from '../../../constants/appConstants';
20
import { DEVICE_MESSAGE_TYPES as MessageTypes } from '../../../constants/deviceConstants';
21
import useWindowSize from '../../../utils/resizehook';
22
import XTerm from '../../common/xterm';
23

24
const fitAddon = new FitAddon();
13✔
25

26
export const options = {
13✔
27
  cursorBlink: 'block',
28
  macOptionIsMeta: true
29
};
30

31
// only matching absolute paths, so: /here/there - but not ../here or ./here or here/there
32
const unixPathRegex = new RegExp('(\\/([^\\0\\s!$`&*()\\[\\]+\'":;\\\\])+)');
13✔
33

34
export const Terminal = ({ onDownloadClick, sendMessage, setSnackbar, socketInitialized, textInput, xtermRef, ...xtermProps }) => {
13✔
35
  const [dimensions, setDimensions] = useState({});
2✔
36
  const [isVisible, setIsVisible] = useState(false);
2✔
37
  const size = useWindowSize();
2✔
38

39
  const observer = useMemo(() => new IntersectionObserver(([entry]) => setIsVisible(entry.isIntersecting)), []);
2✔
40
  const addons = useMemo(() => [fitAddon], []);
2✔
41

42
  const tryFit = useCallback(() => {
2✔
43
    try {
×
44
      fitAddon.fit();
×
45
    } catch {
46
      setSnackbar('Fit not possible, terminal not yet visible', TIMEOUTS.fiveSeconds);
×
47
    }
48
  }, [setSnackbar]);
49

50
  useEffect(() => {
2✔
51
    if (!socketInitialized) {
2!
52
      return;
2✔
53
    }
54
    observer.observe(xtermRef.current.terminalRef.current);
×
55
    // Remove the observer as soon as the component is unmounted
56
    return () => {
×
57
      observer.disconnect();
×
58
    };
59
  }, [observer, sendMessage, socketInitialized, xtermRef]);
60

61
  useEffect(() => {
2✔
62
    if (!socketInitialized || !xtermRef.current?.terminal?.current) {
2!
63
      return;
2✔
64
    }
65
    xtermRef.current.terminal.current.reset();
×
66
    const webLinksAddon = new WebLinksAddon((e, link) => onDownloadClick(link), { urlRegex: unixPathRegex }, true);
×
67
    xtermRef.current.terminal.current.loadAddon(webLinksAddon);
×
68
    tryFit();
×
69
    const { rows = 40, cols = 80 } = fitAddon.proposeDimensions() || {};
×
70
    sendMessage({ typ: MessageTypes.Resize, props: { terminal_height: rows, terminal_width: cols } });
×
71
    setDimensions({ rows, cols });
×
72
    xtermRef.current.terminal.current.focus();
×
73
    // eslint-disable-next-line react-hooks/exhaustive-deps
74
  }, [onDownloadClick, socketInitialized, tryFit, sendMessage]);
75

76
  useEffect(() => {
2✔
77
    if (!socketInitialized || !xtermRef.current.terminal || !isVisible) {
2!
78
      return;
2✔
79
    }
80
    fitAddon.fit();
×
81
    const newDimensions = fitAddon.proposeDimensions();
×
82
    if (newDimensions.rows != dimensions.rows || newDimensions.cols != dimensions.cols) {
×
83
      //
84
      sendMessage({
×
85
        typ: MessageTypes.Resize,
86
        props: { terminal_height: newDimensions.rows, terminal_width: newDimensions.cols }
87
      });
88
      setDimensions(newDimensions);
×
89
    }
90
  }, [size, isVisible, socketInitialized, xtermRef, dimensions.rows, dimensions.cols, sendMessage]);
91

92
  useEffect(() => {
2✔
93
    if (!socketInitialized || !xtermRef.current.terminal || !textInput) {
2!
94
      return;
2✔
95
    }
96
    xtermRef.current.terminal.current.paste(textInput);
×
97
  }, [socketInitialized, textInput, xtermRef]);
98

99
  const onData = useCallback(data => sendMessage({ typ: MessageTypes.Shell, body: data }), [sendMessage]);
2✔
100

101
  return <XTerm xtermRef={xtermRef} addons={addons} options={options} onData={onData} {...xtermProps} />;
2✔
102
};
103

104
export default Terminal;
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