cozy-ui 130.8.1 → 130.10.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 +18 -0
- package/package.json +1 -1
- package/react/CozyDialogs/SpecificDialogs/Readme.md +26 -0
- package/react/CozyDialogs/SpecificDialogs/ShortcutDialog.jsx +120 -0
- package/react/CozyDialogs/SpecificDialogs/helpers/shortcuts.js +61 -0
- package/react/CozyDialogs/SpecificDialogs/index.jsx +1 -0
- package/react/CozyDialogs/SpecificDialogs/locales/en.json +14 -0
- package/react/CozyDialogs/SpecificDialogs/locales/fr.json +14 -0
- package/react/CozyDialogs/SpecificDialogs/locales/ru.json +15 -1
- package/react/CozyDialogs/SpecificDialogs/locales/vi.json +15 -1
- package/react/CozyDialogs/index.jsx +2 -1
- package/react/EditBadge/EditMenu.jsx +102 -0
- package/react/EditBadge/Readme.md +22 -0
- package/react/EditBadge/StatusWrapper.jsx +32 -0
- package/react/EditBadge/helpers.js +102 -0
- package/react/EditBadge/index.jsx +81 -0
- package/react/EditBadge/locales/en.json +18 -0
- package/react/EditBadge/locales/fr.json +18 -0
- package/react/EditBadge/locales/index.js +11 -0
- package/react/EditBadge/locales/ru.json +18 -0
- package/react/EditBadge/locales/vi.json +18 -0
- package/react/providers/DemoProvider.jsx +6 -3
- package/react/utils/react.js +14 -1
- package/transpiled/react/CozyDialogs/SpecificDialogs/ShortcutDialog.d.ts +2 -0
- package/transpiled/react/CozyDialogs/SpecificDialogs/ShortcutDialog.js +114 -0
- package/transpiled/react/CozyDialogs/SpecificDialogs/helpers/shortcuts.d.ts +13 -0
- package/transpiled/react/CozyDialogs/SpecificDialogs/helpers/shortcuts.js +83 -0
- package/transpiled/react/CozyDialogs/SpecificDialogs/index.d.ts +1 -0
- package/transpiled/react/CozyDialogs/SpecificDialogs/index.js +2 -1
- package/transpiled/react/CozyDialogs/SpecificDialogs/withSpecificDialogsLocales.js +56 -0
- package/transpiled/react/CozyDialogs/index.d.ts +1 -1
- package/transpiled/react/CozyDialogs/index.js +1 -1
- package/transpiled/react/EditBadge/EditMenu.d.ts +11 -0
- package/transpiled/react/EditBadge/EditMenu.js +93 -0
- package/transpiled/react/EditBadge/StatusWrapper.d.ts +9 -0
- package/transpiled/react/EditBadge/StatusWrapper.js +44 -0
- package/transpiled/react/EditBadge/helpers.d.ts +20 -0
- package/transpiled/react/EditBadge/helpers.js +153 -0
- package/transpiled/react/EditBadge/index.d.ts +23 -0
- package/transpiled/react/EditBadge/index.js +89 -0
- package/transpiled/react/EditBadge/locales/index.d.ts +10 -0
- package/transpiled/react/EditBadge/locales/index.js +78 -0
- package/transpiled/react/providers/DemoProvider.js +3 -2
- package/transpiled/react/utils/react.d.ts +1 -0
- package/transpiled/react/utils/react.js +19 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EditBadge": {
|
|
3
|
+
"menu": {
|
|
4
|
+
"update": "Update",
|
|
5
|
+
"delete": "Delete"
|
|
6
|
+
},
|
|
7
|
+
"upload": {
|
|
8
|
+
"file-size": "The file size limit is 5MB.",
|
|
9
|
+
"file-type": "The file type is not supported. Please try again.",
|
|
10
|
+
"success": "Avatar updated successfully",
|
|
11
|
+
"error": "The avatar upload has failed. Please try again."
|
|
12
|
+
},
|
|
13
|
+
"delete": {
|
|
14
|
+
"success": "Avatar deleted successfully",
|
|
15
|
+
"error": "The avatar deletion has failed. Please try again."
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EditBadge": {
|
|
3
|
+
"menu": {
|
|
4
|
+
"update": "Mettre à jour",
|
|
5
|
+
"delete": "Supprimer"
|
|
6
|
+
},
|
|
7
|
+
"upload": {
|
|
8
|
+
"file-size": "La taille du fichier est limitée à 5Mo.",
|
|
9
|
+
"file-type": "Le type de fichier n'est pas supporté. Merci de réessayer.",
|
|
10
|
+
"success": "Avatar mis à jour avec succès",
|
|
11
|
+
"error": "La mise à jour de l'avatar a échoué. Merci de réessayer."
|
|
12
|
+
},
|
|
13
|
+
"delete": {
|
|
14
|
+
"success": "Avatar supprimé avec succès",
|
|
15
|
+
"error": "La suppression de l'avatar a échoué. Merci de réessayer."
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EditBadge": {
|
|
3
|
+
"menu": {
|
|
4
|
+
"update": "Обновить",
|
|
5
|
+
"delete": "Удалить"
|
|
6
|
+
},
|
|
7
|
+
"upload": {
|
|
8
|
+
"file-size": "Максимальный размер файла — 5 МБ.",
|
|
9
|
+
"file-type": "Тип файла не поддерживается. Пожалуйста, попробуйте снова.",
|
|
10
|
+
"success": "Аватар успешно обновлён",
|
|
11
|
+
"error": "Не удалось загрузить аватар. Пожалуйста, попробуйте снова."
|
|
12
|
+
},
|
|
13
|
+
"delete": {
|
|
14
|
+
"success": "Аватар успешно удалён",
|
|
15
|
+
"error": "Не удалось удалить аватар. Пожалуйста, попробуйте снова."
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EditBadge": {
|
|
3
|
+
"menu": {
|
|
4
|
+
"update": "Cập nhật",
|
|
5
|
+
"delete": "Xóa"
|
|
6
|
+
},
|
|
7
|
+
"upload": {
|
|
8
|
+
"file-size": "Giới hạn kích thước tệp là 5MB.",
|
|
9
|
+
"file-type": "Loại tệp không được hỗ trợ. Vui lòng thử lại.",
|
|
10
|
+
"success": "Cập nhật ảnh đại diện thành công",
|
|
11
|
+
"error": "Tải ảnh đại diện thất bại. Vui lòng thử lại."
|
|
12
|
+
},
|
|
13
|
+
"delete": {
|
|
14
|
+
"success": "Xóa ảnh đại diện thành công",
|
|
15
|
+
"error": "Xóa ảnh đại diện thất bại. Vui lòng thử lại."
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -4,6 +4,7 @@ import { CozyProvider } from 'cozy-client'
|
|
|
4
4
|
|
|
5
5
|
import { BreakpointsProvider } from './Breakpoints'
|
|
6
6
|
import CozyTheme from './CozyTheme'
|
|
7
|
+
import AlertProvider from '../providers/Alert'
|
|
7
8
|
import I18n from '../providers/I18n'
|
|
8
9
|
|
|
9
10
|
const defaultClient = {
|
|
@@ -29,9 +30,11 @@ const DemoProvider = ({ client, variant, dictRequire, children }) => {
|
|
|
29
30
|
return (
|
|
30
31
|
<CozyProvider client={client || defaultClient}>
|
|
31
32
|
<BreakpointsProvider>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
33
|
+
<AlertProvider>
|
|
34
|
+
<I18n lang={lang} dictRequire={_dictRequire}>
|
|
35
|
+
<CozyTheme variant={variant}>{children}</CozyTheme>
|
|
36
|
+
</I18n>
|
|
37
|
+
</AlertProvider>
|
|
35
38
|
</BreakpointsProvider>
|
|
36
39
|
</CozyProvider>
|
|
37
40
|
)
|
package/react/utils/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, Children } from 'react'
|
|
1
|
+
import { Fragment, Children, isValidElement, cloneElement } from 'react'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the name of the node
|
|
@@ -33,3 +33,16 @@ export const getLastChild = props => {
|
|
|
33
33
|
? getChildren(lastChild.props)[0]
|
|
34
34
|
: lastChild
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Clone a React child and add props on it
|
|
39
|
+
* @param {React.ReactElement} children
|
|
40
|
+
* @param {Function} propsCallback - get child props as arg, return new props as object
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export const AddPropsToChildren = (children, propsCallback) =>
|
|
44
|
+
Children.map(children, child =>
|
|
45
|
+
isValidElement(child)
|
|
46
|
+
? cloneElement(child, { ...propsCallback(child.props) })
|
|
47
|
+
: null
|
|
48
|
+
)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { checkAndSaveShortcut, makeHumanReadableFileName } from "cozy-ui/transpiled/react/CozyDialogs/SpecificDialogs/helpers/shortcuts";
|
|
5
|
+
import withSpecificDialogsLocales from "cozy-ui/transpiled/react/CozyDialogs/SpecificDialogs/withSpecificDialogsLocales";
|
|
6
|
+
import { ConfirmDialog } from "cozy-ui/transpiled/react/CozyDialogs";
|
|
7
|
+
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
8
|
+
import Stack from "cozy-ui/transpiled/react/Stack";
|
|
9
|
+
import TextField from "cozy-ui/transpiled/react/TextField";
|
|
10
|
+
import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
|
|
11
|
+
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
12
|
+
var ENTER_KEY = 13;
|
|
13
|
+
|
|
14
|
+
var ShortcutDialog = function ShortcutDialog(_ref) {
|
|
15
|
+
var shortcut = _ref.shortcut,
|
|
16
|
+
onSave = _ref.onSave,
|
|
17
|
+
onClose = _ref.onClose;
|
|
18
|
+
|
|
19
|
+
var _useI18n = useI18n(),
|
|
20
|
+
t = _useI18n.t;
|
|
21
|
+
|
|
22
|
+
var _useAlert = useAlert(),
|
|
23
|
+
showAlert = _useAlert.showAlert;
|
|
24
|
+
|
|
25
|
+
var initialName = makeHumanReadableFileName((shortcut === null || shortcut === void 0 ? void 0 : shortcut.name) || '');
|
|
26
|
+
var initialUrl = (shortcut === null || shortcut === void 0 ? void 0 : shortcut.url) || '';
|
|
27
|
+
var isEditing = !!shortcut;
|
|
28
|
+
|
|
29
|
+
var _useState = useState(initialName),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
fileName = _useState2[0],
|
|
32
|
+
setFilename = _useState2[1];
|
|
33
|
+
|
|
34
|
+
var _useState3 = useState(initialUrl),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
url = _useState4[0],
|
|
37
|
+
setUrl = _useState4[1];
|
|
38
|
+
|
|
39
|
+
var saveShortcut = function saveShortcut() {
|
|
40
|
+
checkAndSaveShortcut({
|
|
41
|
+
fileName: fileName,
|
|
42
|
+
url: url,
|
|
43
|
+
isEditing: isEditing,
|
|
44
|
+
onSave: onSave,
|
|
45
|
+
onClose: onClose,
|
|
46
|
+
showAlert: showAlert,
|
|
47
|
+
t: t
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
52
|
+
if (e.keyCode === ENTER_KEY) {
|
|
53
|
+
saveShortcut();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return /*#__PURE__*/React.createElement(ConfirmDialog, {
|
|
58
|
+
open: true,
|
|
59
|
+
title: isEditing ? t('shortcut-dialog.edit-title') : t('shortcut-dialog.create-title'),
|
|
60
|
+
onClose: onClose,
|
|
61
|
+
content: /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TextField, {
|
|
62
|
+
label: t('shortcut-dialog.url'),
|
|
63
|
+
value: url,
|
|
64
|
+
id: "shortcuturl",
|
|
65
|
+
variant: "outlined",
|
|
66
|
+
onChange: function onChange(e) {
|
|
67
|
+
return setUrl(e.target.value);
|
|
68
|
+
},
|
|
69
|
+
onKeyDown: function onKeyDown(e) {
|
|
70
|
+
return handleKeyDown(e);
|
|
71
|
+
},
|
|
72
|
+
autoComplete: "off",
|
|
73
|
+
fullWidth: true,
|
|
74
|
+
margin: "normal",
|
|
75
|
+
autoFocus: true
|
|
76
|
+
})), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TextField, {
|
|
77
|
+
label: t('shortcut-dialog.filename'),
|
|
78
|
+
value: fileName,
|
|
79
|
+
id: "shortcutfilename",
|
|
80
|
+
variant: "outlined",
|
|
81
|
+
onChange: function onChange(e) {
|
|
82
|
+
return setFilename(e.target.value);
|
|
83
|
+
},
|
|
84
|
+
onKeyDown: function onKeyDown(e) {
|
|
85
|
+
return handleKeyDown(e);
|
|
86
|
+
},
|
|
87
|
+
autoComplete: "off",
|
|
88
|
+
fullWidth: true,
|
|
89
|
+
margin: "normal"
|
|
90
|
+
}))),
|
|
91
|
+
actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
92
|
+
variant: "secondary",
|
|
93
|
+
onClick: onClose,
|
|
94
|
+
label: t('shortcut-dialog.cancel')
|
|
95
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
96
|
+
variant: "primary",
|
|
97
|
+
label: isEditing ? t('shortcut-dialog.edit') : t('shortcut-dialog.create'),
|
|
98
|
+
onClick: saveShortcut
|
|
99
|
+
}))
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
ShortcutDialog.propTypes = {
|
|
104
|
+
/** An io.cozy.files.shortcut object if we want to prefill fields */
|
|
105
|
+
shortcut: PropTypes.object,
|
|
106
|
+
|
|
107
|
+
/** A function called when clicking the save button with filename and url */
|
|
108
|
+
onSave: PropTypes.func,
|
|
109
|
+
|
|
110
|
+
/** A function called when clicking the close button */
|
|
111
|
+
onClose: PropTypes.func
|
|
112
|
+
};
|
|
113
|
+
ShortcutDialog.displayName = 'ShortcutDialog';
|
|
114
|
+
export default withSpecificDialogsLocales(ShortcutDialog);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isValidURL(url: any): boolean;
|
|
2
|
+
export function makeValidUrl(str: any): any;
|
|
3
|
+
export function makeValidFileName(fileName: any): any;
|
|
4
|
+
export function makeHumanReadableFileName(fileName: any): any;
|
|
5
|
+
export function checkAndSaveShortcut({ fileName, url, isEditing, onSave, onClose, showAlert, t }: {
|
|
6
|
+
fileName: any;
|
|
7
|
+
url: any;
|
|
8
|
+
isEditing: any;
|
|
9
|
+
onSave: any;
|
|
10
|
+
onClose: any;
|
|
11
|
+
showAlert: any;
|
|
12
|
+
t: any;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
export var isValidURL = function isValidURL(url) {
|
|
4
|
+
try {
|
|
5
|
+
new URL(url);
|
|
6
|
+
return true;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export var makeValidUrl = function makeValidUrl(str) {
|
|
12
|
+
if (isValidURL(str)) return str;else if (isValidURL("https://".concat(str))) return "https://".concat(str);
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
export var makeValidFileName = function makeValidFileName(fileName) {
|
|
16
|
+
return fileName.endsWith('.url') ? fileName : fileName + '.url';
|
|
17
|
+
};
|
|
18
|
+
export var makeHumanReadableFileName = function makeHumanReadableFileName(fileName) {
|
|
19
|
+
return fileName.endsWith('.url') ? fileName.slice(0, -4) : fileName;
|
|
20
|
+
};
|
|
21
|
+
export var checkAndSaveShortcut = /*#__PURE__*/function () {
|
|
22
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
23
|
+
var fileName, url, isEditing, onSave, onClose, showAlert, t, validFileName, validURL;
|
|
24
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
|
+
while (1) {
|
|
26
|
+
switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
fileName = _ref.fileName, url = _ref.url, isEditing = _ref.isEditing, onSave = _ref.onSave, onClose = _ref.onClose, showAlert = _ref.showAlert, t = _ref.t;
|
|
29
|
+
|
|
30
|
+
if (!(!fileName || !url)) {
|
|
31
|
+
_context.next = 4;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
showAlert({
|
|
36
|
+
message: t('shortcut-dialog.needs-info'),
|
|
37
|
+
severity: 'error'
|
|
38
|
+
});
|
|
39
|
+
return _context.abrupt("return");
|
|
40
|
+
|
|
41
|
+
case 4:
|
|
42
|
+
validFileName = makeValidFileName(fileName);
|
|
43
|
+
validURL = makeValidUrl(url);
|
|
44
|
+
|
|
45
|
+
if (validURL) {
|
|
46
|
+
_context.next = 9;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
showAlert({
|
|
51
|
+
message: t('shortcut-dialog.url-bad-format'),
|
|
52
|
+
severity: 'error'
|
|
53
|
+
});
|
|
54
|
+
return _context.abrupt("return");
|
|
55
|
+
|
|
56
|
+
case 9:
|
|
57
|
+
try {
|
|
58
|
+
onSave(validFileName, validURL);
|
|
59
|
+
showAlert({
|
|
60
|
+
message: isEditing ? t('shortcut-dialog.edited') : t('shortcut-dialog.created'),
|
|
61
|
+
severity: 'success'
|
|
62
|
+
});
|
|
63
|
+
} catch (_unused) {
|
|
64
|
+
showAlert({
|
|
65
|
+
message: t('shortcut-dialog.errored'),
|
|
66
|
+
severity: 'error'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onClose();
|
|
71
|
+
|
|
72
|
+
case 11:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, _callee);
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
return function checkAndSaveShortcut(_x) {
|
|
81
|
+
return _ref2.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as AllowLocationDialog } from "./AllowLocationDialog";
|
|
2
2
|
export { default as InstallFlagshipAppDialog } from "./InstallFlagshipAppDialog";
|
|
3
3
|
export { default as AuthentificationDialog } from "./AuthentificationDialog";
|
|
4
|
+
export { default as ShortcutDialog } from "./ShortcutDialog";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as AllowLocationDialog } from './AllowLocationDialog';
|
|
2
2
|
export { default as InstallFlagshipAppDialog } from './InstallFlagshipAppDialog';
|
|
3
|
-
export { default as AuthentificationDialog } from './AuthentificationDialog';
|
|
3
|
+
export { default as AuthentificationDialog } from './AuthentificationDialog';
|
|
4
|
+
export { default as ShortcutDialog } from './ShortcutDialog';
|
|
@@ -23,6 +23,20 @@ var en = {
|
|
|
23
23
|
invalid_password: "Incorrect password, try again.",
|
|
24
24
|
server_error: "Something went wrong with the server. Please, reload the page."
|
|
25
25
|
}
|
|
26
|
+
},
|
|
27
|
+
"shortcut-dialog": {
|
|
28
|
+
"create-title": "Create a shortcut",
|
|
29
|
+
"edit-title": "Modify a shortcut",
|
|
30
|
+
filename: "Shortcut name",
|
|
31
|
+
url: "URL",
|
|
32
|
+
cancel: "Cancel",
|
|
33
|
+
create: "Create",
|
|
34
|
+
edit: "Edit",
|
|
35
|
+
created: "The shortcut has been created",
|
|
36
|
+
edited: "The shortcut has been modified",
|
|
37
|
+
errored: "An error occurred",
|
|
38
|
+
"needs-info": "A shortcut needs a name and a URL",
|
|
39
|
+
"url-bad-format": "The entered URL is not in the correct format"
|
|
26
40
|
}
|
|
27
41
|
};
|
|
28
42
|
var fr = {
|
|
@@ -50,6 +64,20 @@ var fr = {
|
|
|
50
64
|
invalid_password: "Mot de passe incorrect, essayer \xE0 nouveau.",
|
|
51
65
|
server_error: "Une erreur s'est produite. Merci de recharger la page."
|
|
52
66
|
}
|
|
67
|
+
},
|
|
68
|
+
"shortcut-dialog": {
|
|
69
|
+
"create-title": "Cr\xE9er un raccourci",
|
|
70
|
+
"edit-title": "Modifier un raccourci",
|
|
71
|
+
filename: "Nom du raccourci",
|
|
72
|
+
url: "URL",
|
|
73
|
+
cancel: "Annuler",
|
|
74
|
+
create: "Cr\xE9er",
|
|
75
|
+
edit: "Modifier",
|
|
76
|
+
created: "Le raccourci a \xE9t\xE9 cr\xE9\xE9",
|
|
77
|
+
edited: "Le raccourci a \xE9t\xE9 modifi\xE9",
|
|
78
|
+
errored: "Une erreur s'est produite",
|
|
79
|
+
"needs-info": "Un raccourci a besoin d'un nom et d'une URL",
|
|
80
|
+
"url-bad-format": "L'URL saisie n'est pas dans le bon format"
|
|
53
81
|
}
|
|
54
82
|
};
|
|
55
83
|
var ru = {
|
|
@@ -77,6 +105,20 @@ var ru = {
|
|
|
77
105
|
invalid_password: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043F\u0430\u0440\u043E\u043B\u044C, \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437.",
|
|
78
106
|
server_error: "\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043E\u043C. \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443."
|
|
79
107
|
}
|
|
108
|
+
},
|
|
109
|
+
"shortcut-dialog": {
|
|
110
|
+
"create-title": "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u044F\u0440\u043B\u044B\u043A",
|
|
111
|
+
"edit-title": "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u044F\u0440\u043B\u044B\u043A",
|
|
112
|
+
filename: "\u0418\u043C\u044F \u044F\u0440\u043B\u044B\u043A\u0430",
|
|
113
|
+
url: "URL",
|
|
114
|
+
cancel: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",
|
|
115
|
+
create: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C",
|
|
116
|
+
edit: "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",
|
|
117
|
+
created: "\u042F\u0440\u043B\u044B\u043A \u0431\u044B\u043B \u0441\u043E\u0437\u0434\u0430\u043D",
|
|
118
|
+
edited: "\u042F\u0440\u043B\u044B\u043A \u0431\u044B\u043B \u0438\u0437\u043C\u0435\u043D\u0435\u043D",
|
|
119
|
+
errored: "\u041F\u0440\u043E\u0438\u0437\u043E\u0448\u043B\u0430 \u043E\u0448\u0438\u0431\u043A\u0430",
|
|
120
|
+
"needs-info": "\u0414\u043B\u044F \u044F\u0440\u043B\u044B\u043A\u0430 \u043D\u0443\u0436\u043D\u044B \u0438\u043C\u044F \u0438 URL",
|
|
121
|
+
"url-bad-format": "\u0412\u0432\u0435\u0434\u0451\u043D\u043D\u044B\u0439 URL \u0438\u043C\u0435\u0435\u0442 \u043D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442"
|
|
80
122
|
}
|
|
81
123
|
};
|
|
82
124
|
var vi = {
|
|
@@ -104,6 +146,20 @@ var vi = {
|
|
|
104
146
|
invalid_password: "M\u1EADt kh\u1EA9u kh\xF4ng ch\xEDnh x\xE1c, h\xE3y th\u1EED l\u1EA1i.",
|
|
105
147
|
server_error: "C\xF3 l\u1ED7i x\u1EA3y ra v\u1EDBi m\xE1y ch\u1EE7. Vui l\xF2ng t\u1EA3i l\u1EA1i trang."
|
|
106
148
|
}
|
|
149
|
+
},
|
|
150
|
+
"shortcut-dialog": {
|
|
151
|
+
"create-title": "T\u1EA1o l\u1ED1i t\u1EAFt",
|
|
152
|
+
"edit-title": "Ch\u1EC9nh s\u1EEDa l\u1ED1i t\u1EAFt",
|
|
153
|
+
filename: "T\xEAn l\u1ED1i t\u1EAFt",
|
|
154
|
+
url: "URL",
|
|
155
|
+
cancel: "H\u1EE7y",
|
|
156
|
+
create: "T\u1EA1o",
|
|
157
|
+
edit: "Ch\u1EC9nh s\u1EEDa",
|
|
158
|
+
created: "L\u1ED1i t\u1EAFt \u0111\xE3 \u0111\u01B0\u1EE3c t\u1EA1o",
|
|
159
|
+
edited: "L\u1ED1i t\u1EAFt \u0111\xE3 \u0111\u01B0\u1EE3c ch\u1EC9nh s\u1EEDa",
|
|
160
|
+
errored: "\u0110\xE3 x\u1EA3y ra l\u1ED7i",
|
|
161
|
+
"needs-info": "L\u1ED1i t\u1EAFt c\u1EA7n c\xF3 t\xEAn v\xE0 URL",
|
|
162
|
+
"url-bad-format": "URL \u0111\xE3 nh\u1EADp kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng"
|
|
107
163
|
}
|
|
108
164
|
};
|
|
109
165
|
import withOnlyLocales from "cozy-ui/transpiled/react/providers/I18n/withOnlyLocales";
|
|
@@ -8,4 +8,4 @@ export { default as IllustrationDialog } from "./IllustrationDialog";
|
|
|
8
8
|
export { default as PermissionDialog } from "./PermissionDialog";
|
|
9
9
|
export { default as useCozyDialog } from "./useCozyDialog";
|
|
10
10
|
export { default as TopAnchoredDialog } from "./TopAnchoredDialog";
|
|
11
|
-
export { AllowLocationDialog, InstallFlagshipAppDialog, AuthentificationDialog } from "./SpecificDialogs";
|
|
11
|
+
export { AllowLocationDialog, InstallFlagshipAppDialog, AuthentificationDialog, ShortcutDialog } from "./SpecificDialogs";
|
|
@@ -8,4 +8,4 @@ export { default as IllustrationDialog } from './IllustrationDialog';
|
|
|
8
8
|
export { default as PermissionDialog } from './PermissionDialog';
|
|
9
9
|
export { default as useCozyDialog } from './useCozyDialog';
|
|
10
10
|
export { default as TopAnchoredDialog } from './TopAnchoredDialog';
|
|
11
|
-
export { AllowLocationDialog, InstallFlagshipAppDialog, AuthentificationDialog } from './SpecificDialogs';
|
|
11
|
+
export { AllowLocationDialog, InstallFlagshipAppDialog, AuthentificationDialog, ShortcutDialog } from './SpecificDialogs';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default EditMenu;
|
|
2
|
+
declare function EditMenu({ anchorRef, status, showMenu, setShowMenu, setStatus, setTimestamp, onUpload, onDelete }: {
|
|
3
|
+
anchorRef: any;
|
|
4
|
+
status: any;
|
|
5
|
+
showMenu: any;
|
|
6
|
+
setShowMenu: any;
|
|
7
|
+
setStatus: any;
|
|
8
|
+
setTimestamp: any;
|
|
9
|
+
onUpload: any;
|
|
10
|
+
onDelete: any;
|
|
11
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { handleDelete, handleUpload } from "cozy-ui/transpiled/react/EditBadge/helpers";
|
|
3
|
+
import { locales } from "cozy-ui/transpiled/react/EditBadge/locales";
|
|
4
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
5
|
+
import CameraIcon from "cozy-ui/transpiled/react/Icons/Camera";
|
|
6
|
+
import TrashIcon from "cozy-ui/transpiled/react/Icons/Trash";
|
|
7
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
8
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
9
|
+
import Menu from "cozy-ui/transpiled/react/Menu";
|
|
10
|
+
import MenuItem from "cozy-ui/transpiled/react/MenuItem";
|
|
11
|
+
import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
|
|
12
|
+
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
13
|
+
|
|
14
|
+
var EditMenu = function EditMenu(_ref) {
|
|
15
|
+
var anchorRef = _ref.anchorRef,
|
|
16
|
+
status = _ref.status,
|
|
17
|
+
showMenu = _ref.showMenu,
|
|
18
|
+
setShowMenu = _ref.setShowMenu,
|
|
19
|
+
setStatus = _ref.setStatus,
|
|
20
|
+
setTimestamp = _ref.setTimestamp,
|
|
21
|
+
onUpload = _ref.onUpload,
|
|
22
|
+
onDelete = _ref.onDelete;
|
|
23
|
+
useExtendI18n(locales);
|
|
24
|
+
|
|
25
|
+
var _useI18n = useI18n(),
|
|
26
|
+
t = _useI18n.t;
|
|
27
|
+
|
|
28
|
+
var _useAlert = useAlert(),
|
|
29
|
+
showAlert = _useAlert.showAlert;
|
|
30
|
+
|
|
31
|
+
var fileInputRef = useRef(null);
|
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
33
|
+
className: "u-dn",
|
|
34
|
+
type: "file",
|
|
35
|
+
ref: fileInputRef,
|
|
36
|
+
accept: "image/*",
|
|
37
|
+
onChange: function onChange(event) {
|
|
38
|
+
return handleUpload({
|
|
39
|
+
event: event,
|
|
40
|
+
t: t,
|
|
41
|
+
fileInputRef: fileInputRef,
|
|
42
|
+
status: status,
|
|
43
|
+
onUpload: onUpload,
|
|
44
|
+
setStatus: setStatus,
|
|
45
|
+
setTimestamp: setTimestamp,
|
|
46
|
+
setShowMenu: setShowMenu,
|
|
47
|
+
showAlert: showAlert
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}), showMenu && /*#__PURE__*/React.createElement(Menu, {
|
|
51
|
+
open: true,
|
|
52
|
+
anchorEl: anchorRef,
|
|
53
|
+
getContentAnchorEl: null,
|
|
54
|
+
anchorOrigin: {
|
|
55
|
+
vertical: 'bottom',
|
|
56
|
+
horizontal: 'left'
|
|
57
|
+
},
|
|
58
|
+
transformOrigin: {
|
|
59
|
+
vertical: 'top',
|
|
60
|
+
horizontal: 'left'
|
|
61
|
+
},
|
|
62
|
+
onClose: function onClose() {
|
|
63
|
+
return setShowMenu(false);
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
setShowMenu(false);
|
|
68
|
+
fileInputRef.current.click(); // triggers onChange of the input
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
71
|
+
icon: CameraIcon
|
|
72
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
73
|
+
primary: t('EditBadge.menu.update')
|
|
74
|
+
})), /*#__PURE__*/React.createElement(MenuItem, {
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return handleDelete({
|
|
77
|
+
t: t,
|
|
78
|
+
status: status,
|
|
79
|
+
onDelete: onDelete,
|
|
80
|
+
setShowMenu: setShowMenu,
|
|
81
|
+
setStatus: setStatus,
|
|
82
|
+
setTimestamp: setTimestamp,
|
|
83
|
+
showAlert: showAlert
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
87
|
+
icon: TrashIcon
|
|
88
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
89
|
+
primary: t('EditBadge.menu.delete')
|
|
90
|
+
}))));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default EditMenu;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default StatusWrapper;
|
|
2
|
+
declare function StatusWrapper({ src, status, setStatus, timestamp, children }: {
|
|
3
|
+
src: any;
|
|
4
|
+
status: any;
|
|
5
|
+
setStatus: any;
|
|
6
|
+
timestamp: any;
|
|
7
|
+
children: any;
|
|
8
|
+
}): JSX.Element | (React.ReactElement<any, string | React.JSXElementConstructor<any>> | null)[];
|
|
9
|
+
import React from "react";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Spinner from "cozy-ui/transpiled/react/Spinner";
|
|
4
|
+
import { AddPropsToChildren } from "cozy-ui/transpiled/react/utils/react";
|
|
5
|
+
|
|
6
|
+
var StatusWrapper = function StatusWrapper(_ref) {
|
|
7
|
+
var src = _ref.src,
|
|
8
|
+
status = _ref.status,
|
|
9
|
+
setStatus = _ref.setStatus,
|
|
10
|
+
timestamp = _ref.timestamp,
|
|
11
|
+
children = _ref.children;
|
|
12
|
+
|
|
13
|
+
if (status === 'LOADING') {
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, AddPropsToChildren(children, function (childProps) {
|
|
15
|
+
return {
|
|
16
|
+
className: cx(childProps.className, 'u-o-50')
|
|
17
|
+
};
|
|
18
|
+
}), /*#__PURE__*/React.createElement(Spinner, {
|
|
19
|
+
className: "u-m-0",
|
|
20
|
+
middle: true,
|
|
21
|
+
size: "large"
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (status === 'PRESENT') {
|
|
26
|
+
return AddPropsToChildren(children, function () {
|
|
27
|
+
return {
|
|
28
|
+
key: timestamp,
|
|
29
|
+
src: src,
|
|
30
|
+
onError: function onError() {
|
|
31
|
+
return setStatus('ABSENT');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return AddPropsToChildren(children, function () {
|
|
38
|
+
return {
|
|
39
|
+
key: timestamp
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default StatusWrapper;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function handleUpload({ event, t, fileInputRef, status, onUpload, setStatus, setTimestamp, setShowMenu, showAlert }: {
|
|
2
|
+
event: any;
|
|
3
|
+
t: any;
|
|
4
|
+
fileInputRef: any;
|
|
5
|
+
status: any;
|
|
6
|
+
onUpload: any;
|
|
7
|
+
setStatus: any;
|
|
8
|
+
setTimestamp: any;
|
|
9
|
+
setShowMenu: any;
|
|
10
|
+
showAlert: any;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export function handleDelete({ t, status, onDelete, setShowMenu, setStatus, setTimestamp, showAlert }: {
|
|
13
|
+
t: any;
|
|
14
|
+
status: any;
|
|
15
|
+
onDelete: any;
|
|
16
|
+
setShowMenu: any;
|
|
17
|
+
setStatus: any;
|
|
18
|
+
setTimestamp: any;
|
|
19
|
+
showAlert: any;
|
|
20
|
+
}): Promise<void>;
|