cozy-ui 117.0.0 → 117.1.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 +7 -0
- package/package.json +1 -1
- package/react/ActionsMenu/Actions/addToFavorites.js +66 -0
- package/react/ActionsMenu/Actions/download.js +42 -0
- package/react/ActionsMenu/Actions/index.js +3 -0
- package/react/ActionsMenu/Actions/locales/en.json +12 -0
- package/react/ActionsMenu/Actions/locales/fr.json +12 -0
- package/react/ActionsMenu/Actions/removeFromFavorites.js +66 -0
- package/transpiled/react/ActionsMenu/Actions/addToFavorites.js +144 -0
- package/transpiled/react/ActionsMenu/Actions/download.js +49 -0
- package/transpiled/react/ActionsMenu/Actions/index.js +3 -0
- package/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales.js +24 -0
- package/transpiled/react/ActionsMenu/Actions/removeFromFavorites.js +144 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [117.1.0](https://github.com/cozy/cozy-ui/compare/v117.0.0...v117.1.0) (2025-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add Download and Add/Remove favorites actions ([6e4bca4](https://github.com/cozy/cozy-ui/commit/6e4bca4))
|
|
7
|
+
|
|
1
8
|
# [117.0.0](https://github.com/cozy/cozy-ui/compare/v116.0.0...v117.0.0) (2025-01-13)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitFilename } from 'cozy-client/dist/models/file'
|
|
4
|
+
|
|
5
|
+
import { getActionsI18n } from './locales/withActionsLocales'
|
|
6
|
+
import Icon from '../../Icon'
|
|
7
|
+
import StarOutlineIcon from '../../Icons/StarOutline'
|
|
8
|
+
import ListItemIcon from '../../ListItemIcon'
|
|
9
|
+
import ListItemText from '../../ListItemText'
|
|
10
|
+
import ActionsMenuItem from '../ActionsMenuItem'
|
|
11
|
+
|
|
12
|
+
const makeComponent = (label, icon) => {
|
|
13
|
+
const Component = forwardRef((props, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<ActionsMenuItem {...props} ref={ref}>
|
|
16
|
+
<ListItemIcon>
|
|
17
|
+
<Icon icon={icon} />
|
|
18
|
+
</ListItemIcon>
|
|
19
|
+
<ListItemText primary={label} />
|
|
20
|
+
</ActionsMenuItem>
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
Component.displayName = 'addToFavorites'
|
|
25
|
+
|
|
26
|
+
return Component
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const addToFavorites = ({ showAlert }) => {
|
|
30
|
+
const { t } = getActionsI18n()
|
|
31
|
+
const icon = StarOutlineIcon
|
|
32
|
+
const label = t('favorites.add.label')
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: 'addToFavorites',
|
|
36
|
+
icon,
|
|
37
|
+
label,
|
|
38
|
+
displayCondition: docs =>
|
|
39
|
+
docs.length > 0 && docs.every(doc => !doc.cozyMetadata?.favorite),
|
|
40
|
+
Component: makeComponent(label, icon),
|
|
41
|
+
action: async (docs, { client }) => {
|
|
42
|
+
try {
|
|
43
|
+
for (const doc of docs) {
|
|
44
|
+
await client.save({
|
|
45
|
+
...doc,
|
|
46
|
+
cozyMetadata: {
|
|
47
|
+
...doc.cozyMetadata,
|
|
48
|
+
favorite: true
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { filename } = splitFilename(docs[0])
|
|
54
|
+
showAlert({
|
|
55
|
+
message: t('favorites.add.success', {
|
|
56
|
+
filename,
|
|
57
|
+
smart_count: docs.length
|
|
58
|
+
}),
|
|
59
|
+
severity: 'success'
|
|
60
|
+
})
|
|
61
|
+
} catch (error) {
|
|
62
|
+
showAlert({ message: t('favorites.error'), severity: 'error' })
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { downloadFile } from 'cozy-client/dist/models/file'
|
|
4
|
+
|
|
5
|
+
import { getActionsI18n } from './locales/withActionsLocales'
|
|
6
|
+
import Icon from '../../Icon'
|
|
7
|
+
import DownloadIcon from '../../Icons/Download'
|
|
8
|
+
import ListItemIcon from '../../ListItemIcon'
|
|
9
|
+
import ListItemText from '../../ListItemText'
|
|
10
|
+
import ActionsMenuItem from '../ActionsMenuItem'
|
|
11
|
+
|
|
12
|
+
const makeComponent = (label, icon) => {
|
|
13
|
+
const Component = forwardRef((props, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<ActionsMenuItem {...props} ref={ref}>
|
|
16
|
+
<ListItemIcon>
|
|
17
|
+
<Icon icon={icon} />
|
|
18
|
+
</ListItemIcon>
|
|
19
|
+
<ListItemText primary={label} />
|
|
20
|
+
</ActionsMenuItem>
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
Component.displayName = 'download'
|
|
25
|
+
|
|
26
|
+
return Component
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const download = ({ encryptedUrl }) => {
|
|
30
|
+
const { t } = getActionsI18n()
|
|
31
|
+
const icon = DownloadIcon
|
|
32
|
+
const label = t('download')
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: 'download',
|
|
36
|
+
icon,
|
|
37
|
+
label,
|
|
38
|
+
Component: makeComponent(label, icon),
|
|
39
|
+
action: (docs, { client, webviewIntent }) =>
|
|
40
|
+
downloadFile({ client, file: docs[0], url: encryptedUrl, webviewIntent })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -5,6 +5,9 @@ export { smsTo } from './smsTo'
|
|
|
5
5
|
export { call } from './call'
|
|
6
6
|
export { emailTo } from './emailTo'
|
|
7
7
|
export { print } from './print'
|
|
8
|
+
export { download } from './download'
|
|
9
|
+
export { addToFavorites } from './addToFavorites'
|
|
10
|
+
export { removeFromFavorites } from './removeFromFavorites'
|
|
8
11
|
export { viewInContacts } from './viewInContacts'
|
|
9
12
|
export { viewInDrive } from './viewInDrive'
|
|
10
13
|
export { copyToClipboard } from './copyToClipboard'
|
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
"emailTo": "Send an email",
|
|
6
6
|
"smsTo": "Send a message",
|
|
7
7
|
"print": "Print",
|
|
8
|
+
"download": "Download",
|
|
9
|
+
"favorites": {
|
|
10
|
+
"add": {
|
|
11
|
+
"label": "Add to favorites",
|
|
12
|
+
"success": "%{filename} has been added to favorites |||| These items have been added to favorites"
|
|
13
|
+
},
|
|
14
|
+
"remove": {
|
|
15
|
+
"label": "Remove from favorites",
|
|
16
|
+
"success": "%{filename} has been removed from favorites |||| These items have been removed from favorites"
|
|
17
|
+
},
|
|
18
|
+
"error": "An error occurred, please try again."
|
|
19
|
+
},
|
|
8
20
|
"others": "Others",
|
|
9
21
|
"editAttribute": "Edit attribute",
|
|
10
22
|
"copyToClipboard": {
|
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
"emailTo": "Envoyer un e-mail",
|
|
6
6
|
"smsTo": "Envoyer un message",
|
|
7
7
|
"print": "Imprimer",
|
|
8
|
+
"download": "Télécharger",
|
|
9
|
+
"favorites": {
|
|
10
|
+
"add": {
|
|
11
|
+
"label": "Ajouter aux favoris",
|
|
12
|
+
"success": "%{filename} a été ajouté aux favoris |||| Ces éléments ont été ajoutés aux favoris"
|
|
13
|
+
},
|
|
14
|
+
"remove": {
|
|
15
|
+
"label": "Retirer des favoris",
|
|
16
|
+
"success": "%{filename} a été retiré des favoris |||| Ces éléments ont été retirés des favoris"
|
|
17
|
+
},
|
|
18
|
+
"error": "Une erreur est survenue, merci de réessayer."
|
|
19
|
+
},
|
|
8
20
|
"others": "Autres",
|
|
9
21
|
"editAttribute": "Editer l'attribut",
|
|
10
22
|
"copyToClipboard": {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitFilename } from 'cozy-client/dist/models/file'
|
|
4
|
+
|
|
5
|
+
import { getActionsI18n } from './locales/withActionsLocales'
|
|
6
|
+
import Icon from '../../Icon'
|
|
7
|
+
import StarIcon from '../../Icons/Star'
|
|
8
|
+
import ListItemIcon from '../../ListItemIcon'
|
|
9
|
+
import ListItemText from '../../ListItemText'
|
|
10
|
+
import ActionsMenuItem from '../ActionsMenuItem'
|
|
11
|
+
|
|
12
|
+
const makeComponent = (label, icon) => {
|
|
13
|
+
const Component = forwardRef((props, ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<ActionsMenuItem {...props} ref={ref}>
|
|
16
|
+
<ListItemIcon>
|
|
17
|
+
<Icon icon={icon} />
|
|
18
|
+
</ListItemIcon>
|
|
19
|
+
<ListItemText primary={label} />
|
|
20
|
+
</ActionsMenuItem>
|
|
21
|
+
)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
Component.displayName = 'removeFromFavorites'
|
|
25
|
+
|
|
26
|
+
return Component
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const removeFromFavorites = ({ showAlert }) => {
|
|
30
|
+
const { t } = getActionsI18n()
|
|
31
|
+
const icon = StarIcon
|
|
32
|
+
const label = t('favorites.remove.label')
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: 'removeFromFavorites',
|
|
36
|
+
icon,
|
|
37
|
+
label,
|
|
38
|
+
displayCondition: docs =>
|
|
39
|
+
docs.length > 0 && docs.every(doc => doc.cozyMetadata?.favorite),
|
|
40
|
+
Component: makeComponent(label, icon),
|
|
41
|
+
action: async (docs, { client }) => {
|
|
42
|
+
try {
|
|
43
|
+
for (const doc of docs) {
|
|
44
|
+
await client.save({
|
|
45
|
+
...doc,
|
|
46
|
+
cozyMetadata: {
|
|
47
|
+
...doc.cozyMetadata,
|
|
48
|
+
favorite: false
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { filename } = splitFilename(docs[0])
|
|
54
|
+
showAlert({
|
|
55
|
+
message: t('favorites.success.remove', {
|
|
56
|
+
filename,
|
|
57
|
+
smart_count: docs.length
|
|
58
|
+
}),
|
|
59
|
+
severity: 'success'
|
|
60
|
+
})
|
|
61
|
+
} catch (error) {
|
|
62
|
+
showAlert({ message: t('favorites.error'), severity: 'error' })
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
import React, { forwardRef } from 'react';
|
|
17
|
+
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
18
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
19
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
|
+
import StarOutlineIcon from "cozy-ui/transpiled/react/Icons/StarOutline";
|
|
21
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
22
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
23
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
24
|
+
|
|
25
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
26
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
+
ref: ref
|
|
29
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
icon: icon
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: label
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
Component.displayName = 'addToFavorites';
|
|
36
|
+
return Component;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var addToFavorites = function addToFavorites(_ref) {
|
|
40
|
+
var showAlert = _ref.showAlert;
|
|
41
|
+
|
|
42
|
+
var _getActionsI18n = getActionsI18n(),
|
|
43
|
+
t = _getActionsI18n.t;
|
|
44
|
+
|
|
45
|
+
var icon = StarOutlineIcon;
|
|
46
|
+
var label = t('favorites.add.label');
|
|
47
|
+
return {
|
|
48
|
+
name: 'addToFavorites',
|
|
49
|
+
icon: icon,
|
|
50
|
+
label: label,
|
|
51
|
+
displayCondition: function displayCondition(docs) {
|
|
52
|
+
return docs.length > 0 && docs.every(function (doc) {
|
|
53
|
+
var _doc$cozyMetadata;
|
|
54
|
+
|
|
55
|
+
return !((_doc$cozyMetadata = doc.cozyMetadata) !== null && _doc$cozyMetadata !== void 0 && _doc$cozyMetadata.favorite);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
Component: makeComponent(label, icon),
|
|
59
|
+
action: function () {
|
|
60
|
+
var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(docs, _ref2) {
|
|
61
|
+
var client, _iterator, _step, doc, _splitFilename, filename;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
client = _ref2.client;
|
|
68
|
+
_context.prev = 1;
|
|
69
|
+
_iterator = _createForOfIteratorHelper(docs);
|
|
70
|
+
_context.prev = 3;
|
|
71
|
+
|
|
72
|
+
_iterator.s();
|
|
73
|
+
|
|
74
|
+
case 5:
|
|
75
|
+
if ((_step = _iterator.n()).done) {
|
|
76
|
+
_context.next = 11;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
doc = _step.value;
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
return client.save(_objectSpread(_objectSpread({}, doc), {}, {
|
|
83
|
+
cozyMetadata: _objectSpread(_objectSpread({}, doc.cozyMetadata), {}, {
|
|
84
|
+
favorite: true
|
|
85
|
+
})
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
case 9:
|
|
89
|
+
_context.next = 5;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case 11:
|
|
93
|
+
_context.next = 16;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 13:
|
|
97
|
+
_context.prev = 13;
|
|
98
|
+
_context.t0 = _context["catch"](3);
|
|
99
|
+
|
|
100
|
+
_iterator.e(_context.t0);
|
|
101
|
+
|
|
102
|
+
case 16:
|
|
103
|
+
_context.prev = 16;
|
|
104
|
+
|
|
105
|
+
_iterator.f();
|
|
106
|
+
|
|
107
|
+
return _context.finish(16);
|
|
108
|
+
|
|
109
|
+
case 19:
|
|
110
|
+
_splitFilename = splitFilename(docs[0]), filename = _splitFilename.filename;
|
|
111
|
+
showAlert({
|
|
112
|
+
message: t('favorites.add.success', {
|
|
113
|
+
filename: filename,
|
|
114
|
+
smart_count: docs.length
|
|
115
|
+
}),
|
|
116
|
+
severity: 'success'
|
|
117
|
+
});
|
|
118
|
+
_context.next = 26;
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 23:
|
|
122
|
+
_context.prev = 23;
|
|
123
|
+
_context.t1 = _context["catch"](1);
|
|
124
|
+
showAlert({
|
|
125
|
+
message: t('favorites.error'),
|
|
126
|
+
severity: 'error'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
case 26:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee, null, [[1, 23], [3, 13, 16, 19]]);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
function action(_x, _x2) {
|
|
138
|
+
return _action.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return action;
|
|
142
|
+
}()
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { downloadFile } from 'cozy-client/dist/models/file';
|
|
4
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
5
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
6
|
+
import DownloadIcon from "cozy-ui/transpiled/react/Icons/Download";
|
|
7
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
8
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
9
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
10
|
+
|
|
11
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
12
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
14
|
+
ref: ref
|
|
15
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
16
|
+
icon: icon
|
|
17
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
18
|
+
primary: label
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
Component.displayName = 'download';
|
|
22
|
+
return Component;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export var download = function download(_ref) {
|
|
26
|
+
var encryptedUrl = _ref.encryptedUrl;
|
|
27
|
+
|
|
28
|
+
var _getActionsI18n = getActionsI18n(),
|
|
29
|
+
t = _getActionsI18n.t;
|
|
30
|
+
|
|
31
|
+
var icon = DownloadIcon;
|
|
32
|
+
var label = t('download');
|
|
33
|
+
return {
|
|
34
|
+
name: 'download',
|
|
35
|
+
icon: icon,
|
|
36
|
+
label: label,
|
|
37
|
+
Component: makeComponent(label, icon),
|
|
38
|
+
action: function action(docs, _ref2) {
|
|
39
|
+
var client = _ref2.client,
|
|
40
|
+
webviewIntent = _ref2.webviewIntent;
|
|
41
|
+
return downloadFile({
|
|
42
|
+
client: client,
|
|
43
|
+
file: docs[0],
|
|
44
|
+
url: encryptedUrl,
|
|
45
|
+
webviewIntent: webviewIntent
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -5,6 +5,9 @@ export { smsTo } from './smsTo';
|
|
|
5
5
|
export { call } from './call';
|
|
6
6
|
export { emailTo } from './emailTo';
|
|
7
7
|
export { print } from './print';
|
|
8
|
+
export { download } from './download';
|
|
9
|
+
export { addToFavorites } from './addToFavorites';
|
|
10
|
+
export { removeFromFavorites } from './removeFromFavorites';
|
|
8
11
|
export { viewInContacts } from './viewInContacts';
|
|
9
12
|
export { viewInDrive } from './viewInDrive';
|
|
10
13
|
export { copyToClipboard } from './copyToClipboard';
|
|
@@ -5,6 +5,18 @@ var en = {
|
|
|
5
5
|
emailTo: "Send an email",
|
|
6
6
|
smsTo: "Send a message",
|
|
7
7
|
print: "Print",
|
|
8
|
+
download: "Download",
|
|
9
|
+
favorites: {
|
|
10
|
+
add: {
|
|
11
|
+
label: "Add to favorites",
|
|
12
|
+
success: "%{filename} has been added to favorites |||| These items have been added to favorites"
|
|
13
|
+
},
|
|
14
|
+
remove: {
|
|
15
|
+
label: "Remove from favorites",
|
|
16
|
+
success: "%{filename} has been removed from favorites |||| These items have been removed from favorites"
|
|
17
|
+
},
|
|
18
|
+
error: "An error occurred, please try again."
|
|
19
|
+
},
|
|
8
20
|
others: "Others",
|
|
9
21
|
editAttribute: "Edit attribute",
|
|
10
22
|
copyToClipboard: {
|
|
@@ -21,6 +33,18 @@ var fr = {
|
|
|
21
33
|
emailTo: "Envoyer un e-mail",
|
|
22
34
|
smsTo: "Envoyer un message",
|
|
23
35
|
print: "Imprimer",
|
|
36
|
+
download: "T\xE9l\xE9charger",
|
|
37
|
+
favorites: {
|
|
38
|
+
add: {
|
|
39
|
+
label: "Ajouter aux favoris",
|
|
40
|
+
success: "%{filename} a \xE9t\xE9 ajout\xE9 aux favoris |||| Ces \xE9l\xE9ments ont \xE9t\xE9 ajout\xE9s aux favoris"
|
|
41
|
+
},
|
|
42
|
+
remove: {
|
|
43
|
+
label: "Retirer des favoris",
|
|
44
|
+
success: "%{filename} a \xE9t\xE9 retir\xE9 des favoris |||| Ces \xE9l\xE9ments ont \xE9t\xE9 retir\xE9s des favoris"
|
|
45
|
+
},
|
|
46
|
+
error: "Une erreur est survenue, merci de r\xE9essayer."
|
|
47
|
+
},
|
|
24
48
|
others: "Autres",
|
|
25
49
|
editAttribute: "Editer l'attribut",
|
|
26
50
|
copyToClipboard: {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
import React, { forwardRef } from 'react';
|
|
17
|
+
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
18
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
19
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
|
+
import StarIcon from "cozy-ui/transpiled/react/Icons/Star";
|
|
21
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
22
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
23
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
24
|
+
|
|
25
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
26
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
+
ref: ref
|
|
29
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
icon: icon
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: label
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
Component.displayName = 'removeFromFavorites';
|
|
36
|
+
return Component;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var removeFromFavorites = function removeFromFavorites(_ref) {
|
|
40
|
+
var showAlert = _ref.showAlert;
|
|
41
|
+
|
|
42
|
+
var _getActionsI18n = getActionsI18n(),
|
|
43
|
+
t = _getActionsI18n.t;
|
|
44
|
+
|
|
45
|
+
var icon = StarIcon;
|
|
46
|
+
var label = t('favorites.remove.label');
|
|
47
|
+
return {
|
|
48
|
+
name: 'removeFromFavorites',
|
|
49
|
+
icon: icon,
|
|
50
|
+
label: label,
|
|
51
|
+
displayCondition: function displayCondition(docs) {
|
|
52
|
+
return docs.length > 0 && docs.every(function (doc) {
|
|
53
|
+
var _doc$cozyMetadata;
|
|
54
|
+
|
|
55
|
+
return (_doc$cozyMetadata = doc.cozyMetadata) === null || _doc$cozyMetadata === void 0 ? void 0 : _doc$cozyMetadata.favorite;
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
Component: makeComponent(label, icon),
|
|
59
|
+
action: function () {
|
|
60
|
+
var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(docs, _ref2) {
|
|
61
|
+
var client, _iterator, _step, doc, _splitFilename, filename;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
client = _ref2.client;
|
|
68
|
+
_context.prev = 1;
|
|
69
|
+
_iterator = _createForOfIteratorHelper(docs);
|
|
70
|
+
_context.prev = 3;
|
|
71
|
+
|
|
72
|
+
_iterator.s();
|
|
73
|
+
|
|
74
|
+
case 5:
|
|
75
|
+
if ((_step = _iterator.n()).done) {
|
|
76
|
+
_context.next = 11;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
doc = _step.value;
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
return client.save(_objectSpread(_objectSpread({}, doc), {}, {
|
|
83
|
+
cozyMetadata: _objectSpread(_objectSpread({}, doc.cozyMetadata), {}, {
|
|
84
|
+
favorite: false
|
|
85
|
+
})
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
case 9:
|
|
89
|
+
_context.next = 5;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case 11:
|
|
93
|
+
_context.next = 16;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 13:
|
|
97
|
+
_context.prev = 13;
|
|
98
|
+
_context.t0 = _context["catch"](3);
|
|
99
|
+
|
|
100
|
+
_iterator.e(_context.t0);
|
|
101
|
+
|
|
102
|
+
case 16:
|
|
103
|
+
_context.prev = 16;
|
|
104
|
+
|
|
105
|
+
_iterator.f();
|
|
106
|
+
|
|
107
|
+
return _context.finish(16);
|
|
108
|
+
|
|
109
|
+
case 19:
|
|
110
|
+
_splitFilename = splitFilename(docs[0]), filename = _splitFilename.filename;
|
|
111
|
+
showAlert({
|
|
112
|
+
message: t('favorites.success.remove', {
|
|
113
|
+
filename: filename,
|
|
114
|
+
smart_count: docs.length
|
|
115
|
+
}),
|
|
116
|
+
severity: 'success'
|
|
117
|
+
});
|
|
118
|
+
_context.next = 26;
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 23:
|
|
122
|
+
_context.prev = 23;
|
|
123
|
+
_context.t1 = _context["catch"](1);
|
|
124
|
+
showAlert({
|
|
125
|
+
message: t('favorites.error'),
|
|
126
|
+
severity: 'error'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
case 26:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee, null, [[1, 23], [3, 13, 16, 19]]);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
function action(_x, _x2) {
|
|
138
|
+
return _action.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return action;
|
|
142
|
+
}()
|
|
143
|
+
};
|
|
144
|
+
};
|