cozy-ui 111.21.0 → 112.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +3 -2
- package/react/FileImageLoader/Readme.md +66 -3
- package/react/FileImageLoader/index.jsx +3 -3
- package/react/FileImageLoader/index.spec.jsx +1 -1
- package/react/hooks/useClientErrors.jsx +140 -0
- package/react/hooks/useClientErrors.spec.jsx +102 -0
- package/react/index.js +0 -1
- package/transpiled/react/FileImageLoader/index.js +3 -3
- package/transpiled/react/hooks/useClientErrors.js +167 -0
- package/transpiled/react/index.js +0 -1
- package/transpiled/react/stylesheet.css +1 -1
- package/react/Viewer/Footer/BottomSheetContent.jsx +0 -29
- package/react/Viewer/Footer/DownloadButton.jsx +0 -67
- package/react/Viewer/Footer/FooterActionButtons.jsx +0 -22
- package/react/Viewer/Footer/FooterActionButtons.spec.jsx +0 -30
- package/react/Viewer/Footer/FooterContent.jsx +0 -99
- package/react/Viewer/Footer/ForwardButton.jsx +0 -95
- package/react/Viewer/Footer/ForwardButton.spec.jsx +0 -87
- package/react/Viewer/Footer/ForwardOrDownloadButton.jsx +0 -24
- package/react/Viewer/Footer/Sharing.jsx +0 -60
- package/react/Viewer/Footer/helpers.js +0 -107
- package/react/Viewer/Footer/helpers.spec.js +0 -77
- package/react/Viewer/NoViewer/DownloadButton.jsx +0 -28
- package/react/Viewer/NoViewer/FileIcon.jsx +0 -46
- package/react/Viewer/NoViewer/NoViewer.jsx +0 -29
- package/react/Viewer/NoViewer/NoViewer.spec.jsx +0 -44
- package/react/Viewer/NoViewer/__snapshots__/NoViewer.spec.jsx.snap +0 -82
- package/react/Viewer/NoViewer/index.jsx +0 -1
- package/react/Viewer/Panel/ActionMenuDesktop.jsx +0 -66
- package/react/Viewer/Panel/ActionMenuMobile.jsx +0 -74
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +0 -104
- package/react/Viewer/Panel/Certifications.jsx +0 -62
- package/react/Viewer/Panel/PanelContent.jsx +0 -49
- package/react/Viewer/Panel/Qualification.jsx +0 -114
- package/react/Viewer/Panel/QualificationListItemContact.jsx +0 -85
- package/react/Viewer/Panel/QualificationListItemDate.jsx +0 -77
- package/react/Viewer/Panel/QualificationListItemInformation.jsx +0 -68
- package/react/Viewer/Panel/QualificationListItemInformation.spec.jsx +0 -73
- package/react/Viewer/Panel/QualificationListItemOther.jsx +0 -61
- package/react/Viewer/Panel/QualificationListItemText.jsx +0 -30
- package/react/Viewer/Panel/getPanelBlocks.jsx +0 -56
- package/react/Viewer/Panel/getPanelBlocks.spec.jsx +0 -79
- package/react/Viewer/Panel/styles.styl +0 -13
- package/react/Viewer/Readme.md +0 -352
- package/react/Viewer/Viewer.jsx +0 -134
- package/react/Viewer/ViewerContainer.jsx +0 -169
- package/react/Viewer/ViewerExposer.js +0 -3
- package/react/Viewer/ViewerInformationsWrapper.jsx +0 -69
- package/react/Viewer/ViewerInformationsWrapper.spec.jsx +0 -63
- package/react/Viewer/ViewerWithCustomPanelAndFooter.jsx +0 -55
- package/react/Viewer/ViewersByFile/AudioViewer.jsx +0 -21
- package/react/Viewer/ViewersByFile/AudioViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/BlankPaperViewer.jsx +0 -46
- package/react/Viewer/ViewersByFile/ImageViewer.jsx +0 -330
- package/react/Viewer/ViewersByFile/ImageViewer.spec.jsx +0 -70
- package/react/Viewer/ViewersByFile/NoNetworkViewer.jsx +0 -17
- package/react/Viewer/ViewersByFile/OnlyOfficeViewer.jsx +0 -28
- package/react/Viewer/ViewersByFile/PdfJsViewer.jsx +0 -210
- package/react/Viewer/ViewersByFile/PdfJsViewer.spec.jsx +0 -160
- package/react/Viewer/ViewersByFile/PdfMobileViewer.jsx +0 -106
- package/react/Viewer/ViewersByFile/PdfMobileViewer.spec.jsx +0 -76
- package/react/Viewer/ViewersByFile/ShortcutViewer.jsx +0 -38
- package/react/Viewer/ViewersByFile/ShortcutViewer.spec.jsx +0 -32
- package/react/Viewer/ViewersByFile/TextViewer.jsx +0 -126
- package/react/Viewer/ViewersByFile/TextViewer.spec.jsx +0 -118
- package/react/Viewer/ViewersByFile/VideoViewer.jsx +0 -13
- package/react/Viewer/ViewersByFile/VideoViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/__snapshots__/AudioViewer.spec.jsx.snap +0 -43
- package/react/Viewer/ViewersByFile/__snapshots__/ShortcutViewer.spec.jsx.snap +0 -57
- package/react/Viewer/ViewersByFile/__snapshots__/TextViewer.spec.jsx.snap +0 -100
- package/react/Viewer/ViewersByFile/__snapshots__/VideoViewer.spec.jsx.snap +0 -19
- package/react/Viewer/ViewersByFile/styles.styl +0 -87
- package/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/react/Viewer/components/ExpirationAlert.jsx +0 -86
- package/react/Viewer/components/ExpirationAnnotation.jsx +0 -40
- package/react/Viewer/components/Footer.jsx +0 -13
- package/react/Viewer/components/InformationPanel.jsx +0 -26
- package/react/Viewer/components/Navigation.jsx +0 -39
- package/react/Viewer/components/PdfToolbarButton.jsx +0 -26
- package/react/Viewer/components/PrintButton.jsx +0 -90
- package/react/Viewer/components/Toolbar.jsx +0 -111
- package/react/Viewer/components/ToolbarButtons.jsx +0 -11
- package/react/Viewer/components/ToolbarFilePath.jsx +0 -61
- package/react/Viewer/components/ViewerByFile.jsx +0 -112
- package/react/Viewer/components/ViewerByFile.spec.jsx +0 -100
- package/react/Viewer/components/ViewerControls.jsx +0 -190
- package/react/Viewer/components/ViewerControls.spec.jsx +0 -54
- package/react/Viewer/components/ViewerSpinner.jsx +0 -17
- package/react/Viewer/components/styles.styl +0 -93
- package/react/Viewer/helpers.js +0 -131
- package/react/Viewer/helpers.spec.js +0 -136
- package/react/Viewer/hoc/withFileUrl.jsx +0 -93
- package/react/Viewer/hoc/withViewerLocales.jsx +0 -4
- package/react/Viewer/hooks/useReferencedContactName.jsx +0 -26
- package/react/Viewer/index.jsx +0 -12
- package/react/Viewer/locales/en.json +0 -66
- package/react/Viewer/locales/fr.json +0 -66
- package/react/Viewer/locales/index.js +0 -4
- package/react/Viewer/proptypes.js +0 -12
- package/react/Viewer/providers/ActionMenuProvider.jsx +0 -35
- package/react/Viewer/queries.js +0 -20
- package/react/Viewer/styles.styl +0 -22
- package/react/Viewer/vars.styl +0 -6
- package/transpiled/react/Viewer/Footer/BottomSheetContent.js +0 -28
- package/transpiled/react/Viewer/Footer/DownloadButton.js +0 -91
- package/transpiled/react/Viewer/Footer/FooterActionButtons.js +0 -21
- package/transpiled/react/Viewer/Footer/FooterContent.js +0 -98
- package/transpiled/react/Viewer/Footer/ForwardButton.js +0 -143
- package/transpiled/react/Viewer/Footer/ForwardOrDownloadButton.js +0 -25
- package/transpiled/react/Viewer/Footer/Sharing.js +0 -57
- package/transpiled/react/Viewer/Footer/helpers.js +0 -151
- package/transpiled/react/Viewer/NoViewer/DownloadButton.js +0 -34
- package/transpiled/react/Viewer/NoViewer/FileIcon.js +0 -57
- package/transpiled/react/Viewer/NoViewer/NoViewer.js +0 -49
- package/transpiled/react/Viewer/NoViewer/index.js +0 -1
- package/transpiled/react/Viewer/Panel/ActionMenuDesktop.js +0 -68
- package/transpiled/react/Viewer/Panel/ActionMenuMobile.js +0 -70
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +0 -129
- package/transpiled/react/Viewer/Panel/Certifications.js +0 -56
- package/transpiled/react/Viewer/Panel/PanelContent.js +0 -48
- package/transpiled/react/Viewer/Panel/Qualification.js +0 -119
- package/transpiled/react/Viewer/Panel/QualificationListItemContact.js +0 -96
- package/transpiled/react/Viewer/Panel/QualificationListItemDate.js +0 -64
- package/transpiled/react/Viewer/Panel/QualificationListItemInformation.js +0 -59
- package/transpiled/react/Viewer/Panel/QualificationListItemOther.js +0 -53
- package/transpiled/react/Viewer/Panel/QualificationListItemText.js +0 -29
- package/transpiled/react/Viewer/Panel/getPanelBlocks.js +0 -62
- package/transpiled/react/Viewer/Viewer.js +0 -172
- package/transpiled/react/Viewer/ViewerContainer.js +0 -189
- package/transpiled/react/Viewer/ViewerExposer.js +0 -2
- package/transpiled/react/Viewer/ViewerInformationsWrapper.js +0 -49
- package/transpiled/react/Viewer/ViewerWithCustomPanelAndFooter.js +0 -56
- package/transpiled/react/Viewer/ViewersByFile/AudioViewer.js +0 -41
- package/transpiled/react/Viewer/ViewersByFile/BlankPaperViewer.js +0 -74
- package/transpiled/react/Viewer/ViewersByFile/ImageViewer.js +0 -367
- package/transpiled/react/Viewer/ViewersByFile/NoNetworkViewer.js +0 -38
- package/transpiled/react/Viewer/ViewersByFile/OnlyOfficeViewer.js +0 -29
- package/transpiled/react/Viewer/ViewersByFile/PdfJsViewer.js +0 -254
- package/transpiled/react/Viewer/ViewersByFile/PdfMobileViewer.js +0 -153
- package/transpiled/react/Viewer/ViewersByFile/ShortcutViewer.js +0 -42
- package/transpiled/react/Viewer/ViewersByFile/TextViewer.js +0 -219
- package/transpiled/react/Viewer/ViewersByFile/VideoViewer.js +0 -33
- package/transpiled/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/transpiled/react/Viewer/components/ExpirationAlert.js +0 -100
- package/transpiled/react/Viewer/components/ExpirationAnnotation.js +0 -41
- package/transpiled/react/Viewer/components/Footer.js +0 -29
- package/transpiled/react/Viewer/components/InformationPanel.js +0 -23
- package/transpiled/react/Viewer/components/Navigation.js +0 -47
- package/transpiled/react/Viewer/components/PdfToolbarButton.js +0 -28
- package/transpiled/react/Viewer/components/PrintButton.js +0 -137
- package/transpiled/react/Viewer/components/Toolbar.js +0 -115
- package/transpiled/react/Viewer/components/ToolbarButtons.js +0 -9
- package/transpiled/react/Viewer/components/ToolbarFilePath.js +0 -71
- package/transpiled/react/Viewer/components/ViewerByFile.js +0 -105
- package/transpiled/react/Viewer/components/ViewerControls.js +0 -226
- package/transpiled/react/Viewer/components/ViewerSpinner.js +0 -17
- package/transpiled/react/Viewer/helpers.js +0 -147
- package/transpiled/react/Viewer/hoc/withFileUrl.js +0 -207
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +0 -3
- package/transpiled/react/Viewer/hooks/useReferencedContactName.js +0 -32
- package/transpiled/react/Viewer/index.js +0 -11
- package/transpiled/react/Viewer/locales/index.js +0 -136
- package/transpiled/react/Viewer/proptypes.js +0 -14
- package/transpiled/react/Viewer/providers/ActionMenuProvider.js +0 -34
- package/transpiled/react/Viewer/queries.js +0 -26
- /package/react/{Viewer/providers/EncryptedProvider.jsx → providers/Encrypted/index.jsx} +0 -0
- /package/transpiled/react/{Viewer/providers/EncryptedProvider.js → providers/Encrypted/index.js} +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
isExpired,
|
|
6
|
-
isExpiringSoon,
|
|
7
|
-
getTranslatedNameForDateMetadata,
|
|
8
|
-
formatDateMetadataValue
|
|
9
|
-
} from 'cozy-client/dist/models/paper'
|
|
10
|
-
|
|
11
|
-
import QualificationListItemText from './QualificationListItemText'
|
|
12
|
-
import Icon from '../../Icon'
|
|
13
|
-
import IconButton from '../../IconButton'
|
|
14
|
-
import Dots from '../../Icons/Dots'
|
|
15
|
-
import ListItem from '../../ListItem'
|
|
16
|
-
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
17
|
-
import Typography from '../../Typography'
|
|
18
|
-
import { useI18n } from '../../providers/I18n'
|
|
19
|
-
import ExpirationAnnotation from '../components/ExpirationAnnotation'
|
|
20
|
-
|
|
21
|
-
const QualificationListItemDate = forwardRef(
|
|
22
|
-
({ file, formattedMetadataQualification, toggleActionsMenu }, ref) => {
|
|
23
|
-
const { f, lang } = useI18n()
|
|
24
|
-
const { name, value } = formattedMetadataQualification
|
|
25
|
-
const formattedTitle = getTranslatedNameForDateMetadata(name, { lang })
|
|
26
|
-
const formattedDate = formatDateMetadataValue(value, {
|
|
27
|
-
f,
|
|
28
|
-
lang
|
|
29
|
-
})
|
|
30
|
-
const isExpirationDate = name === 'expirationDate'
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<ListItem className="u-pl-2 u-pr-3">
|
|
34
|
-
<QualificationListItemText
|
|
35
|
-
primary={formattedTitle}
|
|
36
|
-
secondary={
|
|
37
|
-
<>
|
|
38
|
-
<Typography component="span" variant="inherit">
|
|
39
|
-
{formattedDate}
|
|
40
|
-
</Typography>
|
|
41
|
-
{isExpirationDate && (isExpired(file) || isExpiringSoon(file)) && (
|
|
42
|
-
<>
|
|
43
|
-
<Typography component="span" variant="inherit">
|
|
44
|
-
{' · '}
|
|
45
|
-
</Typography>
|
|
46
|
-
<ExpirationAnnotation file={file} />
|
|
47
|
-
</>
|
|
48
|
-
)}
|
|
49
|
-
</>
|
|
50
|
-
}
|
|
51
|
-
disabled={!value}
|
|
52
|
-
/>
|
|
53
|
-
<ListItemSecondaryAction>
|
|
54
|
-
<IconButton
|
|
55
|
-
ref={ref}
|
|
56
|
-
onClick={() => toggleActionsMenu(formattedDate)}
|
|
57
|
-
>
|
|
58
|
-
<Icon icon={Dots} />
|
|
59
|
-
</IconButton>
|
|
60
|
-
</ListItemSecondaryAction>
|
|
61
|
-
</ListItem>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
QualificationListItemDate.displayName = 'QualificationListItemDate'
|
|
67
|
-
|
|
68
|
-
QualificationListItemDate.propTypes = {
|
|
69
|
-
file: PropTypes.object.isRequired,
|
|
70
|
-
formattedMetadataQualification: PropTypes.shape({
|
|
71
|
-
name: PropTypes.string,
|
|
72
|
-
value: PropTypes.string
|
|
73
|
-
}).isRequired,
|
|
74
|
-
toggleActionsMenu: PropTypes.func.isRequired
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default QualificationListItemDate
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getTranslatedNameForInformationMetadata,
|
|
6
|
-
formatInformationMetadataValue
|
|
7
|
-
} from 'cozy-client/dist/models/paper'
|
|
8
|
-
|
|
9
|
-
import QualificationListItemText from './QualificationListItemText'
|
|
10
|
-
import Icon from '../../Icon'
|
|
11
|
-
import IconButton from '../../IconButton'
|
|
12
|
-
import Dots from '../../Icons/Dots'
|
|
13
|
-
import ListItem from '../../ListItem'
|
|
14
|
-
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
15
|
-
import MidEllipsis from '../../MidEllipsis'
|
|
16
|
-
import { useI18n } from '../../providers/I18n'
|
|
17
|
-
|
|
18
|
-
const QualificationListItemInformation = forwardRef(
|
|
19
|
-
({ formattedMetadataQualification, file, toggleActionsMenu }, ref) => {
|
|
20
|
-
const { lang } = useI18n()
|
|
21
|
-
const { name, value } = formattedMetadataQualification
|
|
22
|
-
const qualificationLabel = file.metadata.qualification.label
|
|
23
|
-
|
|
24
|
-
const formattedTitle = getTranslatedNameForInformationMetadata(name, {
|
|
25
|
-
lang,
|
|
26
|
-
qualificationLabel
|
|
27
|
-
})
|
|
28
|
-
const formattedValue = formatInformationMetadataValue(value, {
|
|
29
|
-
lang,
|
|
30
|
-
name,
|
|
31
|
-
qualificationLabel
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const titleComponent =
|
|
35
|
-
formattedTitle === name ? <MidEllipsis text={name} /> : formattedTitle
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<ListItem className="u-pl-2 u-pr-3">
|
|
39
|
-
<QualificationListItemText
|
|
40
|
-
primary={titleComponent}
|
|
41
|
-
secondary={formattedValue}
|
|
42
|
-
disabled={!value}
|
|
43
|
-
/>
|
|
44
|
-
<ListItemSecondaryAction>
|
|
45
|
-
<IconButton
|
|
46
|
-
ref={ref}
|
|
47
|
-
onClick={() => toggleActionsMenu(value)}
|
|
48
|
-
data-testid="toggleActionsMenuBtn"
|
|
49
|
-
>
|
|
50
|
-
<Icon icon={Dots} />
|
|
51
|
-
</IconButton>
|
|
52
|
-
</ListItemSecondaryAction>
|
|
53
|
-
</ListItem>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
QualificationListItemInformation.displayName = 'QualificationListItemNumber'
|
|
59
|
-
|
|
60
|
-
QualificationListItemInformation.propTypes = {
|
|
61
|
-
formattedMetadataQualification: PropTypes.shape({
|
|
62
|
-
name: PropTypes.string,
|
|
63
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
64
|
-
}).isRequired,
|
|
65
|
-
toggleActionsMenu: PropTypes.func.isRequired
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default QualificationListItemInformation
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from '@testing-library/react'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import QualificationListItemInformation from './QualificationListItemInformation'
|
|
5
|
-
|
|
6
|
-
jest.mock('../../providers/I18n', () => ({
|
|
7
|
-
useI18n: jest.fn(() => ({ t: x => x }))
|
|
8
|
-
}))
|
|
9
|
-
|
|
10
|
-
const setup = ({
|
|
11
|
-
formattedMetadataQualification = {},
|
|
12
|
-
toggleActionsMenu = jest.fn()
|
|
13
|
-
} = {}) => {
|
|
14
|
-
return render(
|
|
15
|
-
<QualificationListItemInformation
|
|
16
|
-
formattedMetadataQualification={formattedMetadataQualification}
|
|
17
|
-
toggleActionsMenu={toggleActionsMenu}
|
|
18
|
-
file={{
|
|
19
|
-
metadata: { qualification: { label: 'label_of_qualification' } }
|
|
20
|
-
}}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('QualificationListItemInformation', () => {
|
|
26
|
-
describe('formattedMetadataQualification', () => {
|
|
27
|
-
it('should display default text if value is falsy', () => {
|
|
28
|
-
const formattedMetadataQualification = { name: 'country', value: '' }
|
|
29
|
-
const { getByText } = setup({ formattedMetadataQualification })
|
|
30
|
-
|
|
31
|
-
expect(getByText('No information'))
|
|
32
|
-
})
|
|
33
|
-
// eslint-disable-next-line jest/no-focused-tests
|
|
34
|
-
it.only('should display current value if it is truthy', () => {
|
|
35
|
-
const formattedMetadataQualification = {
|
|
36
|
-
name: 'country',
|
|
37
|
-
value: 'Italie'
|
|
38
|
-
}
|
|
39
|
-
const { queryByText } = setup({
|
|
40
|
-
formattedMetadataQualification
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
expect(queryByText('No information')).toBeNull()
|
|
44
|
-
expect(queryByText('Italie')).toBeInTheDocument()
|
|
45
|
-
})
|
|
46
|
-
it('should display current value if it number type', () => {
|
|
47
|
-
const formattedMetadataQualification = { name: 'country', value: 0 }
|
|
48
|
-
const { queryByText } = setup({
|
|
49
|
-
formattedMetadataQualification
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
expect(queryByText('No information')).toBeNull()
|
|
53
|
-
expect(queryByText('0')).toBeInTheDocument()
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
describe('toggleActionsMenu', () => {
|
|
57
|
-
it('should call toggleActionsMenu with current value on click it', () => {
|
|
58
|
-
const formattedMetadataQualification = {
|
|
59
|
-
name: 'country',
|
|
60
|
-
value: 'Italie'
|
|
61
|
-
}
|
|
62
|
-
const toggleActionsMenu = jest.fn()
|
|
63
|
-
const { getByTestId } = setup({
|
|
64
|
-
toggleActionsMenu,
|
|
65
|
-
formattedMetadataQualification
|
|
66
|
-
})
|
|
67
|
-
const toggleActionsMenuBtn = getByTestId('toggleActionsMenuBtn')
|
|
68
|
-
fireEvent.click(toggleActionsMenuBtn)
|
|
69
|
-
|
|
70
|
-
expect(toggleActionsMenu).toBeCalledWith('Italie')
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getTranslatedNameForOtherMetadata,
|
|
6
|
-
formatOtherMetadataValue
|
|
7
|
-
} from 'cozy-client/dist/models/paper'
|
|
8
|
-
|
|
9
|
-
import QualificationListItemText from './QualificationListItemText'
|
|
10
|
-
import Icon from '../../Icon'
|
|
11
|
-
import IconButton from '../../IconButton'
|
|
12
|
-
import Dots from '../../Icons/Dots'
|
|
13
|
-
import ListItem from '../../ListItem'
|
|
14
|
-
import ListItemSecondaryAction from '../../ListItemSecondaryAction'
|
|
15
|
-
import MidEllipsis from '../../MidEllipsis'
|
|
16
|
-
import { useI18n } from '../../providers/I18n'
|
|
17
|
-
|
|
18
|
-
const QualificationListItemOther = forwardRef(
|
|
19
|
-
({ formattedMetadataQualification, toggleActionsMenu }, ref) => {
|
|
20
|
-
const { lang } = useI18n()
|
|
21
|
-
const { name, value } = formattedMetadataQualification
|
|
22
|
-
|
|
23
|
-
if (!value) return null
|
|
24
|
-
|
|
25
|
-
const formattedTitle = getTranslatedNameForOtherMetadata(name, {
|
|
26
|
-
lang
|
|
27
|
-
})
|
|
28
|
-
const formattedValue = formatOtherMetadataValue(value, {
|
|
29
|
-
lang,
|
|
30
|
-
name
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<ListItem className="u-pl-2 u-pr-3">
|
|
35
|
-
<QualificationListItemText
|
|
36
|
-
primary={formattedTitle}
|
|
37
|
-
secondary={<MidEllipsis text={formattedValue} />}
|
|
38
|
-
/>
|
|
39
|
-
<ListItemSecondaryAction>
|
|
40
|
-
<IconButton
|
|
41
|
-
ref={ref}
|
|
42
|
-
onClick={() => toggleActionsMenu(formattedValue)}
|
|
43
|
-
>
|
|
44
|
-
<Icon icon={Dots} />
|
|
45
|
-
</IconButton>
|
|
46
|
-
</ListItemSecondaryAction>
|
|
47
|
-
</ListItem>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
QualificationListItemOther.displayName = 'QualificationListItemOther'
|
|
52
|
-
|
|
53
|
-
QualificationListItemOther.propTypes = {
|
|
54
|
-
formattedMetadataQualification: PropTypes.shape({
|
|
55
|
-
name: PropTypes.string,
|
|
56
|
-
value: PropTypes.string
|
|
57
|
-
}).isRequired,
|
|
58
|
-
toggleActionsMenu: PropTypes.func.isRequired
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default QualificationListItemOther
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import ListItemText from '../../ListItemText'
|
|
5
|
-
import Typography from '../../Typography'
|
|
6
|
-
|
|
7
|
-
const QualificationListItemText = ({ primary, secondary, disabled }) => {
|
|
8
|
-
return (
|
|
9
|
-
<ListItemText
|
|
10
|
-
disableTypography
|
|
11
|
-
primary={<Typography variant="caption">{primary}</Typography>}
|
|
12
|
-
secondary={
|
|
13
|
-
<Typography
|
|
14
|
-
component="div"
|
|
15
|
-
variant="body1"
|
|
16
|
-
style={disabled ? { color: 'var(--disabledTextColor)' } : undefined}
|
|
17
|
-
>
|
|
18
|
-
{secondary}
|
|
19
|
-
</Typography>
|
|
20
|
-
}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
QualificationListItemText.propTypes = {
|
|
26
|
-
primary: PropTypes.string.isRequired,
|
|
27
|
-
secondary: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default QualificationListItemText
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { models } from 'cozy-client'
|
|
2
|
-
import KonnectorBlock from 'cozy-harvest-lib/dist/components/KonnectorBlock'
|
|
3
|
-
|
|
4
|
-
import Certifications from './Certifications'
|
|
5
|
-
import Qualification from './Qualification'
|
|
6
|
-
|
|
7
|
-
const { isFromKonnector, hasQualifications, hasCertifications } = models.file
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} PanelBlockSpec
|
|
11
|
-
* @property {Function} condition - Function that returns true if the block should be displayed
|
|
12
|
-
* @property {React.Component} component - Component to display
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object.<string, PanelBlockSpec>} PanelBlocksSpecs
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Returns the specs of the blocks to display in the panel
|
|
21
|
-
* @param {boolean} isPublic - Whether the panel is displayed in public view
|
|
22
|
-
* @returns {PanelBlocksSpecs}
|
|
23
|
-
*/
|
|
24
|
-
export const getPanelBlocksSpecs = (isPublic = false) => ({
|
|
25
|
-
qualifications: {
|
|
26
|
-
condition: hasQualifications,
|
|
27
|
-
component: Qualification
|
|
28
|
-
},
|
|
29
|
-
konnector: {
|
|
30
|
-
condition: file => isFromKonnector(file) && !isPublic,
|
|
31
|
-
component: KonnectorBlock
|
|
32
|
-
},
|
|
33
|
-
certifications: {
|
|
34
|
-
condition: hasCertifications,
|
|
35
|
-
component: Certifications
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns the blocks to display in the panel
|
|
41
|
-
* @param {Object} options
|
|
42
|
-
* @param {PanelBlocksSpecs} options.panelBlocksSpecs - Specs of the blocks to display in the panel
|
|
43
|
-
* @param {import('cozy-client/types/types').FileDocument} options.file - File object
|
|
44
|
-
* @returns {Array.<React.Component>}
|
|
45
|
-
*/
|
|
46
|
-
const getPanelBlocks = ({ panelBlocksSpecs, file }) => {
|
|
47
|
-
const panelBlocks = []
|
|
48
|
-
|
|
49
|
-
Object.values(panelBlocksSpecs).forEach(panelBlock => {
|
|
50
|
-
panelBlock.condition(file) && panelBlocks.push(panelBlock.component)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
return panelBlocks
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default getPanelBlocks
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import getPanelBlocks, { getPanelBlocksSpecs } from './getPanelBlocks'
|
|
2
|
-
|
|
3
|
-
jest.mock('cozy-harvest-lib/dist/components/KonnectorBlock', () => jest.fn())
|
|
4
|
-
const block1Component = jest.fn()
|
|
5
|
-
const block2Component = jest.fn()
|
|
6
|
-
|
|
7
|
-
describe('getPanelBlocks', () => {
|
|
8
|
-
it('should return only blocks with truthy condition', () => {
|
|
9
|
-
// with two truthy component
|
|
10
|
-
expect(
|
|
11
|
-
getPanelBlocks({
|
|
12
|
-
panelBlocksSpecs: {
|
|
13
|
-
block1: {
|
|
14
|
-
condition: () => true,
|
|
15
|
-
component: block1Component
|
|
16
|
-
},
|
|
17
|
-
block2: {
|
|
18
|
-
condition: () => true,
|
|
19
|
-
component: block2Component
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
).toMatchObject([block1Component, block2Component])
|
|
24
|
-
|
|
25
|
-
// with one truthy component
|
|
26
|
-
expect(
|
|
27
|
-
getPanelBlocks({
|
|
28
|
-
panelBlocksSpecs: {
|
|
29
|
-
block1: {
|
|
30
|
-
condition: () => false,
|
|
31
|
-
component: block1Component
|
|
32
|
-
},
|
|
33
|
-
block2: {
|
|
34
|
-
condition: () => true,
|
|
35
|
-
component: block2Component
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
).toMatchObject([block2Component])
|
|
40
|
-
|
|
41
|
-
// with no truthy component
|
|
42
|
-
expect(
|
|
43
|
-
getPanelBlocks({
|
|
44
|
-
panelBlocksSpecs: {
|
|
45
|
-
block1: {
|
|
46
|
-
condition: () => false,
|
|
47
|
-
component: block1Component
|
|
48
|
-
},
|
|
49
|
-
block2: {
|
|
50
|
-
condition: () => false,
|
|
51
|
-
component: block2Component
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
).toMatchObject([])
|
|
56
|
-
|
|
57
|
-
// with no specs
|
|
58
|
-
expect(getPanelBlocks({ panelBlocksSpecs: {} })).toMatchObject([])
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('getPanelBlocksSpecs', () => {
|
|
63
|
-
it('should return the specs of the blocks to display in the panel', () => {
|
|
64
|
-
expect(getPanelBlocksSpecs()).toEqual({
|
|
65
|
-
qualifications: {
|
|
66
|
-
condition: expect.any(Function),
|
|
67
|
-
component: expect.anything()
|
|
68
|
-
},
|
|
69
|
-
konnector: {
|
|
70
|
-
condition: expect.any(Function),
|
|
71
|
-
component: expect.anything()
|
|
72
|
-
},
|
|
73
|
-
certifications: {
|
|
74
|
-
condition: expect.any(Function),
|
|
75
|
-
component: expect.anything()
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
.ActionMenuDesktop-ActionMenu
|
|
2
|
-
a
|
|
3
|
-
padding 0 !important // Waiting for the migration of the ActionMenu on the Viewer
|
|
4
|
-
.ActionMenuDesktop-ActionMenu-link-disabled
|
|
5
|
-
> div
|
|
6
|
-
cursor default
|
|
7
|
-
&:hover
|
|
8
|
-
background-color initial
|
|
9
|
-
> div
|
|
10
|
-
svg
|
|
11
|
-
fill var(--disabledTextColor)
|
|
12
|
-
p
|
|
13
|
-
color var(--disabledTextColor)
|