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

EcrituresNumeriques / stylo / 14472219216

15 Apr 2025 02:37PM UTC coverage: 31.374% (-0.01%) from 31.388%
14472219216

push

github

web-flow
chore: utilise SWR pour gérer les versions d'un article (#1370)

470 of 708 branches covered (66.38%)

Branch coverage included in aggregate %.

53 of 436 new or added lines in 16 files covered. (12.16%)

233 existing lines in 11 files now uncovered.

4521 of 15200 relevant lines covered (29.74%)

2.21 hits per line

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

0.0
/front/src/components/collaborative/CollaborativeEditorMenu.jsx
1
import clsx from 'clsx'
×
NEW
2
import { ArrowLeft, ChevronRight, ExternalLink, Printer } from 'lucide-react'
×
3
import React, { useState } from 'react'
×
4
import { useTranslation } from 'react-i18next'
×
NEW
5
import { useHistory } from 'react-router-dom'
×
6
import { useArticleWorkingCopy } from '../../hooks/article.js'
×
7
import useFetchData from '../../hooks/graphql.js'
×
8

9
import { getArticleInfo } from '../Article.graphql'
×
10
import Export from '../Export.jsx'
×
11
import Loading from '../molecules/Loading.jsx'
×
12
import Sidebar from '../Sidebar.jsx'
×
13
import ArticleBibliography from '../bibliography/ArticleBibliography.jsx'
×
14
import ArticleMetadata from '../Write/ArticleMetadata.jsx'
×
NEW
15
import ArticleTableOfContents from './ArticleTableOfContents.jsx'
×
16

NEW
17
import styles from './CollaborativeEditorMenu.module.scss'
×
18

19
export default function CollaborativeEditorMenu({ articleId }) {
×
UNCOV
20
  const { t } = useTranslation()
×
NEW
21
  const [opened, setOpened] = useState(false)
×
22
  const [activeMenu, setActiveMenu] = useState('')
×
23
  const { article } = useArticleWorkingCopy({ articleId })
×
24
  const { data, isLoading } = useFetchData(
×
25
    { query: getArticleInfo, variables: { articleId } },
×
26
    {
×
27
      revalidateIfStale: false,
×
28
      revalidateOnFocus: false,
×
29
      revalidateOnReconnect: false,
×
30
    }
×
31
  )
×
32

33
  if (isLoading) {
×
UNCOV
34
    return <Loading />
×
35
  }
×
36

37
  const metadata = article?.workingVersion?.metadata
×
38

39
  return (
×
UNCOV
40
    <div className={styles.menu} role="menu">
×
41
      <Sidebar
×
42
        className={clsx(styles.container, opened && styles.opened)}
×
43
        opened={opened}
×
44
        setOpened={setOpened}
×
45
        labelOpened={t('editorMenu.open.label')}
×
46
        labelClosed={t('editorMenu.close.label')}
×
47
      >
48
        <section>
×
UNCOV
49
          {activeMenu === '' && (
×
50
            <div className={styles.entries}>
×
51
              <a href="#" onClick={() => setActiveMenu('toc')}>
×
52
                {t('toc.title')}
×
53
                <ChevronRight
×
54
                  style={{ strokeWidth: 3 }}
×
55
                  height={32}
×
56
                  width={32}
×
57
                />
×
58
              </a>
×
59
              <a href="#" onClick={() => setActiveMenu('metadata')}>
×
60
                {t('metadata.title')}
×
61
                <ChevronRight
×
62
                  style={{ strokeWidth: 3 }}
×
63
                  height={32}
×
64
                  width={32}
×
65
                />
×
66
              </a>
×
67
              <a href="#" onClick={() => setActiveMenu('bibliography')}>
×
68
                {t('bibliography.title')}
×
69
                <ChevronRight
×
70
                  style={{ strokeWidth: 3 }}
×
71
                  height={32}
×
72
                  width={32}
×
73
                />
×
74
              </a>
×
75

76
              <a
×
UNCOV
77
                href="#"
×
NEW
78
                onClick={() => setActiveMenu('export')}
×
NEW
79
                title="Download a printable version"
×
80
              >
NEW
81
                {t('export.title')}
×
NEW
82
                <ChevronRight
×
NEW
83
                  style={{ strokeWidth: 3 }}
×
NEW
84
                  height={32}
×
NEW
85
                  width={32}
×
86
                />
×
87
              </a>
×
88

89
              <a
×
UNCOV
90
                href={`/article/${articleId}/preview`}
×
91
                title="Preview (open a new window)"
×
92
                target="_blank"
×
93
                rel="noopener noreferrer"
×
94
                className={styles.external}
×
95
              >
96
                {t('annotate.title')}
×
97
              </a>
×
UNCOV
98
            </div>
×
99
          )}
100
          <div className={styles.content}>
×
101
            {activeMenu === 'metadata' && (
×
102
              <ArticleMetadata
×
103
                onBack={() => setActiveMenu('')}
×
UNCOV
104
                metadata={metadata}
×
105
                readOnly={true}
×
106
              />
×
107
            )}
UNCOV
108
            {activeMenu === 'toc' && (
×
109
              <ArticleTableOfContents onBack={() => setActiveMenu('')} />
×
110
            )}
111
            {activeMenu === 'bibliography' && (
×
112
              <ArticleBibliography
×
113
                articleId={articleId}
×
114
                onBack={() => setActiveMenu('')}
×
115
              />
×
116
            )}
117
            {activeMenu === 'export' && (
×
118
              <>
×
UNCOV
119
                <h2
×
120
                  className={styles.title}
×
121
                  onClick={() => setActiveMenu('')}
×
122
                  style={{ cursor: 'pointer', userSelect: 'none' }}
×
123
                >
124
                  <span style={{ display: 'flex' }}>
×
UNCOV
125
                    <ArrowLeft style={{ strokeWidth: 3 }} />
×
126
                  </span>
×
127
                  <span>{t('export.title')}</span>
×
128
                </h2>
×
129
                <Export
×
130
                  articleId={articleId}
×
131
                  name={data?.article?.title}
×
UNCOV
132
                  bib={data?.article?.workingVersion?.bibPreview}
×
133
                />
×
134
              </>
×
135
            )}
136
          </div>
×
137
        </section>
×
138
      </Sidebar>
×
139
    </div>
×
140
  )
141
}
×
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