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

EcrituresNumeriques / stylo / 13659652556

04 Mar 2025 05:41PM UTC coverage: 28.444%. Remained the same
13659652556

push

github

web-flow
Supprime `CurrentUserContext` (#1316)

* fix: en fait, on n'utilisait même pas l'info ActiveUser pour créer un tag

* fix: supprime le UserContext… qui n'étaient pas utilisés

---------

Co-authored-by: Thomas Parisot <thom4parisot@users.noreply.github.com>

400 of 601 branches covered (66.56%)

Branch coverage included in aggregate %.

0 of 120 new or added lines in 3 files covered. (0.0%)

38 existing lines in 4 files now uncovered.

3905 of 14534 relevant lines covered (26.87%)

1.92 hits per line

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

0.0
/front/src/components/workspace/Workspaces.jsx
1
import { Button, useModal } from '@geist-ui/core'
×
2
import React, { useEffect, useState } from 'react'
×
3
import { Search } from 'react-feather'
×
4
import { useTranslation } from 'react-i18next'
×
5
import { shallowEqual, useSelector } from 'react-redux'
×
6
import { Helmet } from 'react-helmet'
×
7

8
import Field from '../../components/Field.jsx'
×
9

10
import WorkspaceItem from '../../components/workspace/WorkspaceItem.jsx'
×
11

12
import { CurrentUserContext } from '../../contexts/CurrentUser'
×
13
import { useGraphQLClient } from '../../helpers/graphQL.js'
×
14
import { useWorkspaces } from '../../hooks/workspace.js'
×
15
import Loading from '../Loading.jsx'
×
16
import CreateWorkspaceModal from './CreateWorkspaceModal.jsx'
×
UNCOV
17
import { getUserStats } from './Workspaces.graphql'
×
18

UNCOV
19
import styles from './workspaces.module.scss'
×
20

21
export default function Workspaces() {
×
22
  const { t } = useTranslation()
×
23
  const activeUser = useSelector((state) => state.activeUser, shallowEqual)
×
24
  const [filter, setFilter] = useState('')
×
25
  const { workspaces, error, isLoading } = useWorkspaces()
×
UNCOV
26
  const workspaceCreateModal = useModal()
×
27

28
  const [personalWorkspace, setPersonalWorkspace] = useState({
×
29
    _id: activeUser._id,
×
30
    personal: true,
×
31
    members: [],
×
32
  })
×
UNCOV
33
  const { query } = useGraphQLClient()
×
34

35
  useEffect(() => {
×
36
    ;(async () => {
×
37
      try {
×
38
        const getUserStatsResponse = await query({ query: getUserStats })
×
39
        const userStats = getUserStatsResponse.user.stats
×
40
        setPersonalWorkspace({
×
41
          _id: activeUser._id,
×
42
          personal: true,
×
43
          name: t('workspace.myspace'),
×
44
          description: '',
×
45
          color: '#D9D9D9',
×
46
          createdAt: activeUser.createdAt,
×
47
          updatedAt: activeUser.updatedAt,
×
48
          members: [],
×
49
          articlesCount:
×
50
            userStats.myArticlesCount + userStats.contributedArticlesCount,
×
51
        })
×
52
      } catch (err) {
×
53
        alert(err)
×
54
      }
×
55
    })()
×
UNCOV
56
  }, [activeUser._id, t])
×
57

58
  if (error) {
×
59
    return <div>Unable to load the workspaces</div>
×
60
  }
×
61
  if (isLoading) {
×
62
    return <Loading />
×
UNCOV
63
  }
×
64

NEW
65
  return (
×
66
    <CurrentUserContext.Provider value={activeUser}>
×
67
      <Helmet>
×
68
        <title>{t('workspace.title')}</title>
×
69
      </Helmet>
×
NEW
70
      <section className={styles.section}>
×
NEW
71
        <h1>{t('workspace.title')}</h1>
×
NEW
72
        <div>
×
NEW
73
          <Field
×
NEW
74
            className={styles.searchField}
×
NEW
75
            type="text"
×
NEW
76
            icon={Search}
×
NEW
77
            value={filter}
×
NEW
78
            placeholder={t('search.placeholder')}
×
NEW
79
            onChange={(e) => setFilter(e.target.value)}
×
NEW
80
          />
×
NEW
81
        </div>
×
NEW
82
        <Button
×
NEW
83
          type="secondary"
×
NEW
84
          className={styles.button}
×
NEW
85
          onClick={() => workspaceCreateModal.setVisible(true)}
×
86
        >
NEW
87
          {t('workspace.createNew.button')}
×
88
        </Button>
×
89

NEW
90
        <CreateWorkspaceModal {...workspaceCreateModal} />
×
91

NEW
92
        <ul className={styles.workspacesList}>
×
NEW
93
          {[personalWorkspace, ...workspaces].map((workspace) => (
×
NEW
94
            <li key={`workspace-${workspace._id}`}>
×
NEW
95
              <WorkspaceItem workspace={workspace} />
×
NEW
96
            </li>
×
NEW
97
          ))}
×
NEW
98
        </ul>
×
99
      </section>
×
100
    </CurrentUserContext.Provider>
×
101
  )
UNCOV
102
}
×
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