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

EcrituresNumeriques / stylo / 12925854411

23 Jan 2025 09:11AM UTC coverage: 25.831% (-4.7%) from 30.523%
12925854411

push

github

web-flow
Merge pull request #1192 from EcrituresNumeriques/feat/vite6

322 of 518 branches covered (62.16%)

Branch coverage included in aggregate %.

3448 of 14077 relevant lines covered (24.49%)

1.66 hits per line

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

0.0
/front/src/components/collaborative/CollaborativeEditorStatus.jsx
1
import {
×
2
  Button,
3
  Modal as GeistModal,
4
  useModal,
5
  useToasts,
6
} from '@geist-ui/core'
7
import clsx from 'clsx'
×
8
import PropTypes from 'prop-types'
×
9
import React, { useCallback } from 'react'
×
10
import { StopCircle } from 'react-feather'
×
11
import { useTranslation } from 'react-i18next'
×
12
import { useHistory } from 'react-router-dom'
×
13
import { useMutation } from '../../hooks/graphql.js'
×
14
import CollaborativeEditorWebSocketStatus from './CollaborativeEditorWebSocketStatus.jsx'
×
15
import CollaborativeEditorWriters from './CollaborativeEditorWriters.jsx'
×
16

17
import { stopCollaborativeSession } from './CollaborativeSession.graphql'
×
18

19
import styles from './CollaborativeEditorStatus.module.scss'
×
20

21
export default function CollaborativeEditorStatus({
×
22
  articleId,
×
23
  websocketStatus,
×
24
  collaborativeSessionState,
×
25
}) {
×
26
  const { t } = useTranslation()
×
27
  const mutation = useMutation()
×
28
  const { setToast } = useToasts()
×
29
  const history = useHistory()
×
30

31
  const {
×
32
    visible: collaborativeSessionEndVisible,
×
33
    setVisible: setCollaborativeSessionEndVisible,
×
34
    bindings: collaborativeSessionEndBinding,
×
35
  } = useModal()
×
36

37
  const handleEndCollaborativeSession = useCallback(async () => {
×
38
    try {
×
39
      await mutation({
×
40
        query: stopCollaborativeSession,
×
41
        variables: { articleId },
×
42
      })
×
43
      setToast({
×
44
        type: 'default',
×
45
        text: 'Collaborative session ended',
×
46
      })
×
47
      history.push('/articles')
×
48
    } catch (err) {
×
49
      setToast({
×
50
        type: 'error',
×
51
        text: 'Unable to stop the collaborative session: ' + err.toString(),
×
52
      })
×
53
    }
×
54
  }, [mutation])
×
55

56
  const handleConfirmCollaborativeSessionEnd = useCallback(async () => {
×
57
    setCollaborativeSessionEndVisible(true)
×
58
  }, [])
×
59

60
  return (
×
61
    <>
×
62
      <div className={styles.row}>
×
63
        <div className={styles.writers}>
×
64
          <CollaborativeEditorWriters />
×
65
        </div>
×
66
        <div className={styles.status}>
×
67
          <CollaborativeEditorWebSocketStatus
×
68
            status={websocketStatus}
×
69
            state={collaborativeSessionState}
×
70
          />
×
71
        </div>
×
72
        {websocketStatus === 'connected' &&
×
73
          collaborativeSessionState === 'started' && (
×
74
            <Button
×
75
              className={clsx(styles.button)}
×
76
              type="error"
×
77
              ghost
×
78
              auto
×
79
              scale={0.4}
×
80
              onClick={handleConfirmCollaborativeSessionEnd}
×
81
            >
82
              <StopCircle /> End collaborative session
×
83
            </Button>
×
84
          )}
85
      </div>
×
86
      <GeistModal
×
87
        width="35rem"
×
88
        visible={collaborativeSessionEndVisible}
×
89
        {...collaborativeSessionEndBinding}
×
90
        onClose={handleEndCollaborativeSession}
×
91
      >
92
        <h2>{t('article.collaborativeSessionEnd.title')}</h2>
×
93
        <GeistModal.Content>
×
94
          {t('article.collaborativeSessionEnd.confirmMessage')}
×
95
        </GeistModal.Content>
×
96
        <GeistModal.Action
×
97
          passive
×
98
          onClick={() => setCollaborativeSessionEndVisible(false)}
×
99
        >
100
          {t('modal.cancelButton.text')}
×
101
        </GeistModal.Action>
×
102
        <GeistModal.Action onClick={handleEndCollaborativeSession}>
×
103
          {t('modal.confirmButton.text')}
×
104
        </GeistModal.Action>
×
105
      </GeistModal>
×
106
    </>
×
107
  )
108
}
×
109

110
CollaborativeEditorStatus.propTypes = {
×
111
  articleId: PropTypes.string.isRequired,
×
112
  websocketStatus: PropTypes.string.isRequired,
×
113
  collaborativeSessionState: PropTypes.string.isRequired,
×
114
}
×
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