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

EcrituresNumeriques / stylo / 15066626824

16 May 2025 10:41AM UTC coverage: 37.574% (-0.02%) from 37.594%
15066626824

Pull #1517

github

web-flow
Merge e05a1c169 into 607ffe7f9
Pull Request #1517: Mise à jour vers react-router@7

549 of 776 branches covered (70.75%)

Branch coverage included in aggregate %.

13 of 373 new or added lines in 28 files covered. (3.49%)

5 existing lines in 4 files now uncovered.

5319 of 14841 relevant lines covered (35.84%)

2.56 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 React, { useCallback } from 'react'
×
2
import clsx from 'clsx'
×
3
import { ArrowLeft, ChevronRight } from 'lucide-react'
×
4
import { useTranslation } from 'react-i18next'
×
5

6
import { usePreferenceItem } from '../../hooks/user.js'
×
7
import { useArticleWorkingCopy } from '../../hooks/article.js'
×
8
import useFetchData from '../../hooks/graphql.js'
×
9

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'
×
15
import ArticleTableOfContents from './ArticleTableOfContents.jsx'
×
16
import CollaborativeVersions from './CollaborativeVersions.jsx'
×
17

18
import { getArticleInfo } from '../Article.graphql'
×
19

20
import styles from './CollaborativeEditorMenu.module.scss'
×
21

NEW
22
export default function CollaborativeEditorMenu({ articleId, className, versionId }) {
×
23
  const { t } = useTranslation()
×
24
  const { value: opened, toggleValue: setOpened } = usePreferenceItem(
×
25
    'expandSidebarRight',
×
26
    'article'
×
27
  )
×
28
  const { value: activeMenu, setValue: setActiveMenu } = usePreferenceItem(
×
29
    'activePanel',
×
30
    'article'
×
31
  )
×
32

33
  const onBack = useCallback(() => setActiveMenu(null), [])
×
34

35
  const { article, updateMetadata } = useArticleWorkingCopy({ articleId })
×
36
  const { data, isLoading } = useFetchData(
×
37
    { query: getArticleInfo, variables: { articleId } },
×
38
    {
×
39
      revalidateIfStale: false,
×
40
      revalidateOnFocus: false,
×
41
      revalidateOnReconnect: false,
×
42
    }
×
43
  )
×
44

45
  if (isLoading) {
×
46
    return <Loading />
×
47
  }
×
48

49
  const metadata = article?.workingVersion?.metadata
×
50

51
  return (
×
52
    <Sidebar
×
NEW
53
      className={clsx(className, opened && styles.opened)}
×
54
      opened={opened}
×
55
      setOpened={setOpened}
×
56
      labelOpened={t('editorMenu.open.label')}
×
57
      labelClosed={t('editorMenu.close.label')}
×
58
    >
59
      {!activeMenu && (
×
60
        <ul
×
61
          className={styles.entries}
×
62
          role="menubar"
×
63
          aria-orientation="vertical"
×
64
        >
65
          <li role="menuitem">
×
66
            <button onClick={() => setActiveMenu('toc')}>
×
67
              {t('toc.title')}
×
68
              <ChevronRight
×
69
                style={{ strokeWidth: 3 }}
×
70
                height={32}
×
71
                width={32}
×
72
                aria-hidden
×
73
              />
×
74
            </button>
×
75
          </li>
×
76

77
          <li role="menuitem">
×
78
            <button onClick={() => setActiveMenu('metadata')}>
×
79
              {t('metadata.title')}
×
80
              <ChevronRight
×
81
                style={{ strokeWidth: 3 }}
×
82
                height={32}
×
83
                width={32}
×
84
                aria-hidden
×
85
              />
×
86
            </button>
×
87
          </li>
×
88

89
          <li role="menuitem">
×
90
            <button onClick={() => setActiveMenu('bibliography')}>
×
91
              {t('bibliography.title')}
×
92
              <ChevronRight
×
93
                style={{ strokeWidth: 3 }}
×
94
                height={32}
×
95
                width={32}
×
96
                aria-hidden
×
97
              />
×
98
            </button>
×
99
          </li>
×
100

101
          <li role="menuitem">
×
102
            <button onClick={() => setActiveMenu('versions')}>
×
103
              {t('versions.title')}
×
104
              <ChevronRight
×
105
                style={{ strokeWidth: 3 }}
×
106
                height={32}
×
107
                width={32}
×
108
                aria-hidden
×
109
              />
×
110
            </button>
×
111
          </li>
×
112
          <li role="menuitem">
×
113
            <button
×
114
              onClick={() => setActiveMenu('export')}
×
115
              title="Download a printable version"
×
116
            >
117
              {t('export.title')}
×
118
              <ChevronRight
×
119
                style={{ strokeWidth: 3 }}
×
120
                height={32}
×
121
                width={32}
×
122
                aria-hidden
×
123
              />
×
124
            </button>
×
125
          </li>
×
126
          <li role="menuitem">
×
127
            <a
×
128
              href={`/article/${articleId}/annotate`}
×
129
              title="Preview (open a new window)"
×
130
              target="_blank"
×
131
              rel="noopener noreferrer"
×
132
              className={styles.external}
×
133
            >
134
              {t('annotate.title')}
×
135
            </a>
×
136
          </li>
×
137
        </ul>
×
138
      )}
139

140
      <div className={styles.content}>
×
141
        {activeMenu === 'metadata' && (
×
142
          <ArticleMetadata
×
143
            onBack={onBack}
×
144
            metadata={metadata}
×
145
            onChange={(metadata) => updateMetadata(metadata)}
×
146
          />
×
147
        )}
148
        {activeMenu === 'toc' && <ArticleTableOfContents onBack={onBack} />}
×
149
        {activeMenu === 'bibliography' && (
×
150
          <ArticleBibliography articleId={articleId} onBack={onBack} />
×
151
        )}
152
        {activeMenu === 'export' && (
×
153
          <>
×
154
            <h2
×
155
              className={styles.title}
×
156
              onClick={onBack}
×
157
              style={{ cursor: 'pointer', userSelect: 'none' }}
×
158
            >
159
              <span style={{ display: 'flex' }}>
×
160
                <ArrowLeft style={{ strokeWidth: 3 }} />
×
161
              </span>
×
162
              <span>{t('export.title')}</span>
×
163
            </h2>
×
164
            <Export
×
165
              articleId={articleId}
×
166
              name={data?.article?.title}
×
167
              bib={data?.article?.workingVersion?.bibPreview}
×
168
            />
×
169
          </>
×
170
        )}
171
        {activeMenu === 'versions' && (
×
172
          <CollaborativeVersions
×
173
            articleId={articleId}
×
174
            selectedVersion={versionId}
×
175
            showTitle={true}
×
176
            onBack={onBack}
×
177
          />
×
178
        )}
179
      </div>
×
180
    </Sidebar>
×
181
  )
182
}
×
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