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

EcrituresNumeriques / stylo / 13141758304

04 Feb 2025 05:55PM UTC coverage: 26.581% (+0.8%) from 25.809%
13141758304

push

github

web-flow
Merge pull request #1188 from ggrossetie/fix-1171-hooks-usegraphql

342 of 546 branches covered (62.64%)

Branch coverage included in aggregate %.

54 of 303 new or added lines in 10 files covered. (17.82%)

2 existing lines in 2 files now uncovered.

3567 of 14160 relevant lines covered (25.19%)

1.66 hits per line

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

0.0
/front/src/components/workspace/WorkspaceSelectItem.jsx
1
import React, { useCallback } from 'react'
×
2
import { useSelector } from 'react-redux'
×
3
import clsx from 'clsx'
×
4
import PropTypes from 'prop-types'
×
5

NEW
6
import { removeArticle, addArticle } from './Workspaces.graphql'
×
7
import styles from './WorkspaceSelectItem.module.scss'
×
8
import { useGraphQL } from '../../helpers/graphQL.js'
×
9

10
export default function WorkspaceSelectItem({
×
11
  articleId,
×
12
  selected,
×
13
  id,
×
14
  color,
×
15
  name,
×
16
  onChange,
×
17
}) {
×
18
  const runQuery = useGraphQL()
×
19
  const activeUser = useSelector((state) => state.activeUser)
×
20
  const toggleWorkspaceArticle = useCallback(
×
21
    async (event) => {
×
22
      event.preventDefault()
×
23
      const [id, checked] = [event.target.value, event.target.checked]
×
24
      const query = checked ? addArticle : removeArticle
×
25
      await runQuery({
×
26
        query,
×
27
        variables: { articleId: articleId, workspaceId: id },
×
28
      })
×
29
      onChange({ workspaceId: id })
×
30
    },
×
31
    [articleId, id]
×
32
  )
×
33
  return (
×
34
    <>
×
35
      <li
×
36
        className={
×
37
          activeUser.activeWorkspaceId === id ? clsx(styles.active) : ''
×
38
        }
39
      >
40
        <label className={clsx(styles.workspace, selected && styles.selected)}>
×
41
          <input
×
42
            name={id}
×
43
            value={id}
×
44
            data-id={id}
×
45
            type="checkbox"
×
46
            checked={selected}
×
47
            onChange={toggleWorkspaceArticle}
×
48
          />
×
49
          <span>{name}</span>
×
50
          <span className={styles.chip} style={{ backgroundColor: color }} />
×
51
        </label>
×
52
      </li>
×
53
    </>
×
54
  )
55
}
×
56

57
WorkspaceSelectItem.propTypes = {
×
58
  name: PropTypes.string.isRequired,
×
59
  color: PropTypes.string.isRequired,
×
60
  id: PropTypes.string,
×
61
  selected: PropTypes.bool,
×
62
  articleId: PropTypes.string.isRequired,
×
63
  onChange: PropTypes.func,
×
64
}
×
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

© 2026 Coveralls, Inc