• 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

93.75
/src/js/components/common/timerange-picker.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, { useEffect, useState } from 'react';
15

16
import { getISOStringBoundaries } from '../../helpers';
17
import ClickFilter from './forms/clickfilter';
18

19
const timeranges = {
9✔
20
  today: { start: 0, end: 0, title: 'Today' },
21
  yesterday: { start: 1, end: 1, title: 'Yesterday' },
22
  week: { start: 6, end: 0, title: 'Last 7 days' },
23
  month: { start: 29, end: 0, title: 'Last 30 days' }
24
};
25

26
export const TimerangePicker = ({ classNames = '', disabled = false, endDate, onChange, startDate }) => {
9✔
27
  const [active, setActive] = useState();
95✔
28

29
  useEffect(() => {
95✔
30
    if (!(endDate && startDate)) {
15✔
31
      setActive(Object.keys(timeranges)[0]);
9✔
32
      return;
9✔
33
    }
34
    if (!(endDate || startDate)) {
6!
35
      setActive();
×
36
      return;
×
37
    }
38
    const currentRange = Object.entries(timeranges).reduce((accu, [key, range]) => {
6✔
39
      let rangeEndDate = new Date();
24✔
40
      rangeEndDate.setDate(rangeEndDate.getDate() - (range.end || 0));
24✔
41
      const { end } = getISOStringBoundaries(rangeEndDate);
24✔
42
      let rangeStartDate = new Date();
24✔
43
      rangeStartDate.setDate(rangeStartDate.getDate() - (range.start || 0));
24✔
44
      const { start } = getISOStringBoundaries(rangeStartDate);
24✔
45
      if (startDate == start && endDate == end) {
24✔
46
        return key;
5✔
47
      }
48
      return accu;
19✔
49
    }, undefined);
50
    setActive(currentRange);
6✔
51
  }, [endDate, startDate]);
52

53
  const setRange = (after, before) => {
95✔
54
    let newStartDate = new Date();
3✔
55
    newStartDate.setDate(newStartDate.getDate() - (after || 0));
3!
56
    const { start } = getISOStringBoundaries(newStartDate);
3✔
57
    let newEndDate = new Date();
3✔
58
    newEndDate.setDate(newEndDate.getDate() - (before || 0));
3✔
59
    const { end } = getISOStringBoundaries(newEndDate);
3✔
60
    onChange(start, end);
3✔
61
  };
62

63
  return (
95✔
64
    <ClickFilter disabled={disabled}>
65
      <div className={`${classNames} ${disabled ? 'muted' : ''}`}>
95!
66
        <span>Filter by date</span>
67
        <ul className="unstyled link-list horizontal">
68
          {Object.entries(timeranges).map(([key, range]) => (
69
            <li key={`filter-by-${key}`}>
380✔
70
              <a className={active === key ? 'active' : ''} onClick={() => setRange(range.start, range.end)}>
3✔
71
                {range.title}
72
              </a>
73
            </li>
74
          ))}
75
        </ul>
76
      </div>
77
    </ClickFilter>
78
  );
79
};
80

81
export default TimerangePicker;
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