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

mendersoftware / gui / 963002358

pending completion
963002358

Pull #3870

gitlab-ci

mzedel
chore: cleaned up left over onboarding tooltips & aligned with updated design

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3870: MEN-5413

4348 of 6319 branches covered (68.81%)

95 of 122 new or added lines in 24 files covered. (77.87%)

1734 existing lines in 160 files now uncovered.

8174 of 9951 relevant lines covered (82.14%)

178.12 hits per line

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

62.75
/src/js/components/releases/releaseslist.js
1
// Copyright 2019 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, { useMemo, useRef } from 'react';
15

16
import { makeStyles } from 'tss-react/mui';
17

18
import { SORTING_OPTIONS, canAccess as canShow } from '../../constants/appConstants';
19
import { DEVICE_LIST_DEFAULTS } from '../../constants/deviceConstants';
20
import DetailsTable from '../common/detailstable';
21
import Loader from '../common/loader';
22
import Pagination from '../common/pagination';
23
import { RelativeTime } from '../common/time';
24

25
const columns = [
5✔
26
  {
27
    key: 'name',
28
    title: 'Name',
29
    render: ({ Name }) => Name,
142✔
30
    sortable: true,
31
    defaultSortDirection: SORTING_OPTIONS.asc,
32
    canShow
33
  },
34
  {
35
    key: 'artifacts-count',
36
    title: 'Number of artifacts',
37
    render: ({ Artifacts = [] }) => Artifacts.length,
142!
38
    canShow
39
  },
40
  {
41
    key: 'tags',
42
    title: 'Tags',
UNCOV
43
    render: ({ tags = [] }) => tags.join(', ') || '-',
×
44
    canShow: ({ features: { hasReleaseTags } }) => hasReleaseTags
5✔
45
  },
46
  {
47
    key: 'modified',
48
    title: 'Last modified',
49
    render: ({ modified }) => <RelativeTime updateTime={modified} />,
142✔
50
    defaultSortDirection: SORTING_OPTIONS.desc,
51
    sortable: true,
52
    canShow
53
  }
54
];
55

56
const useStyles = makeStyles()(() => ({
5✔
57
  container: { maxWidth: 1600 }
58
}));
59

60
const { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
5✔
61

62
export const ReleasesList = ({ features, onSelect, releasesListState, releases, setReleasesListState }) => {
5✔
63
  const { isLoading, page = defaultPage, perPage = defaultPerPage, searchTerm, sort = {}, searchTotal, total } = releasesListState;
30!
64
  const { key: attribute, direction } = sort;
30✔
65
  const repoRef = useRef();
30✔
66
  const { classes } = useStyles();
30✔
67

68
  const onChangeSorting = sortKey => {
30✔
UNCOV
69
    let sort = { key: sortKey, direction: direction === SORTING_OPTIONS.asc ? SORTING_OPTIONS.desc : SORTING_OPTIONS.asc };
×
UNCOV
70
    if (sortKey !== attribute) {
×
UNCOV
71
      sort = { ...sort, direction: columns.find(({ key }) => key === sortKey)?.defaultSortDirection ?? SORTING_OPTIONS.desc };
×
72
    }
UNCOV
73
    setReleasesListState({ page: 1, sort });
×
74
  };
75

76
  const onChangePagination = (page, currentPerPage = perPage) => setReleasesListState({ page, perPage: currentPerPage });
30!
77

78
  const applicableColumns = useMemo(
30✔
79
    () =>
80
      columns.reduce((accu, column) => {
5✔
81
        if (column.canShow({ features })) {
20✔
82
          accu.push(column);
15✔
83
        }
84
        return accu;
20✔
85
      }, []),
86
    // eslint-disable-next-line react-hooks/exhaustive-deps
87
    [JSON.stringify(features)]
88
  );
89

90
  const potentialTotal = searchTerm ? searchTotal : total;
30✔
91
  return (
30✔
92
    <div className={classes.container}>
93
      {isLoading === undefined ? (
30!
94
        <Loader show />
95
      ) : !potentialTotal ? (
30✔
96
        <p className="margin-top muted align-center margin-right">There are no Releases {searchTerm ? `for ${searchTerm}` : 'yet'}</p>
2✔
97
      ) : (
98
        <>
99
          <DetailsTable columns={applicableColumns} items={releases} onItemClick={onSelect} sort={sort} onChangeSorting={onChangeSorting} tableRef={repoRef} />
100
          <div className="flexbox">
101
            <Pagination
102
              className="margin-top-none"
103
              count={potentialTotal}
104
              rowsPerPage={perPage}
105
              onChangePage={onChangePagination}
UNCOV
106
              onChangeRowsPerPage={newPerPage => onChangePagination(1, newPerPage)}
×
107
              page={page}
108
            />
109
            <Loader show={isLoading} small />
110
          </div>
111
        </>
112
      )}
113
    </div>
114
  );
115
};
116

117
export default ReleasesList;
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