@scaleflex/widget-explorer 4.0.6 → 4.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +12111 -12075
  2. package/LICENSE +21 -21
  3. package/README.md +1260 -1235
  4. package/dist/style.css +1438 -1094
  5. package/dist/style.min.css +1 -1
  6. package/lib/components/AssetsList/SearchView.hook.js +24 -24
  7. package/lib/components/AssetsList/__SearchTestPannel.js +27 -27
  8. package/lib/components/BulkEditPanel/components/AssetsList/Columns/columns.utils.js +2 -2
  9. package/lib/components/CropPanel/index.scss +55 -55
  10. package/lib/components/Details/Details.constants.js +5 -0
  11. package/lib/components/Details/FileItem/style.scss +11 -11
  12. package/lib/components/Details/TabChips.js +10 -5
  13. package/lib/components/Drawer/ResizerCore.js +3 -3
  14. package/lib/components/FileItem/PreUploadFileThumbnail/index.scss +19 -19
  15. package/lib/components/FileWindowPanel/FileTabs/GeneralTab/GeneralSection.js +1 -1
  16. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/Variations.constants.js +7 -3
  17. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/Variations.styled.js +4 -2
  18. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/Variations.thunks.js +45 -0
  19. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsContent.js +15 -1
  20. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsTabs.js +11 -3
  21. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsTopOptions.js +4 -4
  22. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/index.js +194 -27
  23. package/lib/components/FileWindowPanel/Header/BeforeUploadActionBtns.js +4 -4
  24. package/lib/components/GalleryRoleSelect/GalleryRoleSelect.utils.js +3 -3
  25. package/lib/components/GalleryRoleSelect/index.js +11 -11
  26. package/lib/components/Modals/TransformedDownload/TransformedDownload.hooks.js +11 -11
  27. package/lib/components/Modals/TransformedDownload/TransformedDownload.utils.js +4 -4
  28. package/lib/components/TopBar/index.scss +20 -20
  29. package/lib/components/UrlBuilderModal/index.js +6 -2
  30. package/lib/components/common/FileMetadataFieldValue/FileMetadataFieldValue.utils.js +12 -8
  31. package/lib/components/metadata.adapter.js +18 -18
  32. package/lib/defaultLocale.js +7 -1
  33. package/lib/hooks/useEditFileDetails.js +5 -5
  34. package/lib/hooks/useFileMetadata.js +5 -3
  35. package/lib/hooks/useIsSmallScreen.js +6 -6
  36. package/lib/hooks/useValidateFileName.js +22 -22
  37. package/lib/index.js +154 -151
  38. package/lib/slices/files.slice.js +15 -15
  39. package/lib/slices/folders.slice.js +9 -9
  40. package/lib/slices/metadata.slice.js +9 -2
  41. package/lib/style.scss +268 -268
  42. package/lib/utils/SearchSuggestions/SearchSuggestionsMenu.js +4 -4
  43. package/lib/utils/createSuperFocus.js +5 -5
  44. package/lib/utils/filters.js +3 -3
  45. package/lib/utils/formatPinSubTitle.js +6 -6
  46. package/lib/utils/getActiveOverlayEl.js +2 -2
  47. package/lib/utils/truncateString.js +7 -7
  48. package/package.json +8 -8
  49. package/types/index.d.ts +102 -102
@@ -8,12 +8,16 @@ var VARIATIONS_TAB_IDS = {
8
8
  };
9
9
  var VARIATIONS_TAB = _defineProperty(_defineProperty({}, VARIATIONS_TAB_IDS.MANUAL, {
10
10
  id: VARIATIONS_TAB_IDS.MANUAL,
11
- i18nKey: 'explorerFileWindowVariationsManualTabLabel'
11
+ i18nKey: 'explorerFileWindowVariationsManualTabLabel',
12
+ hide: function hide(_ref) {
13
+ var variationsHideManualSubTab = _ref.variationsHideManualSubTab;
14
+ return variationsHideManualSubTab;
15
+ }
12
16
  }), VARIATIONS_TAB_IDS.AUTOMATIC, {
13
17
  id: VARIATIONS_TAB_IDS.AUTOMATIC,
14
18
  i18nKey: 'explorerFileWindowVariationsAutomaticTabLabel',
15
- disabled: function disabled(_ref) {
16
- var presetsVariants = _ref.presetsVariants;
19
+ disabled: function disabled(_ref2) {
20
+ var presetsVariants = _ref2.presetsVariants;
17
21
  return (presetsVariants === null || presetsVariants === void 0 ? void 0 : presetsVariants.length) === 0;
18
22
  }
19
23
  });
@@ -1,4 +1,4 @@
1
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30;
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31;
2
2
  function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
3
  import styled, { css } from 'styled-components';
4
4
  import { StatusLabel, Search, Skeleton, Tabs as SfxTabs, Tab as SfxTab } from '@scaleflex/ui/core';
@@ -142,6 +142,7 @@ var Tab = styled(SfxTab)(_templateObject29 || (_templateObject29 = _taggedTempla
142
142
  return theme.typography.font[FV.LabelLarge];
143
143
  });
144
144
  var EditModalContent = styled.div(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 16px;\n"])));
145
+ var PresetInputsWrapper = styled.div(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 16px;\n width: 100%;\n"])));
145
146
  var Styled = {
146
147
  Actions: Actions,
147
148
  Title: Title,
@@ -170,6 +171,7 @@ var Styled = {
170
171
  SkeletonItemWrapper: SkeletonItemWrapper,
171
172
  Tabs: Tabs,
172
173
  Tab: Tab,
173
- EditModalContent: EditModalContent
174
+ EditModalContent: EditModalContent,
175
+ PresetInputsWrapper: PresetInputsWrapper
174
176
  };
175
177
  export default Styled;
@@ -1,5 +1,18 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
6
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
7
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
13
  import createThunk from '@scaleflex/widget-utils/lib/createThunk';
2
14
  import { PERMISSIONS } from '@scaleflex/widget-utils/lib/constants';
15
+ import { presetsUpdated, selectPresets } from '../../../../slices/metadata.slice';
3
16
  export var getVariants = createThunk(async function (fileUuid, thunkApi) {
4
17
  var _await$thunkApi$extra = await thunkApi.extra.apiClient.get("file/".concat(fileUuid, "/variants"), {
5
18
  id: 'fileVariants',
@@ -51,4 +64,36 @@ export var deleteVariant = createThunk(async function (_ref3, thunkApi) {
51
64
  abortSignal: thunkApi.signal
52
65
  });
53
66
  return response;
67
+ });
68
+ export var addNewPreset = createThunk(async function () {
69
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
70
+ newPreset = _ref4.newPreset;
71
+ var thunkApi = arguments.length > 1 ? arguments[1] : undefined;
72
+ var _ref5 = thunkApi.extra.filerobot || {},
73
+ projectUuid = _ref5.opts.projectUuid;
74
+ var currentPresets = selectPresets(thunkApi.getState()).map(function (preset) {
75
+ return _objectSpread(_objectSpread({}, preset), {}, {
76
+ desc: preset.desc || '',
77
+ params: preset.params || {},
78
+ sampleImgSrc: preset.sampleImgSrc || ''
79
+ });
80
+ }) || [];
81
+ var newPresetsData = [].concat(_toConsumableArray(currentPresets), [newPreset]);
82
+ var _await$thunkApi$extra7 = await thunkApi.extra.apiClient.putAdmin("project/".concat(projectUuid, "/data-diff"), {
83
+ data: {
84
+ 'cloudimg/presets': newPresetsData
85
+ },
86
+ id: 'filePresets',
87
+ abortSignal: thunkApi.signal
88
+ }),
89
+ data = _await$thunkApi$extra7.data_input;
90
+ var newPresets = data === null || data === void 0 ? void 0 : data['cloudimg/presets'];
91
+ if (newPresets) {
92
+ thunkApi.dispatch(presetsUpdated({
93
+ presets: newPresets
94
+ }));
95
+ } else {
96
+ return thunkApi.rejectWithValue('Failed to add new preset');
97
+ }
98
+ return newPresets;
54
99
  });
@@ -11,6 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  var VariationsContent = function VariationsContent(_ref) {
12
12
  var originalFile = _ref.originalFile,
13
13
  addNewVariant = _ref.addNewVariant,
14
+ addNewPreset = _ref.addNewPreset,
14
15
  isLoading = _ref.isLoading,
15
16
  variants = _ref.variants,
16
17
  searchQuery = _ref.searchQuery,
@@ -21,7 +22,8 @@ var VariationsContent = function VariationsContent(_ref) {
21
22
  editVariantName = _ref.editVariantName,
22
23
  setSelectedVariant = _ref.setSelectedVariant,
23
24
  i18n = _ref.i18n,
24
- activeTabId = _ref.activeTabId;
25
+ activeTabId = _ref.activeTabId,
26
+ showAddPresetButton = _ref.showAddPresetButton;
25
27
  var dispatch = useDispatch();
26
28
  var hasUserVariantEditPermission = useSelector(function (state) {
27
29
  return selectIsUserPermittedTo(state, PERMISSIONS.FILE_IMAGE_EDITOR);
@@ -29,6 +31,7 @@ var VariationsContent = function VariationsContent(_ref) {
29
31
  var isUserAuth = useSelector(selectIsUserAuth);
30
32
  var isUserPermittedToEditVariant = isUserAuth && hasUserVariantEditPermission;
31
33
  var showAddVariantButton = isUserPermittedToEditVariant && activeTabId === VARIATIONS_TAB_IDS.MANUAL;
34
+ var isShowAddPresetButton = showAddPresetButton && isUserPermittedToEditVariant && activeTabId === VARIATIONS_TAB_IDS.AUTOMATIC;
32
35
  var onSelectVariant = function onSelectVariant(variant) {
33
36
  setSelectedVariant(variant);
34
37
  dispatch(filesVariationsUpdated(variant));
@@ -56,6 +59,17 @@ var VariationsContent = function VariationsContent(_ref) {
56
59
  size: 14
57
60
  }), i18n('explorerFileWindowAddVariationButton')]
58
61
  })]
62
+ }), isShowAddPresetButton && /*#__PURE__*/_jsxs(StyledVariants.AddVariantBtn, {
63
+ onClick: addNewPreset,
64
+ "data-testid": "add-preset-button",
65
+ children: [/*#__PURE__*/_jsx(VariantPlaceholder, {
66
+ size: 115,
67
+ height: 58
68
+ }), /*#__PURE__*/_jsxs(StyledVariants.AddVariantBtnLabel, {
69
+ children: [/*#__PURE__*/_jsx(PlusOutline, {
70
+ size: 14
71
+ }), i18n('explorerFileWindowAddPresetButton')]
72
+ })]
59
73
  }), variants.map(function (variant) {
60
74
  return /*#__PURE__*/_jsx(VariationItem, {
61
75
  variant: variant,
@@ -1,5 +1,6 @@
1
1
  import StyledVariants from './Variations.styled';
2
2
  import { VARIATIONS_TABS } from './Variations.constants';
3
+ import { useExplorer } from '../../../../hooks';
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  var VariationsTabs = function VariationsTabs(_ref) {
5
6
  var i18n = _ref.i18n,
@@ -9,6 +10,10 @@ var VariationsTabs = function VariationsTabs(_ref) {
9
10
  _ref$isLoading = _ref.isLoading,
10
11
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
11
12
  presetsVariants = _ref.presetsVariants;
13
+ var _useExplorer = useExplorer(),
14
+ _useExplorer$opts = _useExplorer.opts,
15
+ _useExplorer$opts2 = _useExplorer$opts === void 0 ? {} : _useExplorer$opts,
16
+ variationsHideManualSubTab = _useExplorer$opts2.variationsHideManualSubTab;
12
17
  return /*#__PURE__*/_jsx(StyledVariants.Tabs, {
13
18
  onChange: handleChangeTab,
14
19
  value: activeTabId,
@@ -16,8 +21,11 @@ var VariationsTabs = function VariationsTabs(_ref) {
16
21
  children: VARIATIONS_TABS.map(function (_ref2) {
17
22
  var i18nKey = _ref2.i18nKey,
18
23
  id = _ref2.id,
19
- disabled = _ref2.disabled;
20
- return /*#__PURE__*/_jsx(StyledVariants.Tab, {
24
+ disabled = _ref2.disabled,
25
+ hide = _ref2.hide;
26
+ return !(hide !== null && hide !== void 0 && hide({
27
+ variationsHideManualSubTab: variationsHideManualSubTab
28
+ })) && /*#__PURE__*/_jsx(StyledVariants.Tab, {
21
29
  size: "lg",
22
30
  label: i18n(i18nKey),
23
31
  value: id,
@@ -26,7 +34,7 @@ var VariationsTabs = function VariationsTabs(_ref) {
26
34
  presetsVariants: presetsVariants
27
35
  }))
28
36
  }, id);
29
- })
37
+ }).filter(Boolean)
30
38
  });
31
39
  };
32
40
  export default VariationsTabs;
@@ -63,10 +63,10 @@ var VariationsTopOptions = function VariationsTopOptions(_ref) {
63
63
  }
64
64
  var variantName = variant.name;
65
65
  var variantUrl = getFileLink(variant, 'cdn');
66
- /*
67
- * TODO: Check the following in-case BE supports it,
68
- * Disabled download as zip due to this task: https://scaleflexhq.atlassian.net/browse/FRA-7213
69
- * To re-enabled Remove dismissUsageRights: true.
66
+ /*
67
+ * TODO: Check the following in-case BE supports it,
68
+ * Disabled download as zip due to this task: https://scaleflexhq.atlassian.net/browse/FRA-7213
69
+ * To re-enabled Remove dismissUsageRights: true.
70
70
  */
71
71
 
72
72
  var downloadParams = _objectSpread({
@@ -1,4 +1,5 @@
1
- var _excluded = ["variantUrl", "name"];
1
+ var _excluded = ["variantUrl", "name", "desc"],
2
+ _excluded2 = ["variantUrl", "name"];
2
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -17,11 +18,11 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
17
18
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
19
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
20
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
20
- import { useState, useEffect, useMemo } from 'react';
21
+ import { useState, useEffect, useMemo, useRef } from 'react';
21
22
  import { useDispatch, useSelector } from 'react-redux';
22
23
  import { Button, InputGroup } from '@scaleflex/ui/core';
23
24
  import { PC } from '@scaleflex/widget-common';
24
- import { Download, Lock, Rename } from '@scaleflex/icons';
25
+ import { Download, Lock, Preset, Rename } from '@scaleflex/icons';
25
26
  import { useTheme } from '@scaleflex/ui/theme/hooks';
26
27
  import handlePromise from '@scaleflex/widget-utils/lib/handlePromise';
27
28
  import getFileNameAndExtension from '@scaleflex/widget-utils/lib/getFileNameAndExtension';
@@ -34,7 +35,7 @@ import { useExplorer } from '../../../../hooks';
34
35
  import StyledVariants from './Variations.styled';
35
36
  import VariationsSearch from './VariationsSearch';
36
37
  import { createRemovedBackgroundVariantObject } from './Variations.utils';
37
- import { addNewVariant, deleteVariant, editVariant, getVariants } from './Variations.thunks';
38
+ import { addNewVariant, deleteVariant, editVariant, getVariants, addNewPreset } from './Variations.thunks';
38
39
  import { fetchFileByUuid, filesVariationsUpdated, fileUpdated, selectFilesVariations } from '../../../../slices/files.slice';
39
40
  import { useTransformedDownloadModal } from '../../../Modals/TransformedDownload';
40
41
  import VariationsContent from './VariationsContent';
@@ -50,6 +51,10 @@ var _isUnMounting = false;
50
51
  var extractVariantQuery = function extractVariantQuery(variantUrl) {
51
52
  return variantUrl.substr(variantUrl.indexOf('?') + 1);
52
53
  };
54
+ var URL_BUILDER_OPENED_AS_MODE = {
55
+ PRESET: 'preset',
56
+ VARIANT: 'variant'
57
+ };
53
58
  var VariationsTab = function VariationsTab(_ref) {
54
59
  var originalFile = _ref.originalFile,
55
60
  previewedFile = _ref.previewedFile,
@@ -62,7 +67,10 @@ var VariationsTab = function VariationsTab(_ref) {
62
67
  var _useExplorer = useExplorer(),
63
68
  i18n = _useExplorer.i18n,
64
69
  info = _useExplorer.info,
65
- hideDownloadVariationsOption = _useExplorer.opts.hideDownloadVariationsOption;
70
+ _useExplorer$opts = _useExplorer.opts,
71
+ hideDownloadVariationsOption = _useExplorer$opts.hideDownloadVariationsOption,
72
+ variationsShowAddPresetButton = _useExplorer$opts.variationsShowAddPresetButton,
73
+ variationsHideManualSubTab = _useExplorer$opts.variationsHideManualSubTab;
66
74
  var triggerTransformedDownloadModal = useTransformedDownloadModal();
67
75
  var displayedFileVariant = useSelector(selectFilesVariations);
68
76
  var presets = useSelector(selectPresets);
@@ -90,6 +98,7 @@ var VariationsTab = function VariationsTab(_ref) {
90
98
  _useState12 = _slicedToArray(_useState11, 2),
91
99
  selectedVariant = _useState12[0],
92
100
  setSelectedVariant = _useState12[1];
101
+ var urlBuilderSaveModeRef = useRef(URL_BUILDER_OPENED_AS_MODE.VARIANT);
93
102
  var url = getFileLink(originalFile, 'cdn');
94
103
  var isAutomaticTabActive = activeVariationsTabId === VARIATIONS_TAB_IDS.AUTOMATIC;
95
104
  var customVariants = useMemo(function () {
@@ -125,7 +134,7 @@ var VariationsTab = function VariationsTab(_ref) {
125
134
  return variant.name.toLowerCase().includes(loweredCaseValue);
126
135
  });
127
136
  }, [searchQuery, originalVariants, nextVariants]);
128
- var triggerVariantRequest = function triggerVariantRequest(requestPromise, successFn) {
137
+ var triggerSaveRequest = function triggerSaveRequest(requestPromise, successFn) {
129
138
  setIsLoading(true);
130
139
  return handlePromise(requestPromise, function () {
131
140
  if (_isUnMounting) {
@@ -139,15 +148,53 @@ var VariationsTab = function VariationsTab(_ref) {
139
148
  setIsLoading(false);
140
149
  });
141
150
  };
142
- var handleSavingNewVariant = function handleSavingNewVariant(_ref2) {
151
+ var handleSavingNewPreset = function handleSavingNewPreset(_ref2) {
143
152
  var variantUrl = _ref2.variantUrl,
144
153
  name = _ref2.name,
154
+ desc = _ref2.desc,
145
155
  moreProps = _objectWithoutProperties(_ref2, _excluded);
146
156
  var _ref3 = moreProps || {},
147
157
  onClose = _ref3.onClose;
148
158
  if (isFunction(onClose)) {
149
159
  onClose();
150
160
  }
161
+ info(i18n('explorerFileWindowVariationSavedInfo', 3000));
162
+ var newPreset = {
163
+ name: name,
164
+ desc: desc,
165
+ params: extractVariantQuery(variantUrl).split('&').reduce(function (acc, curr) {
166
+ var _curr$split = curr.split('='),
167
+ _curr$split2 = _slicedToArray(_curr$split, 2),
168
+ key = _curr$split2[0],
169
+ value = _curr$split2[1];
170
+ acc[key] = value;
171
+ return acc;
172
+ }, {}),
173
+ sampleImgSrc: url
174
+ };
175
+ triggerSaveRequest(dispatch(addNewPreset({
176
+ preset: newPreset
177
+ })), function (_) {
178
+ info(i18n('explorerFileWindowPresetAddedInfo'), 'success');
179
+ setShowUrlBuilderModal(false);
180
+ }, setIsLoading);
181
+ };
182
+ var handleUrlBuilderNewSave = function handleUrlBuilderNewSave() {
183
+ if (urlBuilderSaveModeRef.current === URL_BUILDER_OPENED_AS_MODE.PRESET) {
184
+ triggerAddPresetModal.apply(void 0, arguments);
185
+ return;
186
+ }
187
+ triggerAddVariantModal.apply(void 0, arguments);
188
+ };
189
+ var handleSavingNewVariant = function handleSavingNewVariant(_ref4) {
190
+ var variantUrl = _ref4.variantUrl,
191
+ name = _ref4.name,
192
+ moreProps = _objectWithoutProperties(_ref4, _excluded2);
193
+ var _ref5 = moreProps || {},
194
+ onClose = _ref5.onClose;
195
+ if (isFunction(onClose)) {
196
+ onClose();
197
+ }
151
198
  var _getFileNameAndExtens = getFileNameAndExtension(originalFile.name, originalFile.type),
152
199
  extension = _getFileNameAndExtens.extension;
153
200
  info(i18n('explorerFileWindowVariationSavedInfo', 3000));
@@ -157,7 +204,7 @@ var VariationsTab = function VariationsTab(_ref) {
157
204
  query: extractVariantQuery(variantUrl),
158
205
  extension: extension
159
206
  };
160
- triggerVariantRequest(dispatch(addNewVariant({
207
+ triggerSaveRequest(dispatch(addNewVariant({
161
208
  fileUuid: originalFile.uuid,
162
209
  data: newVariantData
163
210
  })), function (newVariant) {
@@ -167,11 +214,119 @@ var VariationsTab = function VariationsTab(_ref) {
167
214
  setOriginalVariants([].concat(_toConsumableArray(originalVariants), [newVariant]));
168
215
  }, setIsLoading);
169
216
  };
217
+ var triggerAddPresetModal = function triggerAddPresetModal(variantUrl, moreProps) {
218
+ var tmpData = {
219
+ name: '',
220
+ desc: '',
221
+ error: ''
222
+ };
223
+ var updateName = function updateName(e, setPrimaryButtonDisabled, updateData) {
224
+ var newName = e.target.value;
225
+ var isExistingName = presets.find(function (preset) {
226
+ var _preset$name;
227
+ return ((_preset$name = preset.name) === null || _preset$name === void 0 ? void 0 : _preset$name.toLowerCase()) === (newName === null || newName === void 0 ? void 0 : newName.toLowerCase());
228
+ });
229
+ tmpData.name = newName;
230
+ if (!newName) {
231
+ tmpData.error = i18n('mutualizedFieldRequired');
232
+ } else if (isExistingName) {
233
+ tmpData.error = i18n('explorerFileWindowVariationsNameExistsError');
234
+ } else if (/[{}|\\^~@`,\s]/.test(newName)) {
235
+ tmpData.error = i18n('explorerFileWindowAddPresetNameRegexError');
236
+ } else {
237
+ tmpData.error = '';
238
+ }
239
+ setPrimaryButtonDisabled(Boolean(tmpData.error) || !newName || isExistingName);
240
+ updateData(_objectSpread({}, tmpData));
241
+ };
242
+ var updateDescription = function updateDescription(e, updateData) {
243
+ var newDesc = e.target.value;
244
+ tmpData.desc = newDesc;
245
+ updateData(_objectSpread({}, tmpData));
246
+ };
247
+ var presetNameInputId = 'filerobotPresetNameModalInput';
248
+ toggleModal({
249
+ icon: /*#__PURE__*/_jsx(Preset, {
250
+ size: 29,
251
+ color: theme.palette[PC.AccentPrimary]
252
+ }),
253
+ showTitleLabel: true,
254
+ title: i18n('explorerFileWindowAddPresetTitle'),
255
+ content: function content(_ref6) {
256
+ var updateData = _ref6.updateData,
257
+ data = _ref6.data,
258
+ setPrimaryButtonDisabled = _ref6.setPrimaryButtonDisabled;
259
+ return /*#__PURE__*/_jsxs(StyledVariants.PresetInputsWrapper, {
260
+ children: [/*#__PURE__*/_jsx(InputGroup, {
261
+ onChange: function onChange(e) {
262
+ return updateName(e, setPrimaryButtonDisabled, updateData);
263
+ },
264
+ error: Boolean(data.error),
265
+ hint: data.error,
266
+ label: "".concat(i18n('mutualizedNameFieldLabel'), " *"),
267
+ placeholder: i18n('explorerFileWindowAddPresetNamePlaceholder'),
268
+ value: tmpData.name || data.name || '',
269
+ InputProps: {
270
+ fullWidth: true
271
+ },
272
+ fullWidth: true,
273
+ focusOnMount: true
274
+ }), /*#__PURE__*/_jsx(InputGroup, {
275
+ type: "textarea",
276
+ onChange: function onChange(e) {
277
+ return updateDescription(e, updateData);
278
+ },
279
+ label: i18n('explorerFileWindowAddPresetDescLabel'),
280
+ placeholder: i18n('explorerFileWindowAddPresetDescPlaceholder'),
281
+ value: tmpData.desc || data.desc || '',
282
+ fullWidth: true
283
+ })]
284
+ });
285
+ },
286
+ onButtonPrimaryClick: function onButtonPrimaryClick() {
287
+ return handleSavingNewPreset(_objectSpread(_objectSpread({
288
+ variantUrl: variantUrl
289
+ }, tmpData), moreProps));
290
+ },
291
+ inputToFocus: presetNameInputId,
292
+ enterKeySubmits: true,
293
+ disablePrimaryButton: true,
294
+ modalStyle: {
295
+ width: 450,
296
+ maxWidth: 'none'
297
+ },
298
+ rootModalStyles: {
299
+ zIndex: 1500
300
+ },
301
+ modalBodyStyle: {
302
+ textAlign: 'center',
303
+ padding: '12px 32px'
304
+ },
305
+ modalFooterStyle: {
306
+ flexDirection: 'row',
307
+ padding: '12px 32px 32px 32px'
308
+ },
309
+ primaryTitleStyle: {
310
+ textAlign: 'center'
311
+ },
312
+ modalSecondaryButtonColor: 'basic',
313
+ contentStyle: {
314
+ textAlign: 'center'
315
+ },
316
+ modalPrimaryButton: {
317
+ width: 187
318
+ },
319
+ modalSecondaryButton: {
320
+ width: 187
321
+ },
322
+ inlineActionButtons: true
323
+ });
324
+ };
170
325
  var triggerAddVariantModal = function triggerAddVariantModal(variantUrl) {
171
326
  var moreProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
172
- var _ref4 = moreProps || {},
173
- ratioGroupKey = _ref4.ratioGroupKey,
174
- ratioTitleKey = _ref4.ratioTitleKey;
327
+ var _ref7 = moreProps || {},
328
+ ratioGroupKey = _ref7.ratioGroupKey,
329
+ ratioTitleKey = _ref7.ratioTitleKey;
175
330
  var name = '';
176
331
  if (ratioGroupKey && ratioTitleKey) {
177
332
  name = "".concat(i18n(ratioGroupKey) || ratioGroupKey, " - ").concat(i18n(ratioTitleKey) || ratioTitleKey);
@@ -206,10 +361,10 @@ var VariationsTab = function VariationsTab(_ref) {
206
361
  }),
207
362
  showTitleLabel: true,
208
363
  title: i18n('explorerFileWindowAddVariationTitle'),
209
- content: function content(_ref5) {
210
- var updateData = _ref5.updateData,
211
- data = _ref5.data,
212
- setPrimaryButtonDisabled = _ref5.setPrimaryButtonDisabled;
364
+ content: function content(_ref8) {
365
+ var updateData = _ref8.updateData,
366
+ data = _ref8.data,
367
+ setPrimaryButtonDisabled = _ref8.setPrimaryButtonDisabled;
213
368
  return /*#__PURE__*/_jsx(InputGroup, {
214
369
  onChange: function onChange(e) {
215
370
  return updateName(e, setPrimaryButtonDisabled, updateData);
@@ -265,14 +420,20 @@ var VariationsTab = function VariationsTab(_ref) {
265
420
  if (originalFile.uuid !== previewedFile.uuid) {
266
421
  return;
267
422
  }
423
+ urlBuilderSaveModeRef.current = URL_BUILDER_OPENED_AS_MODE.VARIANT;
424
+ setQueryString('');
425
+ setShowUrlBuilderModal(true);
426
+ };
427
+ var triggerAddNewPresetModal = function triggerAddNewPresetModal() {
428
+ urlBuilderSaveModeRef.current = URL_BUILDER_OPENED_AS_MODE.PRESET;
268
429
  setQueryString('');
269
430
  setShowUrlBuilderModal(true);
270
431
  };
271
432
  var downloadAllVariants = function downloadAllVariants() {
272
433
  var variantsWithExtensions = searchedVariants.map(function (variant) {
273
- var _ref6, _variant$info, _variant$info2;
434
+ var _ref9, _variant$info, _variant$info2;
274
435
  return _objectSpread(_objectSpread({}, variant), {}, {
275
- extension: variant.bgRemoved ? 'png' : getFileNameAndExtension(variant.name).extension || ((_ref6 = ((_variant$info = variant.info) === null || _variant$info === void 0 ? void 0 : _variant$info.ext) || ((_variant$info2 = variant.info) === null || _variant$info2 === void 0 ? void 0 : _variant$info2.img_type)) === null || _ref6 === void 0 ? void 0 : _ref6.toLowerCase())
436
+ extension: variant.bgRemoved ? 'png' : getFileNameAndExtension(variant.name).extension || ((_ref9 = ((_variant$info = variant.info) === null || _variant$info === void 0 ? void 0 : _variant$info.ext) || ((_variant$info2 = variant.info) === null || _variant$info2 === void 0 ? void 0 : _variant$info2.img_type)) === null || _ref9 === void 0 ? void 0 : _ref9.toLowerCase())
276
437
  });
277
438
  });
278
439
  triggerTransformedDownloadModal(variantsWithExtensions, {
@@ -282,7 +443,7 @@ var VariationsTab = function VariationsTab(_ref) {
282
443
  };
283
444
  var submitVariantEdit = function submitVariantEdit(data) {
284
445
  toggleModal(null);
285
- triggerVariantRequest(dispatch(editVariant({
446
+ triggerSaveRequest(dispatch(editVariant({
286
447
  fileUuid: originalFile.uuid,
287
448
  data: data
288
449
  })), function (updatedVariant) {
@@ -306,7 +467,7 @@ var VariationsTab = function VariationsTab(_ref) {
306
467
  info(i18n('variantDeleteOriginalError'));
307
468
  return;
308
469
  }
309
- triggerVariantRequest(dispatch(deleteVariant({
470
+ triggerSaveRequest(dispatch(deleteVariant({
310
471
  fileUuid: originalFile.uuid,
311
472
  variantUuid: variantUuid
312
473
  })), function (_) {
@@ -320,8 +481,8 @@ var VariationsTab = function VariationsTab(_ref) {
320
481
  useEffect(function () {
321
482
  _isUnMounting = false;
322
483
  var mainFile = previewedFile || displayedFileVariant || originalFile;
323
- if (previewedFile.uuid) {
324
- triggerVariantRequest(dispatch(getVariants(previewedFile.uuid)), function (loadedVariants) {
484
+ if (previewedFile.uuid && !variationsHideManualSubTab) {
485
+ triggerSaveRequest(dispatch(getVariants(previewedFile.uuid)), function (loadedVariants) {
325
486
  var mainVariants = [mainFile];
326
487
  if (mainFile.info.remove_background) {
327
488
  mainVariants.push(createRemovedBackgroundVariantObject(mainFile));
@@ -329,9 +490,11 @@ var VariationsTab = function VariationsTab(_ref) {
329
490
  setOriginalVariants([].concat(mainVariants, _toConsumableArray(loadedVariants)));
330
491
  dispatch(filesVariationsUpdated(mainVariants[0]));
331
492
  }, setIsLoading);
493
+ } else {
494
+ setIsLoading(false);
332
495
  }
333
496
  if (mainFile.removedBackground && !mainFile.info.remove_background) {
334
- triggerVariantRequest(dispatch(fetchFileByUuid(originalFile.uuid)), function (updatedFile) {
497
+ triggerSaveRequest(dispatch(fetchFileByUuid(originalFile.uuid)), function (updatedFile) {
335
498
  var originalVariantsWithRemovedBg = [mainFile];
336
499
  if (updatedFile.info.remove_background) {
337
500
  originalVariantsWithRemovedBg.push(createRemovedBackgroundVariantObject(updatedFile));
@@ -345,7 +508,9 @@ var VariationsTab = function VariationsTab(_ref) {
345
508
  }, setIsLoading);
346
509
  }
347
510
  return function () {
348
- dispatch(filesVariationsUpdated({}));
511
+ if (!variationsHideManualSubTab) {
512
+ dispatch(filesVariationsUpdated({}));
513
+ }
349
514
  _isUnMounting = true;
350
515
  };
351
516
  }, [previewedFile.uuid]);
@@ -353,12 +518,12 @@ var VariationsTab = function VariationsTab(_ref) {
353
518
  setSearchQuery('');
354
519
  }, [originalVariants]);
355
520
  useEffect(function () {
356
- var nextActiveTabId = presetsVariants.length === 0 || activeVariationsTabId === VARIATIONS_TAB_IDS.MANUAL ? VARIATIONS_TAB_IDS.MANUAL : VARIATIONS_TAB_IDS.AUTOMATIC;
521
+ var nextActiveTabId = !variationsHideManualSubTab && (presetsVariants.length === 0 || activeVariationsTabId === VARIATIONS_TAB_IDS.MANUAL) ? VARIATIONS_TAB_IDS.MANUAL : VARIATIONS_TAB_IDS.AUTOMATIC;
357
522
  setActiveVariationsTabId(nextActiveTabId);
358
523
  return function () {
359
524
  setActiveVariationsTabId(null);
360
525
  };
361
- }, [presetsVariants]);
526
+ }, [presetsVariants, variationsHideManualSubTab]);
362
527
  if (isLoading) {
363
528
  return /*#__PURE__*/_jsx(VariationsSkeleton, {
364
529
  i18n: i18n,
@@ -415,13 +580,15 @@ var VariationsTab = function VariationsTab(_ref) {
415
580
  originalVariantsCount: originalVariantsCount,
416
581
  isLoading: isLoading,
417
582
  i18n: i18n,
418
- activeTabId: activeVariationsTabId
583
+ activeTabId: activeVariationsTabId,
584
+ addNewPreset: triggerAddNewPresetModal,
585
+ showAddPresetButton: variationsShowAddPresetButton
419
586
  }), /*#__PURE__*/_jsx(UrlBuilderModal, {
420
587
  queryString: queryString,
421
588
  showUrlBuilderModal: showUrlBuilderModal,
422
589
  setShowUrlBuilderModal: setShowUrlBuilderModal,
423
590
  originalFile: originalFile,
424
- triggerAddVariantModal: triggerAddVariantModal,
591
+ onNewSave: handleUrlBuilderNewSave,
425
592
  headerTitle: i18n('explorerFileWindowAddVariationButton'),
426
593
  actionButtonLabel: i18n('mutualizedSaveButton'),
427
594
  urlTitle: i18n('explorerFileWindowVariationsUrlBuilderModalTitle'),
@@ -35,10 +35,10 @@ var BeforeUploadActionButtons = function BeforeUploadActionButtons(_ref) {
35
35
  if (filesLength === 1) dispatch(showAddFilesPanelUpdated(true));
36
36
  };
37
37
 
38
- /**
39
- * Navigates to the next item or closes the file window.
40
- *
41
- * @param {number} indexOffset - The offset from the current index. Defaults to 0.
38
+ /**
39
+ * Navigates to the next item or closes the file window.
40
+ *
41
+ * @param {number} indexOffset - The offset from the current index. Defaults to 0.
42
42
  */
43
43
  var navigateNextItemOrCloseFileWindow = function navigateNextItemOrCloseFileWindow() {
44
44
  var indexOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -49,9 +49,9 @@ export var generatePrettyName = function generatePrettyName(str) {
49
49
  return eachWordUpperCase ? convertStringToWordsArray(str).map(capitalizeFirstLetter).join(' ') : capitalizeFirstLetter(convertStringToWordsArray(str).join(' '));
50
50
  };
51
51
 
52
- /**
53
- * @param {string} roleName - Like "GALLERY_EDITOR"
54
- * @returns {{longName: string, shortName: string, i18nKeyLongName: string, i18nKeyShortName: string}}
52
+ /**
53
+ * @param {string} roleName - Like "GALLERY_EDITOR"
54
+ * @returns {{longName: string, shortName: string, i18nKeyLongName: string, i18nKeyShortName: string}}
55
55
  */
56
56
  export var prettyGalleryRole = function prettyGalleryRole(roleName) {
57
57
  var galleryRole = roleName ? roleName.toLowerCase() : 'unknown';
@@ -26,17 +26,17 @@ import StandardRolesTab from './StandardRolesTab';
26
26
  import { GALLERY_ROLE_TABS, GALLERY_ROLE_TABS_IDS } from './GalleryRoleSelect.constants';
27
27
  import CustomRolesTab from './CustomRolesTab';
28
28
 
29
- /**
30
- * @param {object} props
31
- * @param {string} props.value - Role ID
32
- * @param {function} props.onChange
33
- * @param {boolean} [props.showPermissionsInfo=true]
34
- * @param {number} [props.selectorPaddingX=17]
35
- * @param {boolean} [props.disabled=false]
36
- * @param {boolean} [props.readOnly=false]
37
- * @param {boolean} [props.defaultValueFirstItem=false]
38
- * @param {number} [props.minPermissions] - Use to specify which roles could be selectable
39
- * @returns
29
+ /**
30
+ * @param {object} props
31
+ * @param {string} props.value - Role ID
32
+ * @param {function} props.onChange
33
+ * @param {boolean} [props.showPermissionsInfo=true]
34
+ * @param {number} [props.selectorPaddingX=17]
35
+ * @param {boolean} [props.disabled=false]
36
+ * @param {boolean} [props.readOnly=false]
37
+ * @param {boolean} [props.defaultValueFirstItem=false]
38
+ * @param {number} [props.minPermissions] - Use to specify which roles could be selectable
39
+ * @returns
40
40
  */
41
41
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
42
42
  var GalleryRoleSelect = function GalleryRoleSelect(_ref) {