• 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

72.92
/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, { useCallback, useMemo, useRef } from 'react';
15
import Dropzone from 'react-dropzone';
16
import { useDispatch, useSelector } from 'react-redux';
17

18
import { makeStyles } from 'tss-react/mui';
19

20
import { setSnackbar } from '../../actions/appActions';
21
import { selectRelease, setReleasesListState } from '../../actions/releaseActions';
22
import { SORTING_OPTIONS, canAccess as canShow } from '../../constants/appConstants';
23
import { DEVICE_LIST_DEFAULTS } from '../../constants/deviceConstants';
24
import { getFeatures, getReleasesList, getUserCapabilities } from '../../selectors';
25
import DetailsTable from '../common/detailstable';
26
import Loader from '../common/loader';
27
import Pagination from '../common/pagination';
28
import { RelativeTime } from '../common/time';
29

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

61
const useStyles = makeStyles()(() => ({
5✔
62
  container: { maxWidth: 1600 },
63
  empty: { margin: '8vh auto' }
64
}));
65

66
const { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
5✔
67

68
const EmptyState = ({ canUpload, className = '', dropzoneRef, uploading, onDrop, onUpload }) => (
5!
69
  <div className={`dashboard-placeholder fadeIn ${className}`} ref={dropzoneRef}>
×
70
    <Dropzone activeClassName="active" disabled={uploading} multiple={false} noClick={true} onDrop={onDrop} rejectClassName="active">
71
      {({ getRootProps, getInputProps }) => (
72
        <div {...getRootProps({ className: uploading ? 'dropzone disabled muted' : 'dropzone' })} onClick={() => onUpload()}>
×
73
          <input {...getInputProps()} disabled={uploading} />
74
          <p>
75
            There are no Releases yet.{' '}
76
            {canUpload && (
×
77
              <>
78
                <a>Upload an Artifact</a> to create a new Release
79
              </>
80
            )}
81
          </p>
82
        </div>
83
      )}
84
    </Dropzone>
85
  </div>
86
);
87

88
export const ReleasesList = ({ onFileUploadClick }) => {
5✔
89
  const repoRef = useRef();
28✔
90
  const dropzoneRef = useRef();
28✔
91
  const uploading = useSelector(state => state.app.uploading);
53✔
92
  const hasReleases = useSelector(
28✔
93
    state => !!(Object.keys(state.releases.byId).length || state.releases.releasesList.total || state.releases.releasesList.searchTotal)
53!
94
  );
95
  const features = useSelector(getFeatures);
28✔
96
  const releases = useSelector(getReleasesList);
28✔
97
  const releasesListState = useSelector(state => state.releases.releasesList);
53✔
98
  const userCapabilities = useSelector(getUserCapabilities);
28✔
99
  const dispatch = useDispatch();
28✔
100
  const { classes } = useStyles();
28✔
101

102
  const { canUploadReleases } = userCapabilities;
28✔
103
  const { isLoading, page = defaultPage, perPage = defaultPerPage, searchTerm, sort = {}, searchTotal, total } = releasesListState;
28!
104
  const { key: attribute, direction } = sort;
28✔
105

106
  const onSelect = useCallback(id => dispatch(selectRelease(id)), [dispatch]);
28✔
107

108
  const onChangeSorting = sortKey => {
28✔
109
    let sort = { key: sortKey, direction: direction === SORTING_OPTIONS.asc ? SORTING_OPTIONS.desc : SORTING_OPTIONS.asc };
×
110
    if (sortKey !== attribute) {
×
111
      sort = { ...sort, direction: columns.find(({ key }) => key === sortKey)?.defaultSortDirection ?? SORTING_OPTIONS.desc };
×
112
    }
113
    dispatch(setReleasesListState({ page: 1, sort }));
×
114
  };
115

116
  const onChangePagination = (page, currentPerPage = perPage) => dispatch(setReleasesListState({ page, perPage: currentPerPage }));
28!
117

118
  const onDrop = (acceptedFiles, rejectedFiles) => {
28✔
119
    if (acceptedFiles.length) {
×
120
      onFileUploadClick(acceptedFiles[0]);
×
121
    }
122
    if (rejectedFiles.length) {
×
123
      dispatch(setSnackbar(`File '${rejectedFiles[0].name}' was rejected. File should be of type .mender`, null));
×
124
    }
125
  };
126

127
  const applicableColumns = useMemo(
28✔
128
    () =>
129
      columns.reduce((accu, column) => {
5✔
130
        if (column.canShow({ features })) {
20✔
131
          accu.push(column);
15✔
132
        }
133
        return accu;
20✔
134
      }, []),
135
    // eslint-disable-next-line react-hooks/exhaustive-deps
136
    [JSON.stringify(features)]
137
  );
138

139
  const potentialTotal = searchTerm ? searchTotal : total;
28✔
140
  if (!hasReleases) {
28!
141
    return (
×
142
      <EmptyState
143
        canUpload={canUploadReleases}
144
        className={classes.empty}
145
        dropzoneRef={dropzoneRef}
146
        uploading={uploading}
147
        onDrop={onDrop}
148
        onUpload={onFileUploadClick}
149
      />
150
    );
151
  }
152

153
  return (
28✔
154
    <div className={classes.container}>
155
      {isLoading === undefined ? (
28!
156
        <Loader show />
157
      ) : !potentialTotal ? (
28✔
158
        <p className="margin-top muted align-center margin-right">There are no Releases {searchTerm ? `for ${searchTerm}` : 'yet'}</p>
1!
159
      ) : (
160
        <>
161
          <DetailsTable columns={applicableColumns} items={releases} onItemClick={onSelect} sort={sort} onChangeSorting={onChangeSorting} tableRef={repoRef} />
162
          <div className="flexbox">
163
            <Pagination
164
              className="margin-top-none"
165
              count={potentialTotal}
166
              rowsPerPage={perPage}
167
              onChangePage={onChangePagination}
168
              onChangeRowsPerPage={newPerPage => onChangePagination(1, newPerPage)}
×
169
              page={page}
170
            />
171
            <Loader show={isLoading} small />
172
          </div>
173
        </>
174
      )}
175
    </div>
176
  );
177
};
178

179
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