@bindu-dashing/dam-solution-v2 5.8.37 → 5.8.39

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.
@@ -131,7 +131,11 @@ function AssetTemplatesTable({ assetTemplates, totalPages, totalCount, filters =
131
131
  title: "Actions",
132
132
  dataIndex: "",
133
133
  key: "actions",
134
- render: (record) => (_jsxs(Space, { children: [_jsx(Tooltip, { title: "Edit Asset template", className: "md-lib-hidden md:md-lib-block", children: _jsx(CustomButton, { icon: _jsx(EditOutlined, { size: 24, className: "md-lib-text-primaryColor" }), size: "large", label: "", className: "md-lib-border-none", onClick: () => navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(record, "_id"))) }) }), _jsx(Tooltip, { title: "Delete Asset template", placement: "topLeft", children: _jsx(CustomButton, { icon: _jsx(DeleteOutlined, { className: "md-lib-text-dangerColor", size: 24 }), label: "", type: "default", onClick: () => toggleDeletConfirm(record), className: "md-lib-border-none", size: "large" }) })] })),
134
+ render: (record) => (_jsxs(Space, { children: [_jsx(Tooltip, { title: "Edit Asset template", className: "md-lib-hidden md:md-lib-block", children: _jsx(CustomButton, { icon: _jsx(EditOutlined, { size: 24, className: "md-lib-text-primaryColor" }), size: "large", label: "", className: "md-lib-border-none", onClick: () => {
135
+ if (navigate) {
136
+ navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(record, "_id")));
137
+ }
138
+ } }) }), _jsx(Tooltip, { title: "Delete Asset template", placement: "topLeft", children: _jsx(CustomButton, { icon: _jsx(DeleteOutlined, { className: "md-lib-text-dangerColor", size: 24 }), label: "", type: "default", onClick: () => toggleDeletConfirm(record), className: "md-lib-border-none", size: "large" }) })] })),
135
139
  },
136
140
  ];
137
141
  const handleTableChange = (pagination, tableFilters, sorter) => {
@@ -41,7 +41,9 @@ export default function CreateAssetTemplate({ label }) {
41
41
  // console.log("response", response);
42
42
  showNotification(get(response, "data.message", CREATE_SUCCESS), NotificationStatus.SUCCESS);
43
43
  toggleModal();
44
- navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(response, "data._id")));
44
+ if (navigate) {
45
+ navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(response, "data._id")));
46
+ }
45
47
  }
46
48
  catch (error) {
47
49
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
@@ -129,7 +129,9 @@ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
129
129
  return finalField;
130
130
  }),
131
131
  });
132
- navigate(ASSETS_SCREEN);
132
+ if (navigate) {
133
+ navigate(ASSETS_SCREEN);
134
+ }
133
135
  showNotification(get(response, "data.message", UPDATE_SUCCESS), NotificationStatus.SUCCESS);
134
136
  }
135
137
  catch (error) {
@@ -168,11 +170,19 @@ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
168
170
  alignItems: "center",
169
171
  marginBottom: 0,
170
172
  }, centered: true, tabBarExtraContent: {
171
- left: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-border-b md-lib-p-3 md-lib-border-borderColor dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary md-lib-bg-white", children: [_jsx(IoMdCloseIcon, { size: ICON_SIZE, onClick: () => navigate(ASSETS_SCREEN), className: "md-lib-cursor-pointer" }), _jsx(Paragraph, { className: "md-lib-text-xl md-lib-border-l md-lib-pl-4 md-lib-ml-4 md-lib-asset-template-title", style: { marginBottom: "0px !important" }, editable: {
173
+ left: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-border-b md-lib-p-3 md-lib-border-borderColor dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary md-lib-bg-white", children: [_jsx(IoMdCloseIcon, { size: ICON_SIZE, onClick: () => {
174
+ if (navigate) {
175
+ navigate(ASSETS_SCREEN);
176
+ }
177
+ }, className: "md-lib-cursor-pointer" }), _jsx(Paragraph, { className: "md-lib-text-xl md-lib-border-l md-lib-pl-4 md-lib-ml-4 md-lib-asset-template-title", style: { marginBottom: "0px !important" }, editable: {
172
178
  onChange: (val) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { name: val }))),
173
179
  icon: _jsx(FiEdit2Icon, { size: 15, className: "md-lib-ml-2" }),
174
180
  }, children: name })] })),
175
- right: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-ml-auto", children: [imagePickerOutputFormatError && (_jsx("p", { className: "md-lib-text-sm md-lib-text-red-500", children: "Please fix the errors in the Image Picker Output format" })), _jsx(CustomButton, { label: "Cancel", onClick: () => navigate(ASSETS_SCREEN) }), _jsx(CustomButton, { label: "Save", type: currentFieldIndex !== null ? "default" : "primary", icon: _jsx(FiSaveIcon, {}), disabled: currentFieldIndex !== null, onClick: handleSaveTemplate, loading: loading })] })),
181
+ right: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-ml-auto", children: [imagePickerOutputFormatError && (_jsx("p", { className: "md-lib-text-sm md-lib-text-red-500", children: "Please fix the errors in the Image Picker Output format" })), _jsx(CustomButton, { label: "Cancel", onClick: () => {
182
+ if (navigate) {
183
+ navigate(ASSETS_SCREEN);
184
+ }
185
+ } }), _jsx(CustomButton, { label: "Save", type: currentFieldIndex !== null ? "default" : "primary", icon: _jsx(FiSaveIcon, {}), disabled: currentFieldIndex !== null, onClick: handleSaveTemplate, loading: loading })] })),
176
186
  }, onChange: (key) => setState((prevState) => {
177
187
  return Object.assign(Object.assign({}, prevState), { activeTab: key, currentFieldIndex: key === "2" ? null : prevState.currentFieldIndex });
178
188
  }) }) }));
@@ -1,19 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DriveModes } from "../utilities/constants/interface";
3
- import { DRIVE_MODES_SCREEN, MY_DRIVE_SCREEN, } from "../utilities/constants/routes";
3
+ import { DRIVE_MODES_SCREEN, } from "../utilities/constants/routes";
4
4
  import { Breadcrumb, Tooltip } from "antd";
5
5
  import { findIndex, get, isEmpty, last, map, slice } from "lodash";
6
6
  import { useMemo } from "react";
7
7
  import { FaChevronRight } from "react-icons/fa";
8
8
  import { useDamConfig } from "../hocs/DamConfigContext";
9
9
  import useAppParams from "../utilities/useAppParams";
10
- import useAppNavigate from "../utilities/useAppNavigate";
11
10
  const FaChevronRightIcon = FaChevronRight;
12
11
  function BreadCrumbList({ folder, parentFolderId, setParentFolderId, pickerFolderId, globalSearch, setSelectedKeys, }) {
13
12
  const { type, id } = useAppParams();
14
13
  const damConfig = useDamConfig();
15
14
  const { rootFolderId } = damConfig;
16
- const navigate = !pickerFolderId ? useAppNavigate() : null;
17
15
  const tree = useMemo(() => {
18
16
  const fullTree = get(folder, "tree", []);
19
17
  if (pickerFolderId) {
@@ -63,17 +61,10 @@ function BreadCrumbList({ folder, parentFolderId, setParentFolderId, pickerFolde
63
61
  if (pickerFolderId && setParentFolderId && !isLast) {
64
62
  setParentFolderId(treeId);
65
63
  }
66
- if (!pickerFolderId && !isLast) {
67
- if (treeId === rootFolderId) {
68
- // Navigate to MY_DRIVE_SCREEN only for root folder
69
- if (navigate) {
70
- navigate(MY_DRIVE_SCREEN);
71
- }
72
- }
73
- else if (setSelectedKeys) {
74
- // Use state-based navigation for other folders
75
- setSelectedKeys(treeId);
76
- }
64
+ if (!pickerFolderId && !isLast && setSelectedKeys) {
65
+ // Use state-based navigation for all folders including root
66
+ // This works regardless of whether Router context is available
67
+ setSelectedKeys(treeId);
77
68
  }
78
69
  };
79
70
  const currentItemRender = (_jsx(Breadcrumb.Item, { onClick: handleClick, className: "md-lib-h-auto md-lib-cursor-pointer", children: _jsx(Tooltip, { title: name, children: _jsx("p", { className: "md-lib-max-w-28 md-lib-truncate md-lib-font-semibold md-lib-text-[22px]", children: name }) }) }, treeId));
@@ -35,13 +35,15 @@ const FolderGridView = ({ folders, foldersFetching, hasNextPage, fetchNextPage,
35
35
  }
36
36
  }
37
37
  else if (type === DriveModes.FOLDERS) {
38
- navigate(FETCH_ENTITY_SCREEN.replace(":id", id).replace(":type", fileType));
38
+ if (navigate) {
39
+ navigate(FETCH_ENTITY_SCREEN.replace(":id", id).replace(":type", fileType));
40
+ }
39
41
  }
40
42
  else {
41
43
  if (clickTimer.current) {
42
44
  clearTimeout(clickTimer.current);
43
45
  clickTimer.current = null;
44
- if (fileType === EntityType.FOLDER) {
46
+ if (fileType === EntityType.FOLDER && navigate) {
45
47
  navigate(SUBFOLDERS_SCREEN.replace(":folderId", id));
46
48
  }
47
49
  if (fileType === EntityType.FILE && type !== DriveModes.TRASH) {
@@ -72,13 +72,15 @@ const FolderListView = ({ folders, foldersFetching, hasNextPage, fetchNextPage,
72
72
  }
73
73
  }
74
74
  else if (type === DriveModes.FOLDERS) {
75
- navigate(FETCH_ENTITY_SCREEN.replace(":id", id).replace(":type", fileType));
75
+ if (navigate) {
76
+ navigate(FETCH_ENTITY_SCREEN.replace(":id", id).replace(":type", fileType));
77
+ }
76
78
  }
77
79
  else {
78
80
  if (clickTimer.current) {
79
81
  clearTimeout(clickTimer.current);
80
82
  clickTimer.current = null;
81
- if (fileType === EntityType.FOLDER) {
83
+ if (fileType === EntityType.FOLDER && navigate) {
82
84
  navigate(SUBFOLDERS_SCREEN.replace(":folderId", id));
83
85
  }
84
86
  if (fileType === EntityType.FILE && type !== DriveModes.TRASH) {
@@ -1,17 +1,18 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FETCH_ENTITY_SCREEN, MY_DRIVE_SCREEN, SUBFOLDERS_SCREEN, } from "../utilities/constants/routes";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import ImagePickerDrive from "./ImagePickerDrive";
4
3
  import MyDriveMainContainer from "./MyDriveMainContainer";
5
- import { NavigatorProvider } from "../utilities/NavigatorProvider";
4
+ import useAppParams from "../utilities/useAppParams";
6
5
  export default function AppRoutes({ folders, setFolders, routerVersion, }) {
7
- if (routerVersion === 6) {
8
- // React Router v6
9
- const { Routes, Route } = require("react-router-dom");
10
- return (_jsxs(Routes, { children: [_jsx(Route, { path: MY_DRIVE_SCREEN, element: _jsx(MyDriveMainContainer, { folders: folders, setFolders: setFolders }) }, MY_DRIVE_SCREEN), _jsx(Route, { path: SUBFOLDERS_SCREEN, element: _jsx(MyDriveMainContainer, { folders: folders, setFolders: setFolders }) }, SUBFOLDERS_SCREEN), _jsx(Route, { path: FETCH_ENTITY_SCREEN, element: _jsx(ImagePickerDrive, {}) }, FETCH_ENTITY_SCREEN)] }));
6
+ const params = useAppParams();
7
+ const { type, id } = params;
8
+ // Determine which component to render based on params
9
+ // If type and id are present, it's likely an image picker or entity view
10
+ if (type && id) {
11
+ // This matches FETCH_ENTITY_SCREEN pattern
12
+ return _jsx(ImagePickerDrive, {});
11
13
  }
12
- // React Router v4/v5
13
- const { Switch, Route, withRouter } = require("react-router-dom");
14
- const Wrapper = ({ history }) => (_jsx(NavigatorProvider, { history: history, children: _jsxs(Switch, { children: [_jsx(Route, { path: MY_DRIVE_SCREEN, render: (props) => (_jsx(MyDriveMainContainer, Object.assign({ folders: folders, setFolders: setFolders }, props))) }, MY_DRIVE_SCREEN), _jsx(Route, { path: SUBFOLDERS_SCREEN, render: (props) => (_jsx(MyDriveMainContainer, Object.assign({ folders: folders, setFolders: setFolders }, props))) }, SUBFOLDERS_SCREEN), _jsx(Route, { path: FETCH_ENTITY_SCREEN, render: (props) => _jsx(ImagePickerDrive, Object.assign({}, props)) }, FETCH_ENTITY_SCREEN)] }) }));
15
- const WithRouterWrapper = withRouter(Wrapper);
16
- return _jsx(WithRouterWrapper, {});
14
+ // Otherwise, render the main drive container
15
+ // This handles both MY_DRIVE_SCREEN and SUBFOLDERS_SCREEN
16
+ // The folderId param will be handled by MyDriveMainContainer
17
+ return (_jsx(MyDriveMainContainer, { folders: folders, setFolders: setFolders }));
17
18
  }
@@ -1,2 +1,2 @@
1
- declare let useAppNavigate: () => (to: string) => void;
1
+ declare let useAppNavigate: () => ((to: string) => void) | null;
2
2
  export default useAppNavigate;
@@ -1,19 +1,42 @@
1
+ import * as React from "react";
1
2
  let useAppNavigate;
2
3
  const rrd = require("react-router-dom");
3
4
  if (rrd.useNavigate) {
4
5
  // ✅ v6+
5
6
  const { useNavigate } = rrd;
6
7
  useAppNavigate = () => {
7
- const navigate = useNavigate();
8
- return (to) => navigate(to);
8
+ // We need to call useNavigate unconditionally (hook rules)
9
+ // But we'll wrap it in an error boundary pattern
10
+ // If Router context is not available, this will throw
11
+ // The component using this should handle the error gracefully
12
+ let navigateFn = null;
13
+ // Use a ref to track if we've successfully initialized
14
+ const hasRouterContext = React.useRef(false);
15
+ try {
16
+ const navigate = useNavigate();
17
+ hasRouterContext.current = true;
18
+ navigateFn = (to) => navigate(to);
19
+ }
20
+ catch (e) {
21
+ // Router context not available - this will throw synchronously
22
+ // Return null so caller can use fallback
23
+ hasRouterContext.current = false;
24
+ navigateFn = null;
25
+ }
26
+ return navigateFn;
9
27
  };
10
28
  }
11
29
  else {
12
30
  // ✅ v4/v5 fallback → use our NavigatorProvider
13
31
  const { useLegacyNavigate } = require("./NavigatorProvider");
14
32
  useAppNavigate = () => {
15
- const navigate = useLegacyNavigate();
16
- return (to) => navigate(to);
33
+ try {
34
+ const navigate = useLegacyNavigate();
35
+ return (to) => navigate(to);
36
+ }
37
+ catch (e) {
38
+ return null;
39
+ }
17
40
  };
18
41
  }
19
42
  export default useAppNavigate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.37",
3
+ "version": "5.8.39",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",