@micromag/media-gallery 0.3.328 → 0.3.330
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/es/index.js +30 -11
- package/lib/index.js +30 -11
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { FormattedMessage, useIntl } from 'react-intl';
|
|
|
11
11
|
import { PropTypes } from '@micromag/core';
|
|
12
12
|
import { Card, Button, Media, Spinner, UploadModal } from '@micromag/core/components';
|
|
13
13
|
import { useFieldComponent, useStory } from '@micromag/core/contexts';
|
|
14
|
-
import { useMediaUpdate, useMediasRecentSearches, useMediaTags, useMediaAuthors, useMedias, useMediaCreate } from '@micromag/data';
|
|
14
|
+
import { useMediaUpdate, useMediaDelete, useMediasRecentSearches, useMediaTags, useMediaAuthors, useMedias, useMediaCreate } from '@micromag/data';
|
|
15
15
|
import { useDimensionObserver } from '@micromag/core/hooks';
|
|
16
16
|
import { faHeadphonesAlt } from '@fortawesome/free-solid-svg-icons/faHeadphonesAlt';
|
|
17
17
|
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons/faInfoCircle';
|
|
@@ -20,7 +20,6 @@ import { faTimesCircle } from '@fortawesome/free-solid-svg-icons/faTimesCircle';
|
|
|
20
20
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
21
21
|
import uniqBy from 'lodash/uniqBy';
|
|
22
22
|
import prettyBytes from 'pretty-bytes';
|
|
23
|
-
import { useMediaDelete } from '@micromag/data/src/hooks';
|
|
24
23
|
import { faChevronLeft } from '@fortawesome/free-solid-svg-icons/faChevronLeft';
|
|
25
24
|
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
|
|
26
25
|
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
@@ -200,18 +199,21 @@ var propTypes$9 = {
|
|
|
200
199
|
media: PropTypes.media,
|
|
201
200
|
tags: PropTypes.tags,
|
|
202
201
|
onClickClose: PropTypes$1.func,
|
|
202
|
+
onClickDelete: PropTypes$1.func,
|
|
203
203
|
className: PropTypes$1.string
|
|
204
204
|
};
|
|
205
205
|
var defaultProps$9 = {
|
|
206
206
|
media: null,
|
|
207
207
|
tags: [],
|
|
208
208
|
onClickClose: null,
|
|
209
|
+
onClickDelete: null,
|
|
209
210
|
className: null
|
|
210
211
|
};
|
|
211
212
|
function MediaMetadata(_ref) {
|
|
212
213
|
var media = _ref.media,
|
|
213
214
|
allTags = _ref.tags,
|
|
214
215
|
onClickClose = _ref.onClickClose,
|
|
216
|
+
onClickDelete = _ref.onClickDelete,
|
|
215
217
|
className = _ref.className;
|
|
216
218
|
var _ref2 = media || {},
|
|
217
219
|
mediaId = _ref2.id,
|
|
@@ -315,8 +317,8 @@ function MediaMetadata(_ref) {
|
|
|
315
317
|
return deleteMedia(mediaId).then(function () {
|
|
316
318
|
setChanged(false);
|
|
317
319
|
setDeletedState(true);
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
+
if (onClickDelete !== null) {
|
|
321
|
+
onClickDelete(mediaId);
|
|
320
322
|
}
|
|
321
323
|
})["catch"](function () {
|
|
322
324
|
setDeletedState(false);
|
|
@@ -540,10 +542,10 @@ function MediaMetadata(_ref) {
|
|
|
540
542
|
})), deletedState === false ? /*#__PURE__*/React.createElement("p", {
|
|
541
543
|
className: "pt-1 text-danger"
|
|
542
544
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
543
|
-
id: "
|
|
545
|
+
id: "rqbRV2",
|
|
544
546
|
defaultMessage: [{
|
|
545
547
|
"type": 0,
|
|
546
|
-
"value": "Sorry, this media
|
|
548
|
+
"value": "Sorry, this media could not be deleted."
|
|
547
549
|
}]
|
|
548
550
|
})) : null)));
|
|
549
551
|
}
|
|
@@ -858,7 +860,8 @@ var Search = function Search(_ref) {
|
|
|
858
860
|
className: "btn",
|
|
859
861
|
onClick: onClickSearchIcon
|
|
860
862
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
861
|
-
icon: loading ? faSpinner : faSearch
|
|
863
|
+
icon: loading ? faSpinner : faSearch,
|
|
864
|
+
spin: loading
|
|
862
865
|
})), /*#__PURE__*/React.createElement("input", {
|
|
863
866
|
className: classNames([styles$7.input, 'form-control', {
|
|
864
867
|
'bg-light': !!value,
|
|
@@ -1214,7 +1217,9 @@ var propTypes$1 = {
|
|
|
1214
1217
|
selectedMedia: PropTypes.media,
|
|
1215
1218
|
storyId: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.number]),
|
|
1216
1219
|
tags: PropTypes.tags,
|
|
1217
|
-
authors: PropTypes.
|
|
1220
|
+
authors: PropTypes$1.arrayOf(PropTypes$1.shape({
|
|
1221
|
+
name: PropTypes$1.string
|
|
1222
|
+
})),
|
|
1218
1223
|
loading: PropTypes$1.bool,
|
|
1219
1224
|
withoutSource: PropTypes$1.bool,
|
|
1220
1225
|
withoutType: PropTypes$1.bool,
|
|
@@ -1546,7 +1551,7 @@ var defaultProps = {
|
|
|
1546
1551
|
onClearMedia: null
|
|
1547
1552
|
};
|
|
1548
1553
|
function MediaGallery(_ref) {
|
|
1549
|
-
var
|
|
1554
|
+
var _ref4;
|
|
1550
1555
|
var type = _ref.type,
|
|
1551
1556
|
source = _ref.source,
|
|
1552
1557
|
isPicker = _ref.isPicker,
|
|
@@ -1642,6 +1647,19 @@ function MediaGallery(_ref) {
|
|
|
1642
1647
|
setMetadataMedia(null);
|
|
1643
1648
|
refresh();
|
|
1644
1649
|
}, [refresh, setMetadataMedia]);
|
|
1650
|
+
var onMetadataClickDelete = useCallback(function () {
|
|
1651
|
+
var mediaId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1652
|
+
var _ref3 = selectedMedia || {},
|
|
1653
|
+
_ref3$id = _ref3.id,
|
|
1654
|
+
selectedId = _ref3$id === void 0 ? null : _ref3$id;
|
|
1655
|
+
if (mediaId !== null && mediaId === selectedId && onClickMedia !== null) {
|
|
1656
|
+
onClickMedia(null);
|
|
1657
|
+
} else {
|
|
1658
|
+
setMetadataMedia(null);
|
|
1659
|
+
}
|
|
1660
|
+
refresh();
|
|
1661
|
+
}, [refresh, setMetadataMedia, selectedMedia]);
|
|
1662
|
+
|
|
1645
1663
|
// console.log(loadedMedias);
|
|
1646
1664
|
// Navigation
|
|
1647
1665
|
var onClickBack = useCallback(function () {
|
|
@@ -1679,7 +1697,7 @@ function MediaGallery(_ref) {
|
|
|
1679
1697
|
return setUploadModalOpened(false);
|
|
1680
1698
|
}, [setUploadModalOpened]);
|
|
1681
1699
|
return /*#__PURE__*/React.createElement("div", {
|
|
1682
|
-
className: classNames([styles.container, (
|
|
1700
|
+
className: classNames([styles.container, (_ref4 = {}, _defineProperty(_ref4, styles.metadataOpened, metadataMedia !== null), _defineProperty(_ref4, className, className), _ref4)])
|
|
1683
1701
|
}, /*#__PURE__*/React.createElement(Navbar, {
|
|
1684
1702
|
types: isArray(type) ? type : [type],
|
|
1685
1703
|
filters: filtersValue,
|
|
@@ -1731,7 +1749,8 @@ function MediaGallery(_ref) {
|
|
|
1731
1749
|
}, /*#__PURE__*/React.createElement(MediaMetadata, {
|
|
1732
1750
|
media: metadataMedia,
|
|
1733
1751
|
tags: tags,
|
|
1734
|
-
onClickClose: onMetadataClickClose
|
|
1752
|
+
onClickClose: onMetadataClickClose,
|
|
1753
|
+
onClickDelete: onMetadataClickDelete
|
|
1735
1754
|
}))), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
|
1736
1755
|
type: type === 'video' ? videoTypes : type,
|
|
1737
1756
|
opened: uploadModalOpened,
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var faTimesCircle = require('@fortawesome/free-solid-svg-icons/faTimesCircle');
|
|
|
22
22
|
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
23
23
|
var uniqBy = require('lodash/uniqBy');
|
|
24
24
|
var prettyBytes = require('pretty-bytes');
|
|
25
|
-
var hooks$1 = require('@micromag/data/src/hooks');
|
|
26
25
|
var faChevronLeft = require('@fortawesome/free-solid-svg-icons/faChevronLeft');
|
|
27
26
|
var faPlus = require('@fortawesome/free-solid-svg-icons/faPlus');
|
|
28
27
|
var faTimes = require('@fortawesome/free-solid-svg-icons/faTimes');
|
|
@@ -216,18 +215,21 @@ var propTypes$9 = {
|
|
|
216
215
|
media: core.PropTypes.media,
|
|
217
216
|
tags: core.PropTypes.tags,
|
|
218
217
|
onClickClose: PropTypes__default["default"].func,
|
|
218
|
+
onClickDelete: PropTypes__default["default"].func,
|
|
219
219
|
className: PropTypes__default["default"].string
|
|
220
220
|
};
|
|
221
221
|
var defaultProps$9 = {
|
|
222
222
|
media: null,
|
|
223
223
|
tags: [],
|
|
224
224
|
onClickClose: null,
|
|
225
|
+
onClickDelete: null,
|
|
225
226
|
className: null
|
|
226
227
|
};
|
|
227
228
|
function MediaMetadata(_ref) {
|
|
228
229
|
var media = _ref.media,
|
|
229
230
|
allTags = _ref.tags,
|
|
230
231
|
onClickClose = _ref.onClickClose,
|
|
232
|
+
onClickDelete = _ref.onClickDelete,
|
|
231
233
|
className = _ref.className;
|
|
232
234
|
var _ref2 = media || {},
|
|
233
235
|
mediaId = _ref2.id,
|
|
@@ -259,7 +261,7 @@ function MediaMetadata(_ref) {
|
|
|
259
261
|
mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags;
|
|
260
262
|
var _useMediaUpdate = data.useMediaUpdate(),
|
|
261
263
|
update = _useMediaUpdate.update;
|
|
262
|
-
var _useMediaDelete =
|
|
264
|
+
var _useMediaDelete = data.useMediaDelete(),
|
|
263
265
|
deleteMedia = _useMediaDelete.deleteMedia;
|
|
264
266
|
var getOptionLabel = React.useCallback(function (_ref4) {
|
|
265
267
|
var name = _ref4.name;
|
|
@@ -331,8 +333,8 @@ function MediaMetadata(_ref) {
|
|
|
331
333
|
return deleteMedia(mediaId).then(function () {
|
|
332
334
|
setChanged(false);
|
|
333
335
|
setDeletedState(true);
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
+
if (onClickDelete !== null) {
|
|
337
|
+
onClickDelete(mediaId);
|
|
336
338
|
}
|
|
337
339
|
})["catch"](function () {
|
|
338
340
|
setDeletedState(false);
|
|
@@ -556,10 +558,10 @@ function MediaMetadata(_ref) {
|
|
|
556
558
|
})), deletedState === false ? /*#__PURE__*/React__default["default"].createElement("p", {
|
|
557
559
|
className: "pt-1 text-danger"
|
|
558
560
|
}, /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
559
|
-
id: "
|
|
561
|
+
id: "rqbRV2",
|
|
560
562
|
defaultMessage: [{
|
|
561
563
|
"type": 0,
|
|
562
|
-
"value": "Sorry, this media
|
|
564
|
+
"value": "Sorry, this media could not be deleted."
|
|
563
565
|
}]
|
|
564
566
|
})) : null)));
|
|
565
567
|
}
|
|
@@ -874,7 +876,8 @@ var Search = function Search(_ref) {
|
|
|
874
876
|
className: "btn",
|
|
875
877
|
onClick: onClickSearchIcon
|
|
876
878
|
}, /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
877
|
-
icon: loading ? faSpinner.faSpinner : faSearch.faSearch
|
|
879
|
+
icon: loading ? faSpinner.faSpinner : faSearch.faSearch,
|
|
880
|
+
spin: loading
|
|
878
881
|
})), /*#__PURE__*/React__default["default"].createElement("input", {
|
|
879
882
|
className: classNames__default["default"]([styles$7.input, 'form-control', {
|
|
880
883
|
'bg-light': !!value,
|
|
@@ -1230,7 +1233,9 @@ var propTypes$1 = {
|
|
|
1230
1233
|
selectedMedia: core.PropTypes.media,
|
|
1231
1234
|
storyId: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
|
|
1232
1235
|
tags: core.PropTypes.tags,
|
|
1233
|
-
authors:
|
|
1236
|
+
authors: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
|
|
1237
|
+
name: PropTypes__default["default"].string
|
|
1238
|
+
})),
|
|
1234
1239
|
loading: PropTypes__default["default"].bool,
|
|
1235
1240
|
withoutSource: PropTypes__default["default"].bool,
|
|
1236
1241
|
withoutType: PropTypes__default["default"].bool,
|
|
@@ -1562,7 +1567,7 @@ var defaultProps = {
|
|
|
1562
1567
|
onClearMedia: null
|
|
1563
1568
|
};
|
|
1564
1569
|
function MediaGallery(_ref) {
|
|
1565
|
-
var
|
|
1570
|
+
var _ref4;
|
|
1566
1571
|
var type = _ref.type,
|
|
1567
1572
|
source = _ref.source,
|
|
1568
1573
|
isPicker = _ref.isPicker,
|
|
@@ -1658,6 +1663,19 @@ function MediaGallery(_ref) {
|
|
|
1658
1663
|
setMetadataMedia(null);
|
|
1659
1664
|
refresh();
|
|
1660
1665
|
}, [refresh, setMetadataMedia]);
|
|
1666
|
+
var onMetadataClickDelete = React.useCallback(function () {
|
|
1667
|
+
var mediaId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1668
|
+
var _ref3 = selectedMedia || {},
|
|
1669
|
+
_ref3$id = _ref3.id,
|
|
1670
|
+
selectedId = _ref3$id === void 0 ? null : _ref3$id;
|
|
1671
|
+
if (mediaId !== null && mediaId === selectedId && onClickMedia !== null) {
|
|
1672
|
+
onClickMedia(null);
|
|
1673
|
+
} else {
|
|
1674
|
+
setMetadataMedia(null);
|
|
1675
|
+
}
|
|
1676
|
+
refresh();
|
|
1677
|
+
}, [refresh, setMetadataMedia, selectedMedia]);
|
|
1678
|
+
|
|
1661
1679
|
// console.log(loadedMedias);
|
|
1662
1680
|
// Navigation
|
|
1663
1681
|
var onClickBack = React.useCallback(function () {
|
|
@@ -1695,7 +1713,7 @@ function MediaGallery(_ref) {
|
|
|
1695
1713
|
return setUploadModalOpened(false);
|
|
1696
1714
|
}, [setUploadModalOpened]);
|
|
1697
1715
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1698
|
-
className: classNames__default["default"]([styles.container, (
|
|
1716
|
+
className: classNames__default["default"]([styles.container, (_ref4 = {}, _defineProperty__default["default"](_ref4, styles.metadataOpened, metadataMedia !== null), _defineProperty__default["default"](_ref4, className, className), _ref4)])
|
|
1699
1717
|
}, /*#__PURE__*/React__default["default"].createElement(Navbar, {
|
|
1700
1718
|
types: isArray__default["default"](type) ? type : [type],
|
|
1701
1719
|
filters: filtersValue,
|
|
@@ -1747,7 +1765,8 @@ function MediaGallery(_ref) {
|
|
|
1747
1765
|
}, /*#__PURE__*/React__default["default"].createElement(MediaMetadata, {
|
|
1748
1766
|
media: metadataMedia,
|
|
1749
1767
|
tags: tags,
|
|
1750
|
-
onClickClose: onMetadataClickClose
|
|
1768
|
+
onClickClose: onMetadataClickClose,
|
|
1769
|
+
onClickDelete: onMetadataClickDelete
|
|
1751
1770
|
}))), /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(components.UploadModal, {
|
|
1752
1771
|
type: type === 'video' ? videoTypes : type,
|
|
1753
1772
|
opened: uploadModalOpened,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.330",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
60
60
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
61
61
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
62
|
-
"@micromag/core": "^0.3.
|
|
63
|
-
"@micromag/data": "^0.3.
|
|
62
|
+
"@micromag/core": "^0.3.329",
|
|
63
|
+
"@micromag/data": "^0.3.329",
|
|
64
64
|
"bootstrap": "5.2.0-beta1",
|
|
65
65
|
"change-case": "^4.1.2",
|
|
66
66
|
"classnames": "^2.2.6",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "4ee3638ac45e97004ea24ddefa27e3b1f369efc9"
|
|
77
77
|
}
|