cozy-ui 74.6.1 → 74.7.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 CHANGED
@@ -1,3 +1,19 @@
1
+ # [74.7.0](https://github.com/cozy/cozy-ui/compare/v74.6.1...v74.7.0) (2022-09-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Viewer:** Add "edit" option ([f40c926](https://github.com/cozy/cozy-ui/commit/f40c926))
7
+ * **Viewer:** Add ActionMenuDesktop component ([e5db778](https://github.com/cozy/cozy-ui/commit/e5db778))
8
+ * **Viewer:** Add ActionMenuMobile component ([87dac4d](https://github.com/cozy/cozy-ui/commit/87dac4d))
9
+ * **Viewer:** Add ActionMenuProvider component ([7938117](https://github.com/cozy/cozy-ui/commit/7938117))
10
+ * **Viewer:** Add buildEditAttributePath helper ([677bff7](https://github.com/cozy/cozy-ui/commit/677bff7))
11
+ * **Viewer:** Add editPathByModelProps prop to ViewerContainer ([c615600](https://github.com/cozy/cozy-ui/commit/c615600))
12
+ * **Viewer:** Add name & fileId props to ActionMenuWrapper ([fbcf1bc](https://github.com/cozy/cozy-ui/commit/fbcf1bc))
13
+ * **Viewer:** Add optionFile & file props to ActionMenuWrapper ([a5f0b2d](https://github.com/cozy/cozy-ui/commit/a5f0b2d))
14
+ * **Viewer:** Remove filename attribute in Viewer information ([8f76f46](https://github.com/cozy/cozy-ui/commit/8f76f46))
15
+ * **Viewer:** Use actionMenuContext in ActionMenuWrapper ([89518aa](https://github.com/cozy/cozy-ui/commit/89518aa))
16
+
1
17
  ## [74.6.1](https://github.com/cozy/cozy-ui/compare/v74.6.0...v74.6.1) (2022-09-15)
2
18
 
3
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "74.6.1",
3
+ "version": "74.7.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -0,0 +1,68 @@
1
+ import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import styles from './styles.styl'
4
+
5
+ import Icon from '../../Icon'
6
+ import Copy from '../../Icons/Copy'
7
+ import Edit from '../../Icons/Rename'
8
+ import ActionMenu, { ActionMenuItem } from '../../ActionMenu'
9
+ import Typography from '../../Typography'
10
+ import { useI18n } from '../../I18n'
11
+ import AppLinker from '../../AppLinker'
12
+
13
+ const ActionMenuDesktop = forwardRef(
14
+ ({ onClose, isEditable, actions, appLink, appSlug }, ref) => {
15
+ const { handleCopy, handleEdit } = actions
16
+ const { t } = useI18n()
17
+
18
+ return (
19
+ <ActionMenu
20
+ className={styles['ActionMenuDesktop-ActionMenu']}
21
+ onClose={onClose}
22
+ anchorElRef={ref}
23
+ >
24
+ {isEditable && (
25
+ <AppLinker app={{ slug: appSlug }} href={appLink}>
26
+ {({ onClick, href }) => {
27
+ return (
28
+ <a
29
+ href={href}
30
+ className={
31
+ !appLink &&
32
+ styles['ActionMenuDesktop-ActionMenu-link-disabled']
33
+ }
34
+ onClick={() => handleEdit(onClick)}
35
+ >
36
+ <ActionMenuItem left={<Icon icon={Edit} />}>
37
+ <Typography>
38
+ {t(`Viewer.panel.qualification.actions.edit`)}
39
+ </Typography>
40
+ </ActionMenuItem>
41
+ </a>
42
+ )
43
+ }}
44
+ </AppLinker>
45
+ )}
46
+ <ActionMenuItem onClick={handleCopy} left={<Icon icon={Copy} />}>
47
+ <Typography>
48
+ {t(`Viewer.panel.qualification.actions.copy`)}
49
+ </Typography>
50
+ </ActionMenuItem>
51
+ </ActionMenu>
52
+ )
53
+ }
54
+ )
55
+ ActionMenuDesktop.displayName = 'ActionMenuDesktop'
56
+
57
+ ActionMenuDesktop.propTypes = {
58
+ onClose: PropTypes.func,
59
+ isEditable: PropTypes.bool,
60
+ actions: PropTypes.shape({
61
+ handleCopy: PropTypes.func,
62
+ handleEdit: PropTypes.func
63
+ }),
64
+ appLink: PropTypes.string,
65
+ appSlug: PropTypes.string
66
+ }
67
+
68
+ export default ActionMenuDesktop
@@ -0,0 +1,75 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import List from '../../MuiCozyTheme/List'
5
+ import ListItem from '../../MuiCozyTheme/ListItem'
6
+ import ListItemIcon from '../../MuiCozyTheme/ListItemIcon'
7
+ import ListItemText from '../../ListItemText'
8
+ import Icon from '../../Icon'
9
+ import Copy from '../../Icons/Copy'
10
+ import Edit from '../../Icons/Rename'
11
+ import BottomSheet, { BottomSheetItem } from '../../BottomSheet'
12
+ import { useI18n } from '../../I18n'
13
+ import AppLinker from '../../AppLinker'
14
+
15
+ const ActionMenuMobile = ({
16
+ onClose,
17
+ isEditable,
18
+ actions,
19
+ appLink,
20
+ appSlug
21
+ }) => {
22
+ const { t } = useI18n()
23
+ const { handleCopy, handleEdit } = actions
24
+
25
+ return (
26
+ <BottomSheet backdrop onClose={onClose}>
27
+ <BottomSheetItem disableGutters>
28
+ <List>
29
+ {isEditable && (
30
+ <AppLinker app={{ slug: appSlug }} href={appLink}>
31
+ {({ onClick, href }) => {
32
+ return (
33
+ <ListItem
34
+ button
35
+ component="a"
36
+ href={href}
37
+ onClick={() => handleEdit(onClick)}
38
+ disabled={!appLink}
39
+ >
40
+ <ListItemIcon>
41
+ <Icon icon={Edit} />
42
+ </ListItemIcon>
43
+ <ListItemText
44
+ primary={t(`Viewer.panel.qualification.actions.edit`)}
45
+ />
46
+ </ListItem>
47
+ )
48
+ }}
49
+ </AppLinker>
50
+ )}
51
+ <ListItem button onClick={handleCopy}>
52
+ <ListItemIcon>
53
+ <Icon icon={Copy} />
54
+ </ListItemIcon>
55
+ <ListItemText
56
+ primary={t(`Viewer.panel.qualification.actions.copyClipboard`)}
57
+ />
58
+ </ListItem>
59
+ </List>
60
+ </BottomSheetItem>
61
+ </BottomSheet>
62
+ )
63
+ }
64
+
65
+ ActionMenuMobile.propTypes = {
66
+ onClose: PropTypes.func,
67
+ isEditable: PropTypes.bool,
68
+ actions: PropTypes.shape({
69
+ handleCopy: PropTypes.func,
70
+ handleEdit: PropTypes.func
71
+ }),
72
+ appLink: PropTypes.string
73
+ }
74
+
75
+ export default ActionMenuMobile
@@ -0,0 +1,35 @@
1
+ import React, { createContext, useContext } from 'react'
2
+
3
+ /**
4
+ * @typedef {object} useActionMenuContextReturn
5
+ * @property {string} information
6
+ * @property {string} page
7
+ */
8
+
9
+ const ActionMenuContext = createContext()
10
+
11
+ const ActionMenuProvider = ({ children, editPathByModelProps = {} }) => {
12
+ return (
13
+ <ActionMenuContext.Provider value={editPathByModelProps}>
14
+ {children}
15
+ </ActionMenuContext.Provider>
16
+ )
17
+ }
18
+
19
+ /**
20
+ * @returns {useActionMenuContextReturn}
21
+ */
22
+ const useActionMenuContext = () => {
23
+ const actionMenuContext = useContext(ActionMenuContext)
24
+ if (!actionMenuContext) {
25
+ throw new Error(
26
+ 'ActionMenuContext must be used within a ActionMenuProvider'
27
+ )
28
+ }
29
+
30
+ return actionMenuContext
31
+ }
32
+
33
+ export default useActionMenuContext
34
+
35
+ export { ActionMenuProvider }
@@ -1,23 +1,45 @@
1
1
  import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import List from '../../MuiCozyTheme/List'
5
- import ListItem from '../../MuiCozyTheme/ListItem'
6
- import ListItemIcon from '../../MuiCozyTheme/ListItemIcon'
7
- import ListItemText from '../../ListItemText'
8
- import Icon from '../../Icon'
9
- import Copy from '../../Icons/Copy'
10
- import BottomSheet, { BottomSheetItem } from '../../BottomSheet'
11
- import ActionMenu, { ActionMenuItem } from '../../ActionMenu'
12
- import Typography from '../../Typography'
4
+ import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
5
+
13
6
  import useBreakpoints from '../../hooks/useBreakpoints'
14
7
  import { useI18n } from '../../I18n'
15
8
  import useViewerSnackbar from '../snackbar/ViewerSnackbarProvider'
9
+ import { buildEditAttributePath, getCurrentModel } from '../helpers'
10
+ import useActionMenuContext from './ActionMenuProvider'
11
+ import ActionMenuMobile from './ActionMenuMobile'
12
+ import ActionMenuDesktop from './ActionMenuDesktop'
13
+
14
+ const mespapiersAppSlug = 'mespapiers'
15
+
16
+ const checkEditableAttribute = name => {
17
+ const isNotEditableAttributes = ['datetime', 'qualification', 'contact']
18
+ return !isNotEditableAttributes.includes(name)
19
+ }
16
20
 
17
- const ActionMenuWrapper = forwardRef(({ onClose, value }, ref) => {
21
+ const ActionMenuWrapper = forwardRef(({ onClose, optionFile }, ref) => {
22
+ const { name, value } = optionFile
23
+ const editPathByModelProps = useActionMenuContext()
18
24
  const { isMobile } = useBreakpoints()
19
25
  const { t } = useI18n()
20
26
  const { showViewerSnackbar } = useViewerSnackbar()
27
+ const client = useClient()
28
+
29
+ const isEditableAttribute = checkEditableAttribute(name)
30
+ const currentModel = getCurrentModel(name)
31
+ const editPath = buildEditAttributePath(
32
+ editPathByModelProps,
33
+ currentModel,
34
+ optionFile.name
35
+ )
36
+
37
+ const { fetchStatus, url } = useAppLinkWithStoreFallback(
38
+ mespapiersAppSlug,
39
+ client,
40
+ editPath
41
+ )
42
+ const isAppLinkLoaded = fetchStatus === 'loaded'
21
43
 
22
44
  const handleCopy = () => {
23
45
  if (navigator?.clipboard) {
@@ -32,38 +54,44 @@ const ActionMenuWrapper = forwardRef(({ onClose, value }, ref) => {
32
54
  onClose()
33
55
  }
34
56
 
57
+ const handleEdit = cb => {
58
+ if (isAppLinkLoaded) {
59
+ onClose()
60
+ cb && cb()
61
+ }
62
+ }
63
+
35
64
  if (isMobile) {
36
65
  return (
37
- <BottomSheet backdrop onClose={onClose}>
38
- <BottomSheetItem disableGutters>
39
- <List>
40
- <ListItem button onClick={handleCopy}>
41
- <ListItemIcon>
42
- <Icon icon={Copy} />
43
- </ListItemIcon>
44
- <ListItemText
45
- primary={t(`Viewer.panel.qualification.actions.copyClipboard`)}
46
- />
47
- </ListItem>
48
- </List>
49
- </BottomSheetItem>
50
- </BottomSheet>
66
+ <ActionMenuMobile
67
+ onClose={onClose}
68
+ isEditable={editPath && isEditableAttribute}
69
+ actions={{ handleCopy, handleEdit }}
70
+ appLink={url}
71
+ appSlug={mespapiersAppSlug}
72
+ />
51
73
  )
52
74
  }
53
75
 
54
76
  return (
55
- <ActionMenu onClose={onClose} anchorElRef={ref}>
56
- <ActionMenuItem onClick={handleCopy} left={<Icon icon={Copy} />}>
57
- <Typography>{t(`Viewer.panel.qualification.actions.copy`)}</Typography>
58
- </ActionMenuItem>
59
- </ActionMenu>
77
+ <ActionMenuDesktop
78
+ ref={ref}
79
+ onClose={onClose}
80
+ isEditable={editPath && isEditableAttribute}
81
+ actions={{ handleCopy, handleEdit }}
82
+ appLink={url}
83
+ appSlug={mespapiersAppSlug}
84
+ />
60
85
  )
61
86
  })
62
87
  ActionMenuWrapper.displayName = 'ActionMenuWrapper'
63
88
 
64
89
  ActionMenuWrapper.propTypes = {
65
90
  onClose: PropTypes.func,
66
- value: PropTypes.string
91
+ optionFile: PropTypes.shape({
92
+ name: PropTypes.string,
93
+ value: PropTypes.string
94
+ })
67
95
  }
68
96
 
69
97
  export default ActionMenuWrapper
@@ -19,19 +19,19 @@ const Qualification = ({ file = {} }) => {
19
19
  const { metadata = {} } = file
20
20
  const actionBtnRef = useRef([])
21
21
  const [optionFile, setOptionFile] = useState({
22
- isOpen: false,
23
22
  id: '',
23
+ name: '',
24
24
  value: ''
25
25
  })
26
26
 
27
27
  const hideActionsMenu = () => {
28
- setOptionFile({ isOpen: false, id: '', value: '' })
28
+ setOptionFile({ id: '', name: '', value: '' })
29
29
  }
30
30
 
31
- const toggleActionsMenu = (id, value) => {
31
+ const toggleActionsMenu = (id, name, value) => {
32
32
  setOptionFile(prev => {
33
- if (prev.isOpen) return { isOpen: false, id: '', value: '' }
34
- return { isOpen: true, id, value }
33
+ if (prev.value) return { id: '', name: '', value: '' }
34
+ return { id, name, value }
35
35
  })
36
36
  }
37
37
 
@@ -56,7 +56,7 @@ const Qualification = ({ file = {} }) => {
56
56
  key={idx}
57
57
  ref={actionBtnRef.current[idx]}
58
58
  metadataComputed={meta}
59
- toggleActionsMenu={val => toggleActionsMenu(idx, val)}
59
+ toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
60
60
  />
61
61
  )
62
62
  }
@@ -67,13 +67,13 @@ const Qualification = ({ file = {} }) => {
67
67
  key={idx}
68
68
  ref={actionBtnRef.current[idx]}
69
69
  metadataComputed={meta}
70
- toggleActionsMenu={val => toggleActionsMenu(idx, val)}
70
+ toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
71
71
  />
72
72
  )
73
73
  }
74
74
 
75
75
  if (knowOtherMetadataNames.includes(name)) {
76
- if (name === 'owner') {
76
+ if (name === 'contact') {
77
77
  return <QualificationListItemContact key={idx} file={file} />
78
78
  }
79
79
 
@@ -81,18 +81,18 @@ const Qualification = ({ file = {} }) => {
81
81
  <QualificationListItemOther
82
82
  key={idx}
83
83
  ref={actionBtnRef.current[idx]}
84
- filename={file.name}
85
84
  metadataComputed={meta}
86
- toggleActionsMenu={val => toggleActionsMenu(idx, val)}
85
+ toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
87
86
  />
88
87
  )
89
88
  }
90
89
  })}
91
90
 
92
- {optionFile.isOpen && (
91
+ {optionFile.value && (
93
92
  <ActionMenuWrapper
94
93
  onClose={hideActionsMenu}
95
- value={optionFile.value}
94
+ file={file}
95
+ optionFile={optionFile}
96
96
  ref={actionBtnRef.current[optionFile.id]}
97
97
  />
98
98
  )}
@@ -16,15 +16,15 @@ const QualificationListItemContact = ({ file }) => {
16
16
  const { t } = useI18n()
17
17
  const actionBtnRef = useRef()
18
18
  const [optionFile, setOptionFile] = useState({
19
- isOpen: false,
19
+ name: '',
20
20
  value: ''
21
21
  })
22
22
 
23
- const hideActionsMenu = () => setOptionFile({ isOpen: false, value: '' })
24
- const toggleActionsMenu = value =>
23
+ const hideActionsMenu = () => setOptionFile({ name: '', value: '' })
24
+ const toggleActionsMenu = (name, value) =>
25
25
  setOptionFile(prev => {
26
- if (prev.isOpen) return { isOpen: false, value: '' }
27
- return { isOpen: true, value }
26
+ if (prev.value) return { name: '', value: '' }
27
+ return { name, value }
28
28
  })
29
29
 
30
30
  const { contactName, isLoadingContacts } = useReferencedContactName(file)
@@ -45,23 +45,24 @@ const QualificationListItemContact = ({ file }) => {
45
45
  <>
46
46
  <ListItem className={'u-ph-2'}>
47
47
  <QualificationListItemText
48
- primary={t('Viewer.panel.qualification.owner')}
48
+ primary={t('Viewer.panel.qualification.contact')}
49
49
  secondary={contactName}
50
50
  />
51
51
  <ListItemSecondaryAction>
52
52
  <IconButton
53
53
  ref={actionBtnRef}
54
- onClick={() => toggleActionsMenu(contactName)}
54
+ onClick={() => toggleActionsMenu('contact', contactName)}
55
55
  >
56
56
  <Icon icon={Dots} />
57
57
  </IconButton>
58
58
  </ListItemSecondaryAction>
59
59
  </ListItem>
60
60
 
61
- {optionFile.isOpen && (
61
+ {optionFile.value && (
62
62
  <ActionMenuWrapper
63
63
  onClose={hideActionsMenu}
64
- value={optionFile.value}
64
+ file={file}
65
+ optionFile={optionFile}
65
66
  ref={actionBtnRef}
66
67
  />
67
68
  )}
@@ -19,35 +19,33 @@ const {
19
19
  } = models
20
20
 
21
21
  const QualificationListItemOther = forwardRef(
22
- ({ metadataComputed, toggleActionsMenu, filename }, ref) => {
22
+ ({ metadataComputed, toggleActionsMenu }, ref) => {
23
23
  const { t, lang } = useI18n()
24
24
  const scannerT = getBoundT(lang)
25
25
  const { name, value } = metadataComputed
26
26
 
27
+ if (!value) return null
28
+
27
29
  const currentValueTranslated =
28
30
  name === 'qualification'
29
31
  ? scannerT(`Scan.items.${value}`)
30
- : value
31
- ? t(`Viewer.panel.qualification.${value}`)
32
- : filename
32
+ : t(`Viewer.panel.qualification.${value}`)
33
33
 
34
34
  return (
35
- currentValueTranslated && (
36
- <ListItem className={'u-pl-2 u-pr-3'}>
37
- <QualificationListItemText
38
- primary={t(`Viewer.panel.qualification.${name}`)}
39
- secondary={<MidEllipsis text={currentValueTranslated} />}
40
- />
41
- <ListItemSecondaryAction>
42
- <IconButton
43
- ref={ref}
44
- onClick={() => toggleActionsMenu(currentValueTranslated)}
45
- >
46
- <Icon icon={Dots} />
47
- </IconButton>
48
- </ListItemSecondaryAction>
49
- </ListItem>
50
- )
35
+ <ListItem className={'u-pl-2 u-pr-3'}>
36
+ <QualificationListItemText
37
+ primary={t(`Viewer.panel.qualification.${name}`)}
38
+ secondary={<MidEllipsis text={currentValueTranslated} />}
39
+ />
40
+ <ListItemSecondaryAction>
41
+ <IconButton
42
+ ref={ref}
43
+ onClick={() => toggleActionsMenu(currentValueTranslated)}
44
+ >
45
+ <Icon icon={Dots} />
46
+ </IconButton>
47
+ </ListItemSecondaryAction>
48
+ </ListItem>
51
49
  )
52
50
  }
53
51
  )
@@ -0,0 +1,13 @@
1
+ .ActionMenuDesktop-ActionMenu
2
+ a
3
+ padding 0
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)
@@ -58,14 +58,14 @@ const files = [
58
58
  mime: 'application/pdf',
59
59
  metadata: {
60
60
  carbonCopy: true,
61
- datetime: "2022-02-09T09:05:38.000Z",
62
- datetimeLabel: "datetime",
61
+ BObtentionDate: "2022-02-09T09:05:38.000Z",
62
+ datetimeLabel: "BObtentionDate",
63
63
  qualification: {
64
- label: "vehicle_registration",
64
+ label: "driver_license",
65
65
  purpose: "attestation",
66
66
  sourceCategory: "gov",
67
67
  sourceSubCategory: "transport",
68
- subjects: ["vehicule", "indentity", "right"]
68
+ subjects: ["permit", "driving"]
69
69
  }
70
70
  }
71
71
  },
@@ -143,6 +143,10 @@ const getURL = (file) => {
143
143
  const toggleViewer = () => setState({ viewerOpened: !state.viewerOpened });
144
144
  const handleToggleToolbarClose = () => setState({ showToolbarCloseButton: !state.showToolbarCloseButton });
145
145
  const onFileChange = (file, nextIndex) => setState({ currentIndex: nextIndex, currentURL: getURL(file) });
146
+ const editPathByModelProps = {
147
+ information: `#!/Viewer?metadata=__NAME__`,
148
+ page: `#!/Viewer`
149
+ };
146
150
 
147
151
  <DemoProvider>
148
152
  <Variants initialVariants={initialVariants}>{
@@ -169,6 +173,7 @@ const onFileChange = (file, nextIndex) => setState({ currentIndex: nextIndex, cu
169
173
  onCloseRequest={toggleViewer}
170
174
  onChangeRequest={onFileChange}
171
175
  showNavigation={variant.navigation}
176
+ editPathByModelProps={editPathByModelProps}
172
177
  onlyOfficeProps={{
173
178
  isEnabled: variant.onlyOfficeEnabled,
174
179
  opener: () => alert('This is a demo, no Only Office opener here')
@@ -12,9 +12,17 @@ import ViewerInformationsWrapper from './ViewerInformationsWrapper'
12
12
  import EncryptedProvider from './EncryptedProvider'
13
13
  import { ViewerSnackbarProvider } from './snackbar/ViewerSnackbarProvider'
14
14
  import ViewerSnackbar from './snackbar/ViewerSnackbar'
15
+ import { ActionMenuProvider } from './Panel/ActionMenuProvider'
15
16
 
16
17
  const ViewerContainer = props => {
17
- const { className, disableFooter, disablePanel, children, ...rest } = props
18
+ const {
19
+ className,
20
+ disableFooter,
21
+ disablePanel,
22
+ editPathByModelProps,
23
+ children,
24
+ ...rest
25
+ } = props
18
26
  const { currentIndex, files, currentURL } = props
19
27
  const toolbarRef = createRef()
20
28
  const { isDesktop } = useBreakpoints()
@@ -27,27 +35,29 @@ const ViewerContainer = props => {
27
35
 
28
36
  return (
29
37
  <ViewerSnackbarProvider>
30
- <ViewerWrapper className={className}>
31
- <EncryptedProvider url={currentURL}>
32
- <Viewer
33
- {...rest}
34
- currentFile={currentFile}
35
- hasPrevious={hasPrevious}
36
- hasNext={hasNext}
38
+ <ActionMenuProvider editPathByModelProps={editPathByModelProps}>
39
+ <ViewerWrapper className={className}>
40
+ <EncryptedProvider url={currentURL}>
41
+ <Viewer
42
+ {...rest}
43
+ currentFile={currentFile}
44
+ hasPrevious={hasPrevious}
45
+ hasNext={hasNext}
46
+ validForPanel={validForPanel}
47
+ toolbarRef={toolbarRef}
48
+ />
49
+ </EncryptedProvider>
50
+ <ViewerInformationsWrapper
51
+ disableFooter={disableFooter}
37
52
  validForPanel={validForPanel}
53
+ currentFile={currentFile}
38
54
  toolbarRef={toolbarRef}
39
- />
40
- </EncryptedProvider>
41
- <ViewerInformationsWrapper
42
- disableFooter={disableFooter}
43
- validForPanel={validForPanel}
44
- currentFile={currentFile}
45
- toolbarRef={toolbarRef}
46
- >
47
- {children}
48
- </ViewerInformationsWrapper>
49
- </ViewerWrapper>
50
- <ViewerSnackbar />
55
+ >
56
+ {children}
57
+ </ViewerInformationsWrapper>
58
+ </ViewerWrapper>
59
+ <ViewerSnackbar />
60
+ </ActionMenuProvider>
51
61
  </ViewerSnackbarProvider>
52
62
  )
53
63
  }
@@ -20,7 +20,18 @@ export const knowNumberMetadataNames = [
20
20
  'vinNumber',
21
21
  'ibanNumber'
22
22
  ]
23
- export const knowOtherMetadataNames = ['owner', 'page', 'qualification']
23
+ export const knowOtherMetadataNames = ['contact', 'page', 'qualification']
24
+
25
+ export const getCurrentModel = metadataName => {
26
+ if (
27
+ knownDateMetadataNames.includes(metadataName) ||
28
+ knowNumberMetadataNames.includes(metadataName)
29
+ ) {
30
+ return 'information'
31
+ }
32
+ if (metadataName === 'contact') return 'contact'
33
+ if (metadataName === 'page') return 'page'
34
+ }
24
35
 
25
36
  /**
26
37
  * @typedef {object} Reference
@@ -117,3 +128,18 @@ export const formatDate = ({ f, lang, date }) => {
117
128
  }
118
129
  return f(date, 'DD/MM/YYYY')
119
130
  }
131
+
132
+ /**
133
+ * @param {{ information: string, page: string }} editPathByModelProps
134
+ * @param {string} currentModel
135
+ * @param {string} name
136
+ * @returns {string}
137
+ */
138
+ export const buildEditAttributePath = (
139
+ editPathByModelProps,
140
+ currentModel,
141
+ name
142
+ ) => {
143
+ const currentPath = editPathByModelProps[currentModel]
144
+ return currentPath?.replace(/__NAME__/, name) ?? ''
145
+ }