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

mendersoftware / gui / 1350829378

27 Jun 2024 01:46PM UTC coverage: 83.494% (-16.5%) from 99.965%
1350829378

Pull #4465

gitlab-ci

mzedel
chore: test fixes

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #4465: MEN-7169 - feat: added multi sorting capabilities to devices view

4506 of 6430 branches covered (70.08%)

81 of 100 new or added lines in 14 files covered. (81.0%)

1661 existing lines in 163 files now uncovered.

8574 of 10269 relevant lines covered (83.49%)

160.6 hits per line

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

70.0
/src/js/components/releases/dialogs/addTags.js
1
// Copyright 2024 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
import { FormProvider, useForm } from 'react-hook-form';
16
import { useDispatch } from 'react-redux';
17

18
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
19
import { makeStyles } from 'tss-react/mui';
20

21
import { setReleaseTags, setReleasesListState } from '../../../actions/releaseActions.js';
22
import ChipSelect from '../../common/chipselect.js';
23

24
const useStyles = makeStyles()(theme => ({
5✔
25
  DialogContent: {
26
    padding: 0,
27
    margin: 30
28
  },
29
  DialogActions: {
30
    padding: `${theme.spacing()} ${theme.spacing(3)}`
31
  },
32
  tagSelect: { marginRight: theme.spacing(2), maxWidth: 350 }
33
}));
34

35
export const AddTagsDialog = ({ selectedReleases, onClose }) => {
5✔
36
  const [initialValues] = useState({ tags: [] });
1✔
37
  const [disableSave, setDisableSave] = useState(true);
1✔
38
  const inputName = 'tags';
1✔
39
  const { classes } = useStyles();
1✔
40

41
  const methods = useForm({ mode: 'onChange', defaultValues: initialValues });
1✔
42
  const { watch, getValues } = methods;
1✔
43
  const watchTagsInput = watch([inputName]);
1✔
44
  const dispatch = useDispatch();
1✔
45

46
  const addTagsToReleases = () => {
1✔
UNCOV
47
    const tags = getValues(inputName);
×
UNCOV
48
    dispatch(setReleasesListState({ loading: true })).then(() => {
×
UNCOV
49
      const addRequests = selectedReleases.reduce((accu, release) => {
×
UNCOV
50
        accu.push(dispatch(setReleaseTags(release.name, [...new Set([...release.tags, ...tags])])));
×
UNCOV
51
        return accu;
×
52
      }, []);
UNCOV
53
      return Promise.all(addRequests).then(onClose);
×
54
    });
55
  };
56

57
  useEffect(() => {
1✔
58
    setDisableSave(!getValues('tags').length);
1✔
59
  }, [getValues, watchTagsInput]);
60

61
  return (
1✔
62
    <Dialog open={true} fullWidth={true} maxWidth="sm">
63
      <DialogTitle>Add tags to Releases</DialogTitle>
64
      <DialogContent className={`${classes.DialogContent}`}>
65
        <div className="margin-bottom">Add tags to the selected Releases. If a Release already has the tag, it won’t be added again.</div>
66
        <FormProvider {...methods}>
67
          <form noValidate>
68
            <ChipSelect className={classes.tagSelect} label="" name={inputName} placeholder="Enter release tags" />
69
          </form>
70
        </FormProvider>
71
      </DialogContent>
72
      <DialogActions className={`flexbox space-between margin-top-none ${classes.DialogActions}`}>
73
        <Button style={{ marginRight: 10 }} onClick={onClose}>
74
          Cancel
75
        </Button>
76
        <Button variant="contained" color="primary" disabled={disableSave} onClick={addTagsToReleases}>
77
          Add tags
78
        </Button>
79
      </DialogActions>
80
    </Dialog>
81
  );
82
};
83

84
export default AddTagsDialog;
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