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

EcrituresNumeriques / stylo / 18488516340

14 Oct 2025 07:12AM UTC coverage: 39.528% (+0.1%) from 39.427%
18488516340

push

github

web-flow
feat(metadata): Ajout d'un formulaire pour les notes de réunion (#1697)

598 of 846 branches covered (70.69%)

Branch coverage included in aggregate %.

33 of 45 new or added lines in 1 file covered. (73.33%)

111 existing lines in 5 files now uncovered.

5938 of 15689 relevant lines covered (37.85%)

2.58 hits per line

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

82.46
/front/src/components/Write/yamleditor/ArticleEditorMetadataForm.jsx
1
import { merge } from 'allof-merge'
1✔
2
import React, { useCallback, useMemo, useState } from 'react'
1✔
3
import { useTranslation } from 'react-i18next'
1✔
4

5
import blogPostSchema from '../../../schemas/article-blog-post-metadata.schema.json'
1✔
6
import blogPostUiSchema from '../../../schemas/article-blog-post-ui-schema.json'
1✔
7
import meetingNotesSchema from '../../../schemas/article-meeting-notes-metadata.schema.json'
1✔
8
import meetingNotesUiSchema from '../../../schemas/article-meeting-notes-ui-schema.json'
1✔
9
import defaultSchema from '../../../schemas/article-metadata.schema.json'
1✔
10
import defaultUiSchema from '../../../schemas/article-ui-schema.json'
1✔
11
import Form from '../../Form'
1✔
12

13
import Select from '../../Select.jsx'
1✔
14

15
import styles from './ArticleEditorMetadataForm.module.scss'
1✔
16

17
const FormTypeDefaultOptions = [
1✔
18
  {
1✔
19
    name: 'default',
1✔
20
    data: defaultSchema,
1✔
21
    ui: defaultUiSchema,
1✔
22
  },
1✔
23
  {
1✔
24
    name: 'blog-post',
1✔
25
    data: blogPostSchema,
1✔
26
    ui: blogPostUiSchema,
1✔
27
  },
1✔
28
  {
1✔
29
    name: 'meeting-notes',
1✔
30
    data: meetingNotesSchema,
1✔
31
    ui: meetingNotesUiSchema,
1✔
32
  },
1✔
33
]
1✔
34

35
/**
36
 * @param {object} props properties
37
 * @param {any} props.metadata
38
 * @param {string} props.metadataFormType
39
 * @param {any} props.metadataFormTypeOptions
40
 * @param {boolean} props.readOnly
41
 * @param {(any) => void} props.onChange
42
 * @param {(any) => void} props.onTypeChange
43
 * @returns {Element}
44
 */
45
export default function ArticleEditorMetadataForm({
4✔
46
  metadata,
4✔
47
  metadataFormType = 'default',
4✔
48
  metadataFormTypeOptions = [],
4✔
49
  readOnly = false,
4✔
50
  onChange = () => {},
4✔
51
  onTypeChange = () => {},
4✔
52
}) {
4✔
53
  const [type, setType] = useState(metadataFormType)
4✔
54
  const schemaMerged = useMemo(() => {
4✔
55
    const defaultOption = FormTypeDefaultOptions.find((o) => o.name === type)
3✔
56
    if (defaultOption === undefined) {
3!
NEW
57
      const option = metadataFormTypeOptions.find((o) => o.name === type)
×
NEW
58
      if (option) {
×
NEW
59
        return merge(option.data)
×
NEW
60
      }
×
61
      // QUESTION: what should we do, if we can't find the form?
NEW
62
      return merge(
×
NEW
63
        FormTypeDefaultOptions.find((o) => o.name === 'default').data
×
NEW
64
      )
×
65
    } else {
3✔
66
      return merge(defaultOption.data)
3✔
67
    }
3✔
68
  }, [metadataFormTypeOptions, type])
4✔
69
  const uiSchema = useMemo(() => {
4✔
70
    const defaultOption = FormTypeDefaultOptions.find((o) => o.name === type)
3✔
71
    if (defaultOption === undefined) {
3!
NEW
72
      const option = metadataFormTypeOptions.find((o) => o.name === type)
×
NEW
73
      if (option) {
×
NEW
74
        return option.ui
×
NEW
75
      }
×
76
      // QUESTION: what should we do, if we can't find the form?
NEW
77
      return FormTypeDefaultOptions.find((o) => o.name === 'default').ui
×
78
    } else {
3✔
79
      return defaultOption.ui
3✔
80
    }
3✔
81
  }, [metadataFormTypeOptions, type])
4✔
82

83
  const handleChange = useCallback(
4✔
84
    (newFormData) => onChange(newFormData),
4✔
85
    [onChange]
4✔
86
  )
4✔
87

88
  const handleTypeChange = useCallback(
4✔
89
    (type) => {
4✔
90
      setType(type)
×
91
      onTypeChange(type)
×
92
    },
×
93
    [setType, onTypeChange]
4✔
94
  )
4✔
95

96
  const { t } = useTranslation()
4✔
97
  return (
4✔
98
    <>
4✔
99
      <div className={styles.header}>
4✔
100
        <Select
4✔
101
          disabled={readOnly}
4✔
102
          label={t('article.type.label')}
4✔
103
          value={type}
4✔
104
          onChange={(event) => handleTypeChange(event?.target?.value ?? event)}
4✔
105
        >
106
          <option value="default">{t('article.type.default')}</option>
4✔
107
          <option value="blog-post">{t('article.type.blogPost')}</option>
4✔
108
          <option value="meeting-notes">
4✔
109
            {t('article.type.meetingNotes')}
4✔
110
          </option>
4✔
111
          {metadataFormTypeOptions.map((option) => (
4✔
112
            <option key={option.name} value={option.name}>
×
113
              {option.name}
×
114
            </option>
×
115
          ))}
4✔
116
        </Select>
4✔
117
      </div>
4✔
118
      <Form
4✔
119
        readOnly={readOnly}
4✔
120
        formData={metadata}
4✔
121
        schema={schemaMerged}
4✔
122
        uiSchema={uiSchema}
4✔
123
        onChange={handleChange}
4✔
124
      />
4✔
125
    </>
4✔
126
  )
127
}
4✔
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