@scaleflex/widget-explorer 4.5.0 → 4.5.1

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 (48) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +21 -3
  3. package/lib/components/ActionBar/DownloadWithExportButton.js +32 -4
  4. package/lib/components/AssetsList/ListView/AssetsSection/AssetsSectionTableRow.js +1 -1
  5. package/lib/components/Breadcrumbs/index.js +114 -6
  6. package/lib/components/CollectionsView/CollectionFolderIcon.js +35 -0
  7. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionTreeSkeletion.js +26 -0
  8. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.styled.js +52 -0
  9. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.utils.js +24 -0
  10. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Folder.js +88 -0
  11. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Tree.js +50 -0
  12. package/lib/components/CollectionsView/CollectionVirtualFoldersTree/index.js +75 -0
  13. package/lib/components/CollectionsView/CollectionsSkeleton.js +30 -0
  14. package/lib/components/CollectionsView/CollectionsTree/ActiveCollectionContent.js +61 -0
  15. package/lib/components/CollectionsView/CollectionsTree/CollectionTreeItem.js +44 -0
  16. package/lib/components/CollectionsView/CollectionsTree/CollectionsContent.js +130 -0
  17. package/lib/components/CollectionsView/CollectionsTree/CollectionsTree.styled.js +84 -0
  18. package/lib/components/CollectionsView/CollectionsTree/index.js +47 -0
  19. package/lib/components/CollectionsView/CollectionsView.styled.js +38 -0
  20. package/lib/components/CollectionsView/VirtualFoldersGrid.js +67 -0
  21. package/lib/components/CollectionsView/index.js +188 -0
  22. package/lib/components/Details/Details.constants.js +1 -0
  23. package/lib/components/FileItem/FileInfo/index.js +8 -2
  24. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsTabNavigator.js +1 -7
  25. package/lib/components/FileWindowPanel/FileTabs/VariationsTab/index.js +4 -1
  26. package/lib/components/FileWindowPanel/Header/index.js +9 -0
  27. package/lib/components/Filters/hooks/useFilters.js +3 -2
  28. package/lib/components/HeaderBar/index.js +6 -2
  29. package/lib/components/LabelsView/LabelsTree/LabelsTree.styled.js +86 -0
  30. package/lib/components/LabelsView/LabelsTree/LabelsTreeSkeleton.js +21 -0
  31. package/lib/components/LabelsView/LabelsTree/index.js +128 -0
  32. package/lib/components/LabelsView/LabelsView.styled.js +10 -0
  33. package/lib/components/LabelsView/index.js +139 -0
  34. package/lib/components/Modals/DownloadConsent/DownloadConsent.hooks.js +11 -0
  35. package/lib/components/Modals/TransformedDownload/TransformedDownload.hooks.js +9 -0
  36. package/lib/components/Views/Views.constants.js +30 -4
  37. package/lib/components/Views/index.js +11 -4
  38. package/lib/components/common/FileMetadataFieldValue/GeneralMetadataFieldValue.js +1 -1
  39. package/lib/components/common/Sort/Sort.constants.js +28 -1
  40. package/lib/defaultLocale.js +36 -1
  41. package/lib/slices/collections.slice.js +714 -0
  42. package/lib/slices/common.slice.js +15 -52
  43. package/lib/slices/files.slice.js +6 -3
  44. package/lib/slices/index.js +5 -1
  45. package/lib/slices/labels.slice.js +652 -0
  46. package/lib/slices/views.slice.js +12 -0
  47. package/lib/utils/prepareSearchUrl.js +10 -0
  48. package/package.json +8 -8
@@ -0,0 +1,188 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ 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); }
7
+ import { useDispatch, useSelector } from 'react-redux';
8
+ import { NoAssets } from '@scaleflex/icons';
9
+ import { useExplorer, useIsSmallScreen } from '../../hooks';
10
+ import { selectActiveCollection, selectIsActiveVirtualFolderLoading, selectIsIntermediateVirtualFolder, selectCollectionsSortOrder, selectCollectionsSortBy, collectionsSortingUpdated, fetchCollectionsFiles, selectCollectionsError, activateFirstCollection, selectCollectionsActiveVirtualFolder, fetchCollectionVirtualFolders, selectIsCollectionsLoading, selectIsCollectionTreeOpened, toggleCollectionsTree, activateCollectionsView, selectCollectionsUuids } from '../../slices/collections.slice';
11
+ import { selectIsDetailsViewOpened, detailsViewToggled } from '../../slices/panels.slice';
12
+ import CollectionsTree from './CollectionsTree';
13
+ import VirtualFoldersGrid from './VirtualFoldersGrid';
14
+ import Drawer from '../Drawer';
15
+ import TopSection from '../TopSection';
16
+ import AssetsList from '../AssetsList';
17
+ import Details from '../Details';
18
+ import AssetsViewStyled from '../AssetsView/AssetsView.styled';
19
+ import Sort from '../common/Sort';
20
+ import { COLLECTIONS_FOLDERS_SORT_OPTIONS } from '../common/Sort/Sort.constants';
21
+ import { searchOrListViewFiles, selectIsListLayout } from '../../slices/views.slice';
22
+ import ErroredViewPlaceholder from '../Views/ErroredViewPlaceholder';
23
+ import GridLayoutCollectionsSkeleton from './CollectionsSkeleton';
24
+ import { DETAILS_SIDEBAR_WIDTHS } from '../Details/Details.constants';
25
+ import NoItems from '../NoItems';
26
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
27
+ var EMPTY_COLLECTIONS_VIEW_PLACEHOLDER_DATA = {
28
+ titleI18nKey: 'explorerCollectionsViewNoCollectionsLabel',
29
+ hintI18nKeys: ['explorerCollectionsViewNoCollectionsHint']
30
+ };
31
+ var CollectionsView = function CollectionsView() {
32
+ var dispatch = useDispatch();
33
+ var _useExplorer = useExplorer(),
34
+ i18n = _useExplorer.i18n,
35
+ opts = _useExplorer.opts;
36
+ var isDetailsViewOpened = useSelector(selectIsDetailsViewOpened);
37
+ var isCollectionTreeOpened = useSelector(selectIsCollectionTreeOpened);
38
+ var isCollectionsLoading = useSelector(selectIsCollectionsLoading);
39
+ var isActiveCollectionVirtualFoldersLoading = useSelector(selectIsActiveVirtualFolderLoading);
40
+ var isNoCollectionsFound = useSelector(function (state) {
41
+ return selectCollectionsUuids(state).length === 0;
42
+ });
43
+ var activeCollection = useSelector(selectActiveCollection);
44
+ var isCollectionIntermediateVirtualFolder = useSelector(selectIsIntermediateVirtualFolder);
45
+ var hasActiveCollectionVirtualFolder = useSelector(function (state) {
46
+ return !!selectCollectionsActiveVirtualFolder(state);
47
+ });
48
+ var sortOrder = useSelector(selectCollectionsSortOrder);
49
+ var sortBy = useSelector(selectCollectionsSortBy);
50
+ var isListLayout = useSelector(selectIsListLayout);
51
+ var error = useSelector(selectCollectionsError);
52
+ var isWidgetSmallSize = useIsSmallScreen();
53
+ var floaty = opts.floaty,
54
+ hideHeaderBar = opts.hideHeaderBar,
55
+ noItemsBrowser = opts.noItemsBrowser,
56
+ showBar = opts.showBar,
57
+ hideLeftSideBar = opts.hideLeftSideBar;
58
+ var fetchNextCollectionFiles = function fetchNextCollectionFiles() {
59
+ return dispatch(fetchCollectionsFiles());
60
+ };
61
+ var applyLeftSideNavigation = function applyLeftSideNavigation(child, closeFunc) {
62
+ return /*#__PURE__*/_jsx(Drawer, {
63
+ direction: "e",
64
+ position: "left",
65
+ closeFn: closeFunc,
66
+ noTopMargin: true,
67
+ showCloseIcon: isCollectionTreeOpened,
68
+ children: child
69
+ });
70
+ };
71
+ var applyRightSideNavigation = function applyRightSideNavigation(child, closeFunc) {
72
+ return /*#__PURE__*/_jsx(Drawer, _objectSpread(_objectSpread({
73
+ direction: "w",
74
+ position: "right",
75
+ closeFn: closeFunc,
76
+ style: {
77
+ overflow: floaty && 'inherit'
78
+ },
79
+ showCloseIcon: !floaty || isDetailsViewOpened
80
+ }, DETAILS_SIDEBAR_WIDTHS), {}, {
81
+ children: child
82
+ }));
83
+ };
84
+ var renderLeftSideNavigation = function renderLeftSideNavigation() {
85
+ return isCollectionTreeOpened && applyLeftSideNavigation(/*#__PURE__*/_jsx(CollectionsTree, {}), function () {
86
+ return dispatch(toggleCollectionsTree());
87
+ });
88
+ };
89
+ var renderRightSideNavigation = function renderRightSideNavigation() {
90
+ return isDetailsViewOpened && applyRightSideNavigation(/*#__PURE__*/_jsx(Details, {}), function () {
91
+ return dispatch(detailsViewToggled());
92
+ });
93
+ };
94
+
95
+ // TODO: Split those skeletons and maybe them separate and show the files/folders alone besides the other items skelecton if loaded
96
+ var renderContent = function renderContent() {
97
+ if (isCollectionsLoading || isActiveCollectionVirtualFoldersLoading) {
98
+ return /*#__PURE__*/_jsx(GridLayoutCollectionsSkeleton, {});
99
+ }
100
+ if (isCollectionIntermediateVirtualFolder) {
101
+ return /*#__PURE__*/_jsx(VirtualFoldersGrid, {});
102
+ }
103
+ if (isNoCollectionsFound) {
104
+ return /*#__PURE__*/_jsx(NoItems, {
105
+ primary: i18n('collectionsNoActivePrimaryPlaceholder'),
106
+ secondary: i18n('collectionsNoActiveSecondaryPlaceholder'),
107
+ icon: NoAssets,
108
+ iconWidth: 130,
109
+ iconHeight: 55,
110
+ size: 130,
111
+ mt: 150
112
+ });
113
+ }
114
+ return /*#__PURE__*/_jsx(AssetsList, {
115
+ isInitialLoading: isCollectionsLoading,
116
+ fetchNextFiles: fetchNextCollectionFiles,
117
+ sortProps: sortProps,
118
+ emptyViewPlaceholderData: _objectSpread({}, EMPTY_COLLECTIONS_VIEW_PLACEHOLDER_DATA),
119
+ noTopMargin: true
120
+ });
121
+ };
122
+ var handleChangeSort = function handleChangeSort(sortedBy, order) {
123
+ if (!isCollectionIntermediateVirtualFolder) {
124
+ // Fetch files again with the new sort
125
+ dispatch(fetchCollectionsFiles({
126
+ sortBy: sortedBy,
127
+ sortOrder: order,
128
+ offset: 0
129
+ }));
130
+ } else {
131
+ dispatch(collectionsSortingUpdated({
132
+ sortBy: sortedBy,
133
+ order: order
134
+ }));
135
+ }
136
+ };
137
+ var openFirstCollection = function openFirstCollection() {
138
+ dispatch(activateFirstCollection());
139
+ };
140
+ var handleCollectionsRefresh = function handleCollectionsRefresh() {
141
+ if (!activeCollection) {
142
+ return dispatch(activateCollectionsView({
143
+ skipViewDispatch: true
144
+ }));
145
+ }
146
+ if (!hasActiveCollectionVirtualFolder) {
147
+ return dispatch(fetchCollectionVirtualFolders());
148
+ }
149
+ return dispatch(searchOrListViewFiles());
150
+ };
151
+ var sortProps = _objectSpread({
152
+ onChange: handleChangeSort,
153
+ useFilesSort: true
154
+ }, isCollectionIntermediateVirtualFolder && {
155
+ options: COLLECTIONS_FOLDERS_SORT_OPTIONS,
156
+ sortBy: sortBy,
157
+ sortOrder: sortOrder,
158
+ useFilesSort: false
159
+ });
160
+ var SortElement = !!activeCollection && /*#__PURE__*/_jsx(Sort, _objectSpread({}, sortProps));
161
+ var renderTopSection = function renderTopSection(hideTopSection) {
162
+ return /*#__PURE__*/_jsx(TopSection, {
163
+ showTopBar: showBar && !noItemsBrowser,
164
+ showHeaderBar: !hideHeaderBar,
165
+ SortElement: SortElement,
166
+ hideTopSection: hideTopSection,
167
+ showFilters: hasActiveCollectionVirtualFolder && !isCollectionIntermediateVirtualFolder,
168
+ showLayoutAndDetailsBtns: hasActiveCollectionVirtualFolder && !isCollectionIntermediateVirtualFolder,
169
+ onRefresh: handleCollectionsRefresh
170
+ });
171
+ };
172
+ return /*#__PURE__*/_jsxs(_Fragment, {
173
+ children: [renderTopSection(!isWidgetSmallSize), /*#__PURE__*/_jsxs(AssetsViewStyled.BrowserBody, {
174
+ className: "filerobot-ProviderBrowser-body".concat(isListLayout ? ' filerobot-ProviderBrowser-body-list' : ''),
175
+ children: [!hideLeftSideBar && renderLeftSideNavigation(), /*#__PURE__*/_jsxs(AssetsViewStyled.ViewBody, {
176
+ className: "filerobot-ProviderBrowser-mainContent",
177
+ children: [renderTopSection(isWidgetSmallSize), !isCollectionsLoading && !isActiveCollectionVirtualFoldersLoading && error ? /*#__PURE__*/_jsx(ErroredViewPlaceholder, {
178
+ title: (error === null || error === void 0 ? void 0 : error.message) || error,
179
+ description: error === null || error === void 0 ? void 0 : error.details,
180
+ backTo: openFirstCollection,
181
+ backToLabel: i18n('collectionsViewGoToFirstCollection'),
182
+ error: error
183
+ }) : renderContent()]
184
+ }), renderRightSideNavigation()]
185
+ })]
186
+ });
187
+ };
188
+ export default CollectionsView;
@@ -11,6 +11,7 @@ var DETAILS_VARIANTS = {
11
11
  FILE: 'file',
12
12
  FOLDER: 'folder',
13
13
  PRODUCT: 'product',
14
+ COLLECTION: 'collection',
14
15
  NO_ITEM_SELECTED: 'no_item_selected',
15
16
  FAVORITES: 'favorites',
16
17
  NO_ITEM_SELECTED_IN_FOLDERS: 'no_item_selected_folders'
@@ -5,7 +5,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
5
5
  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; } }
6
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
7
  import { useState, useEffect } from 'react';
8
- import { useSelector } from 'react-redux';
8
+ import { useSelector, useDispatch } from 'react-redux';
9
9
  import { useTheme } from '@scaleflex/ui/theme/hooks';
10
10
  import { EllipsedText, TooltipV2 } from '@scaleflex/ui/core';
11
11
  import LabelIcon from '@scaleflex/icons/label';
@@ -23,8 +23,9 @@ import { ScaleflexWidget } from '@scaleflex/widget-core';
23
23
  import isUploadableFile from '@scaleflex/widget-utils/lib/isUploadableFile';
24
24
  import FileName from './FileName';
25
25
  import Styled from './FileInfo.styled';
26
- import { selectFileLabels } from '../../../slices/common.slice';
26
+ import { activateLabel, selectFileLabels } from '../../../slices/labels.slice';
27
27
  import { useExplorer, useToLocaleNumber } from '../../../hooks';
28
+ import { selectIsLabelsViewAvailable } from '../../../slices/views.slice';
28
29
  import { selectActiveRegionalLang } from '../../../slices/metadata.slice';
29
30
  import { selectCurrentFolder } from '../../../slices/folders.slice';
30
31
  import FileMetadata from './FileMetadata';
@@ -50,12 +51,14 @@ var FileInfo = function FileInfo(_ref) {
50
51
  disableFileResolutionFallback = _useExplorer$opts.disableFileResolutionFallback,
51
52
  thumbnailMetadataKeys = _useExplorer$opts.thumbnailMetadataKeys,
52
53
  isFastToken = _useExplorer$opts.isFastToken;
54
+ var dispatch = useDispatch();
53
55
  var toLocaleNumber = useToLocaleNumber();
54
56
  var showUploadsPanel = useSelector(function (state) {
55
57
  return selectUploadsCount(state) > 0;
56
58
  });
57
59
  var theme = useTheme();
58
60
  var iconPrimaryColor = theme.palette[PC.IconsPrimary];
61
+ var isLabelsViewAvailable = useSelector(selectIsLabelsViewAvailable);
59
62
  var currentLanguage = useSelector(selectActiveRegionalLang);
60
63
  var currentFolder = useSelector(selectCurrentFolder);
61
64
  var visibility = getVisibilityObject((file === null || file === void 0 ? void 0 : file.visibility) || getFileInheritedVisibility(currentFolder));
@@ -108,6 +111,9 @@ var FileInfo = function FileInfo(_ref) {
108
111
  return /*#__PURE__*/_jsx(Styled.ClickableText, {
109
112
  color: "link-basic-primary",
110
113
  size: "sm",
114
+ onClick: isLabelsViewAvailable ? function () {
115
+ return dispatch(activateLabel(label));
116
+ } : undefined,
111
117
  startIcon: /*#__PURE__*/_jsx(LabelIcon, {
112
118
  color: (label === null || label === void 0 ? void 0 : label.color) || iconPrimaryColor,
113
119
  size: 14
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect } from 'react';
1
+ import { useCallback } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
  import { VARIATIONS_TAB_IDS } from './Variations.constants';
4
4
  import { filesVariationsUpdated } from '../../../../slices/files.slice';
@@ -25,12 +25,6 @@ var VariationsTabNavigator = function VariationsTabNavigator(_ref) {
25
25
  dispatch(filesVariationsUpdated(firstVariant));
26
26
  setActiveTabId(newTabId);
27
27
  }, [dispatch]);
28
- useEffect(function () {
29
- if (activeTabId === VARIATIONS_TAB_IDS.AUTOMATIC) {
30
- var firstVariant = getActiveVariant(activeTabId);
31
- dispatch(filesVariationsUpdated(firstVariant));
32
- }
33
- }, []);
34
28
  return /*#__PURE__*/_jsx(VariationsTabs, {
35
29
  i18n: i18n,
36
30
  activeTabId: activeTabId,
@@ -491,7 +491,10 @@ var VariationsTab = function VariationsTab(_ref) {
491
491
  dispatch(filesVariationsUpdated(mainVariants[0]));
492
492
  }, setIsLoading);
493
493
  } else {
494
- dispatch(filesVariationsUpdated(mainFile));
494
+ var activeVariant = activeVariationsTabId === VARIATIONS_TAB_IDS.AUTOMATIC ? selectedVariant && (presetsVariants === null || presetsVariants === void 0 ? void 0 : presetsVariants.find(function (variant) {
495
+ return variant.name === selectedVariant.name;
496
+ })) || (presetsVariants === null || presetsVariants === void 0 ? void 0 : presetsVariants[0]) : mainFile;
497
+ dispatch(filesVariationsUpdated(activeVariant));
495
498
  setIsLoading(false);
496
499
  }
497
500
  if (mainFile.removedBackground && !mainFile.info.remove_background) {
@@ -11,6 +11,8 @@ import { RegionalVariantFilters } from '@scaleflex/widget-common';
11
11
  import isUploadableFile from '@scaleflex/widget-utils/lib/isUploadableFile';
12
12
  import { fileWindowUpdated } from '../../../slices/panels.slice';
13
13
  import { metadataRegionalFiltersSet, selectMetadataRegionalFilters, selectMetadataRegionalGroups, selectMetadataVersion } from '../../../slices/metadata.slice';
14
+ import { labelsSelectionToggled } from '../../../slices/labels.slice';
15
+ import { collectionsDeselected } from '../../../slices/collections.slice';
14
16
  import BeforeUploadActionButtons from './BeforeUploadActionBtns';
15
17
  import AfterUploadActionBtns from './AfterUploadActionBtns';
16
18
  import { useExplorer } from '../../../hooks';
@@ -38,8 +40,15 @@ var FileWindowHeader = function FileWindowHeader(_ref) {
38
40
  var name = previewedFile.name;
39
41
  var useAssetsPicker = opts.useAssetsPicker;
40
42
  var isFileLoading = originalFile.loading;
43
+ var handleClearSelection = function handleClearSelection() {
44
+ dispatch(labelsSelectionToggled({
45
+ uuids: []
46
+ }));
47
+ dispatch(collectionsDeselected());
48
+ };
41
49
  var closeFileWindow = function closeFileWindow() {
42
50
  alertUnsavedChangesFirst(function () {
51
+ handleClearSelection();
43
52
  dispatch(fileWindowUpdated(null));
44
53
  });
45
54
  };
@@ -2,9 +2,10 @@ import { useEffect, useMemo } from 'react';
2
2
  import { useSelector, useDispatch } from 'react-redux';
3
3
  import { useUpdateEffect } from '@scaleflex/widget-common/lib/hooks';
4
4
  import { DATE_OPTIONS_RANGE, FILTER_SECTION_KEYS } from '../Filters.constants';
5
- import { selectIsFoldersView, selectIsAssetsView } from '../../../slices/views.slice';
5
+ import { selectIsFoldersView, selectIsAssetsView, selectIsLabelsView, selectIsCollectionsView } from '../../../slices/views.slice';
6
6
  import { getFilters, selectAppliedFilters, selectIsFiltersLoaded } from '../../../slices/filters.slice';
7
7
  import { selectActiveRegionalLang, selectIsM0LegacyMeta, selectMetaMappedLicenseExpireDateField } from '../../../slices/metadata.slice';
8
+ import { selectIsCollectionsActivated } from '../../../slices/collections.slice';
8
9
  var useFilters = function useFilters() {
9
10
  var dispatch = useDispatch();
10
11
  var appliedFilters = useSelector(selectAppliedFilters);
@@ -12,7 +13,7 @@ var useFilters = function useFilters() {
12
13
  var activeRegionalLang = useSelector(selectActiveRegionalLang);
13
14
  var isFiltersLoaded = useSelector(selectIsFiltersLoaded);
14
15
  var isFiltersAvailableView = useSelector(function (state) {
15
- return selectIsAssetsView(state) || selectIsFoldersView(state);
16
+ return selectIsAssetsView(state) || selectIsFoldersView(state) || selectIsLabelsView(state) || selectIsCollectionsView(state) && selectIsCollectionsActivated(state);
16
17
  });
17
18
  var isFoldersFilterShown = useSelector(function (state) {
18
19
  return !selectIsFoldersView(state);
@@ -8,7 +8,7 @@ import BreadcrumbsSkeleton from '../Breadcrumbs/BreadcrumbsSkeleton';
8
8
  import RightSide from './RightSide';
9
9
  import Breadcrumbs from '../Breadcrumbs';
10
10
  import FacetedSearchToggleButton from './FacetedSearchToggleButton';
11
- import { selectActiveView, selectIsAssetsView, selectIsSearchMode } from '../../slices/views.slice';
11
+ import { selectActiveView, selectIsAssetsView, selectIsSearchMode, selectIsLabelsView, selectIsCollectionsView } from '../../slices/views.slice';
12
12
  import { selectIsFoldersTreeOpened } from '../../slices/folders.slice';
13
13
  import { selectIsAiSearch } from '../../slices/search.slice';
14
14
  import Styled from './HeaderBar.styled';
@@ -36,6 +36,8 @@ var HeaderBar = function HeaderBar(_ref) {
36
36
  var filesError = useSelector(selectFilesError);
37
37
  var isSearchMode = useSelector(selectIsSearchMode);
38
38
  var isAiSearch = useSelector(selectIsAiSearch);
39
+ var isLabelsView = useSelector(selectIsLabelsView);
40
+ var isCollectionsView = useSelector(selectIsCollectionsView);
39
41
  var isBreadcrumbsView = BREADCRUMBS_VIEWS.includes(activeView);
40
42
  var showBreadcrumbsLoading = !isSearchMode && isFilesLoading;
41
43
  var showBreadcrumbs = opts.showBreadcrumbs,
@@ -66,7 +68,9 @@ var HeaderBar = function HeaderBar(_ref) {
66
68
  return /*#__PURE__*/_jsxs(Styled.HeaderBar, {
67
69
  showFoldersTreeIcon: !showFoldersTree && !isAssetsView,
68
70
  className: classNames('filerobot-ProviderBrowser-headerBar', {
69
- 'filerobot-ProviderBrowser-headerBar--simple': !showBreadcrumbs
71
+ 'filerobot-ProviderBrowser-headerBar--simple': !showBreadcrumbs,
72
+ 'filerobot-ProviderBrowser-headerBar--labelsView': isLabelsView,
73
+ 'filerobot-ProviderBrowser-headerBar--collectionsView': isCollectionsView
70
74
  }),
71
75
  children: [renderViewBar(), showSortComponent && SortElement, /*#__PURE__*/_jsx(RightSide, {
72
76
  onRefresh: onRefresh,
@@ -0,0 +1,86 @@
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
2
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
+ import { FV, PC, PSH } from '@scaleflex/widget-common';
4
+ import { IconButton as SfxIconButton } from '@scaleflex/ui/core';
5
+ import styled from 'styled-components';
6
+ var Container = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 16px;\n padding-bottom: 24px;\n height: 100%;\n"])));
7
+ var Title = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n color: ", ";\n padding: 32px 24px 0 24px;\n"])), function (_ref) {
8
+ var font = _ref.theme.typography.font;
9
+ return font[FV.TitleH4];
10
+ }, function (_ref2) {
11
+ var palette = _ref2.theme.palette;
12
+ return palette[PC.TextPrimary];
13
+ });
14
+ var LabelItemIcon = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n\n svg {\n color: ", ";\n }\n"])), function (_ref3) {
15
+ var palette = _ref3.theme.palette;
16
+ return palette[PC.IconsPrimary];
17
+ });
18
+ var SearchWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 0 24px 0 24px;\n"])));
19
+ var AddLabelBtnWrapper = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n padding: 0 24px;\n height: 36px;\n\n .SfxButton-StartIcon {\n margin-right: 4px;\n }\n\n .SfxButton-Label{\n font-weight: 500;\n }\n"])));
20
+ var SettingsWrapper = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n padding: 0;\n gap: 10px;\n padding: 0 24px;\n width: 100%;\n"])));
21
+ var NameLabel = styled.span(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n ", "\n color: ", ";\n"])), function (_ref4) {
22
+ var font = _ref4.theme.typography.font;
23
+ return font[FV.LabelMedium];
24
+ }, function (_ref5) {
25
+ var palette = _ref5.theme.palette;
26
+ return palette[PC.LinkStateless];
27
+ });
28
+ var SortingWrapper = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n flex-grow: 1;\n gap: 4px;\n height: 32px;\n"])));
29
+ var IconButton = styled(SfxIconButton)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n &:focus,\n &:active {\n background: transparent;\n color: ", ";\n }\n\n &:hover {\n background: ", ";\n color: ", ";\n }\n"])), function (_ref6) {
30
+ var palette = _ref6.theme.palette;
31
+ return palette[PC.LinkStateless];
32
+ }, function (_ref7) {
33
+ var palette = _ref7.theme.palette;
34
+ return palette[PC.BackgroundHover];
35
+ }, function (_ref8) {
36
+ var palette = _ref8.theme.palette;
37
+ return palette[PC.IconsPrimaryHover];
38
+ });
39
+ var SettingsBtnWrapper = styled(SfxIconButton)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n width: 36px;\n height: 36px;\n padding: 1px 6px;\n border: 1px solid ", ";\n box-shadow: ", ";\n background: ", ";\n"])), function (_ref9) {
40
+ var palette = _ref9.theme.palette;
41
+ return palette[PC.IconsPrimary];
42
+ }, function (_ref10) {
43
+ var theme = _ref10.theme;
44
+ return theme.shadows[PSH.ShadowMd];
45
+ }, function (_ref11) {
46
+ var palette = _ref11.theme.palette;
47
+ return palette[PC.BackgroundStateless];
48
+ });
49
+ var LabelsWrapper = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n overflow-y: overlay;\n"])));
50
+ var LabelItemLabel = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n overflow: hidden;\n ", "\n color: ", ";\n"])), function (_ref12) {
51
+ var font = _ref12.theme.typography.font;
52
+ return font[FV.LabelMedium];
53
+ }, function (_ref13) {
54
+ var palette = _ref13.theme.palette;
55
+ return palette[PC.TextPrimary];
56
+ });
57
+ var LabelItem = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n height: 36px;\n gap: 6px;\n cursor: pointer;\n border-radius: 4px;\n margin: 0 24px;\n padding-left: 17px;\n\n &:hover {\n background: ", ";\n }\n\n ", "\n\n ", "\n"])), function (_ref14) {
58
+ var palette = _ref14.theme.palette;
59
+ return palette[PC.BackgroundHover];
60
+ }, function (_ref15) {
61
+ var $bg = _ref15.$bg;
62
+ return $bg ? "\n ".concat(LabelItemIcon, " {\n svg {\n color: ").concat($bg, ";\n }\n }\n ") : '';
63
+ }, function (_ref16) {
64
+ var $active = _ref16.$active,
65
+ $bg = _ref16.$bg,
66
+ palette = _ref16.theme.palette;
67
+ return $active ? "\n background: ".concat(palette[PC.BackgroundActive], " !important;\n\n ").concat(LabelItemLabel, " {\n color: ").concat(palette[PC.AccentStateless], ";\n }\n\n ").concat(LabelItemIcon, " {\n svg {\n color: ").concat($bg || palette[PC.AccentStateless], ";\n }\n }\n ") : '';
68
+ });
69
+ var NoItemsWrapper = styled.div(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 0 24px;\n\n svg {\n width: 150px;\n height: 60px;\n }\n"])));
70
+ var Styled = {
71
+ Container: Container,
72
+ Title: Title,
73
+ SearchWrapper: SearchWrapper,
74
+ AddLabelBtnWrapper: AddLabelBtnWrapper,
75
+ SettingsWrapper: SettingsWrapper,
76
+ SortingWrapper: SortingWrapper,
77
+ NameLabel: NameLabel,
78
+ SettingsBtnWrapper: SettingsBtnWrapper,
79
+ LabelsWrapper: LabelsWrapper,
80
+ LabelItem: LabelItem,
81
+ LabelItemIcon: LabelItemIcon,
82
+ LabelItemLabel: LabelItemLabel,
83
+ IconButton: IconButton,
84
+ NoItemsWrapper: NoItemsWrapper
85
+ };
86
+ export default Styled;
@@ -0,0 +1,21 @@
1
+ import { Skeleton } from '@scaleflex/ui/core';
2
+ import Styled from './LabelsTree.styled';
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ var LabelsTreeSkeleton = function LabelsTreeSkeleton() {
5
+ return /*#__PURE__*/_jsx(Styled.LabelsWrapper, {
6
+ children: Array(10).fill().map(function (_, index) {
7
+ return /*#__PURE__*/_jsxs(Styled.LabelItem, {
8
+ children: [/*#__PURE__*/_jsx(Styled.LabelItemIcon, {
9
+ children: /*#__PURE__*/_jsx(Skeleton, {
10
+ width: 14
11
+ })
12
+ }), /*#__PURE__*/_jsx(Styled.LabelItemLabel, {
13
+ children: /*#__PURE__*/_jsx(Skeleton, {
14
+ width: 220
15
+ })
16
+ })]
17
+ }, index);
18
+ })
19
+ });
20
+ };
21
+ export default LabelsTreeSkeleton;
@@ -0,0 +1,128 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ 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; } }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { useCallback, useState } from 'react';
8
+ import { useDispatch, useSelector } from 'react-redux';
9
+ import { useDebounce } from '@scaleflex/widget-common/lib/hooks';
10
+ import { Asc, Desc, Label } from '@scaleflex/icons';
11
+ import { Search, EllipsedText, TextWithHighlights } from '@scaleflex/ui/core';
12
+ import NoItems from '@scaleflex/widget-explorer/lib/components/NoItems';
13
+ import { labelsSearchTermUpdated, selectActiveLabelUuid, selectLabelsSearchTerm, selectLabelsBySearchTerm, selectLabelsArray, activateLabel, selectIsLabelsLoading } from '../../../slices/labels.slice';
14
+ import { useExplorer } from '../../../hooks';
15
+ import LabelsTreeSkeleton from './LabelsTreeSkeleton';
16
+ import Styled from './LabelsTree.styled';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ var LabelsTree = function LabelsTree() {
19
+ var dispatch = useDispatch();
20
+ var _useExplorer = useExplorer(),
21
+ i18n = _useExplorer.i18n,
22
+ opts = _useExplorer.opts;
23
+ var activeLabelUuid = useSelector(selectActiveLabelUuid);
24
+ var isLabelsLoading = useSelector(selectIsLabelsLoading);
25
+ var labelsSearchTerm = useSelector(selectLabelsSearchTerm);
26
+ var debouncedLabelsSearchTerm = useDebounce(labelsSearchTerm, 300);
27
+ var labelsCount = useSelector(function (state) {
28
+ return selectLabelsArray(state).length;
29
+ });
30
+ var filteredLabels = useSelector(function (state) {
31
+ return selectLabelsBySearchTerm(state, debouncedLabelsSearchTerm);
32
+ });
33
+ var _useState = useState(false),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ isDesc = _useState2[0],
36
+ setIsDesc = _useState2[1];
37
+ var showSort = opts.showSort;
38
+ var sortedLabels = filteredLabels.sort(function (labelA, labelB) {
39
+ return isDesc ? labelB === null || labelB === void 0 ? void 0 : labelB.name.localeCompare(labelA === null || labelA === void 0 ? void 0 : labelA.name) : labelA === null || labelA === void 0 ? void 0 : labelA.name.localeCompare(labelB === null || labelB === void 0 ? void 0 : labelB.name);
40
+ });
41
+ var isNoSearchedLabelsFound = (sortedLabels === null || sortedLabels === void 0 ? void 0 : sortedLabels.length) === 0;
42
+ var setLabelsSearchTerm = useCallback(function (_ref) {
43
+ var value = _ref.target.value;
44
+ dispatch(labelsSearchTermUpdated(value));
45
+ }, []);
46
+ var handleSortingLabels = function handleSortingLabels() {
47
+ setIsDesc(function (isDesc) {
48
+ return !isDesc;
49
+ });
50
+ };
51
+ var renderNoItems = function renderNoItems() {
52
+ if (labelsCount === 0) {
53
+ return /*#__PURE__*/_jsx(NoItems, {
54
+ iconWidth: 150,
55
+ iconHeight: 60,
56
+ secondary: i18n('labelsTreeNoLabels'),
57
+ mt: 64,
58
+ isTreeView: true
59
+ });
60
+ }
61
+ if ((sortedLabels || []).length === 0) {
62
+ return /*#__PURE__*/_jsx(Styled.NoItemsWrapper, {
63
+ children: /*#__PURE__*/_jsx(NoItems, {
64
+ noSearchResults: true,
65
+ smallItemsGap: true,
66
+ mt: 60,
67
+ primary: i18n('mutualizedNoResults'),
68
+ secondary: i18n('mutualizedTryAnotherSearch')
69
+ })
70
+ });
71
+ }
72
+ return null;
73
+ };
74
+ return /*#__PURE__*/_jsxs(Styled.Container, {
75
+ children: [/*#__PURE__*/_jsx(Styled.Title, {
76
+ children: i18n('labelsTreeTitle')
77
+ }), /*#__PURE__*/_jsx(Styled.SearchWrapper, {
78
+ children: /*#__PURE__*/_jsx(Search, {
79
+ value: labelsSearchTerm,
80
+ onChange: setLabelsSearchTerm,
81
+ placeholder: i18n('labelsTreeSearchPlaceholder'),
82
+ disabled: labelsCount === 0,
83
+ size: "sm",
84
+ fullWidth: true,
85
+ focusOnMount: true,
86
+ "data-testid": "labels-tree-search"
87
+ })
88
+ }), !isNoSearchedLabelsFound && /*#__PURE__*/_jsx(Styled.SettingsWrapper, {
89
+ children: showSort && /*#__PURE__*/_jsxs(Styled.SortingWrapper, {
90
+ children: [/*#__PURE__*/_jsx(Styled.NameLabel, {
91
+ children: i18n('sortOptionsByNameLabel')
92
+ }), /*#__PURE__*/_jsx(Styled.IconButton, {
93
+ color: "basic",
94
+ onClick: handleSortingLabels,
95
+ children: isDesc ? /*#__PURE__*/_jsx(Desc, {
96
+ size: 14
97
+ }) : /*#__PURE__*/_jsx(Asc, {
98
+ size: 14
99
+ })
100
+ })]
101
+ })
102
+ }), isLabelsLoading ? /*#__PURE__*/_jsx(LabelsTreeSkeleton, {}) : /*#__PURE__*/_jsx(Styled.LabelsWrapper, {
103
+ children: sortedLabels.map(function (label) {
104
+ return /*#__PURE__*/_jsxs(Styled.LabelItem, {
105
+ $active: activeLabelUuid === label.uuid,
106
+ $bg: label.color,
107
+ onClick: function onClick() {
108
+ return dispatch(activateLabel({
109
+ uuid: label.uuid
110
+ }));
111
+ },
112
+ children: [/*#__PURE__*/_jsx(Styled.LabelItemIcon, {
113
+ children: /*#__PURE__*/_jsx(Label, {})
114
+ }), /*#__PURE__*/_jsx(Styled.LabelItemLabel, {
115
+ children: /*#__PURE__*/_jsx(EllipsedText, {
116
+ maxLinesCount: 1,
117
+ children: /*#__PURE__*/_jsx(TextWithHighlights, {
118
+ text: label.name,
119
+ highlightText: debouncedLabelsSearchTerm
120
+ })
121
+ })
122
+ })]
123
+ }, label.sid);
124
+ })
125
+ }), !isLabelsLoading && renderNoItems()]
126
+ });
127
+ };
128
+ export default LabelsTree;
@@ -0,0 +1,10 @@
1
+ var _templateObject, _templateObject2;
2
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
+ import styled from 'styled-components';
4
+ var BrowserBody = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex: 1;\n z-index: 1000;\n position: relative;\n display: flex;\n overflow: hidden;\n"])));
5
+ var ViewBody = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow-y: auto;\n"])));
6
+ var Styled = {
7
+ BrowserBody: BrowserBody,
8
+ ViewBody: ViewBody
9
+ };
10
+ export default Styled;