@bindu-dashing/dam-solution-v2 5.8.144 → 5.8.148
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.
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { Form, Modal, Button, Upload, Select, Input, Radio, Typography, Tooltip, } from "antd";
|
|
11
|
+
import { Form, Modal, Button, Upload, Select, Input, Radio, Typography, Tooltip, Checkbox, Popover, } from "antd";
|
|
12
12
|
import { useEffect, useMemo, useState } from "react";
|
|
13
|
-
import { UploadOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
13
|
+
import { UploadOutlined, InfoCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
14
14
|
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
15
15
|
import { createApiClient } from "../hocs/configureAxios";
|
|
16
16
|
import { BULK_UPLOAD_URL, FETCH_ASSETS_URL, FILE_UPLOAD_URL, GENERATE_THUMBNAILS_URL, SAMPLE_FILE_DOWNLOAD_URL, } from "../utilities/constants/apiUrls";
|
|
@@ -113,7 +113,7 @@ const BulkUploadModal = ({ toggleUpload, userEmail, folderId, thumbnailsOnly, })
|
|
|
113
113
|
else {
|
|
114
114
|
const formData = new FormData();
|
|
115
115
|
formData.append("assetId", values === null || values === void 0 ? void 0 : values.asset_type_id);
|
|
116
|
-
formData.append("rejectInvalidMetaFile", "true");
|
|
116
|
+
formData.append("rejectInvalidMetaFile", (values === null || values === void 0 ? void 0 : values.reject_invalid_meta_file) ? "true" : "false");
|
|
117
117
|
formData.append("zipFileUrl", values === null || values === void 0 ? void 0 : values.zip_file_url);
|
|
118
118
|
formData.append("file", metaFile);
|
|
119
119
|
formData.append("folderId", folderId);
|
|
@@ -206,7 +206,7 @@ const BulkUploadModal = ({ toggleUpload, userEmail, folderId, thumbnailsOnly, })
|
|
|
206
206
|
}, disabled: !assetTypeId, onRemove: () => {
|
|
207
207
|
setMetaFile(null);
|
|
208
208
|
setFileError("Meta File is required");
|
|
209
|
-
}, accept: ".csv,.xlsx,.xls", maxCount: 1, children: _jsx(Button, { icon: _jsx(UploadOutlined, {}), disabled: !assetTypeId, children: "Upload" }) }) }), fileError && (_jsx(Typography.Text, { style: { color: "red" }, children: fileError }))] })), _jsx(Form.Item, { label: "Upload your DAM Files (must be zipped)", name: "assets_source_type", children: _jsxs(Radio.Group, { onChange: (e) => setAssetsSourceType(e.target.value), value: assetsSourceType, disabled: thumbnailsOnly ? false : !assetTypeId, children: [_jsx(Radio, { value: "zip", children: "Zip file" }), _jsx(Radio, { value: "zipUrl", children: "Zip file url" })] }) }), assetsSourceType == "zip" ? (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Assets zip file", name: "assets_zip_file", rules: [
|
|
209
|
+
}, accept: ".csv,.xlsx,.xls", maxCount: 1, children: _jsx(Button, { icon: _jsx(UploadOutlined, {}), disabled: !assetTypeId, children: "Upload" }) }) }), fileError && (_jsx(Typography.Text, { style: { color: "red" }, children: fileError })), _jsx(Form.Item, { name: "reject_invalid_meta_file", valuePropName: "checked", children: _jsxs(Checkbox, { name: "reject_invalid_meta_file", children: ["Reject invalid meta file", _jsx(Popover, { content: _jsxs("span", { style: { color: "grey", padding: "5px" }, children: ["When this option is selected the uploaded metadata", _jsx("br", {}), " file will be rejected if it contains invalid values"] }), children: _jsx(QuestionCircleOutlined, { style: { marginLeft: "5px", color: "silver" } }) })] }) })] })), _jsx(Form.Item, { label: "Upload your DAM Files (must be zipped)", name: "assets_source_type", children: _jsxs(Radio.Group, { onChange: (e) => setAssetsSourceType(e.target.value), value: assetsSourceType, disabled: thumbnailsOnly ? false : !assetTypeId, children: [_jsx(Radio, { value: "zip", children: "Zip file" }), _jsx(Radio, { value: "zipUrl", children: "Zip file url" })] }) }), assetsSourceType == "zip" ? (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Assets zip file", name: "assets_zip_file", rules: [
|
|
210
210
|
{
|
|
211
211
|
required: true,
|
|
212
212
|
message: "Asset zip file is required",
|
|
@@ -13,7 +13,7 @@ import _, { filter, first, flatMap, get, includes, isEmpty, merge, } from "lodas
|
|
|
13
13
|
import FolderListView from "./FolderListView";
|
|
14
14
|
import FolderGridView from "./FolderGridView";
|
|
15
15
|
import TypeAndDateFilters from "../common/folders/TypeAndDateFilters";
|
|
16
|
-
import { Button,
|
|
16
|
+
import { Button, Upload } from "antd";
|
|
17
17
|
import { addQueryParams, getDateRangeFromKey } from "../hocs/helpers";
|
|
18
18
|
import { useFolders } from "../react-query/services/folder-services";
|
|
19
19
|
import { DEFAULT_PAGE } from "../hocs/appConstants";
|
|
@@ -33,10 +33,8 @@ import ImagePickerBreadCrumbList from "./ImagePickerBreadCrumbList";
|
|
|
33
33
|
import { FETCH_ASSETS_URL, FETCH_IMAGE_PCIKER_THUMBNAIL_URL, UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, } from "../utilities/constants/apiUrls";
|
|
34
34
|
import { showNotification } from "../common/notifications";
|
|
35
35
|
import useAppParams from "../utilities/useAppParams";
|
|
36
|
-
import { IoIosSearch } from "react-icons/io";
|
|
37
36
|
import { RefetchFoldersProvider } from "../utilities/FoldersContext";
|
|
38
37
|
const BsUploadIcon = BsUpload;
|
|
39
|
-
const IoIosSearchIcon = IoIosSearch;
|
|
40
38
|
function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pickerFolderId, selectedPickerFile, imagePicker, globalSearch, setGlobalSearch, setSelectedKeys, }) {
|
|
41
39
|
const damConfig = useDamConfig();
|
|
42
40
|
const { rootFolderId, brand, isAdmin } = damConfig;
|
|
@@ -59,7 +57,6 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
59
57
|
folderSearch: "",
|
|
60
58
|
});
|
|
61
59
|
const { selectedType, selectedDateKey, showGrid, loadingType, selectedItems, assets, sortBy, sortOrder, searchKey, searchValue, metadataKey, metadataValue, folderSearch, } = state;
|
|
62
|
-
const nameSearchRef = useRef();
|
|
63
60
|
const getSearchParams = () => {
|
|
64
61
|
const params = {};
|
|
65
62
|
if (searchKey === "name") {
|
|
@@ -234,23 +231,12 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
234
231
|
onSelectNewFile(file);
|
|
235
232
|
}, showUploadList: false, accept: "image/*", children: _jsx(CustomButton, { loading: loadingType === "NEW_FILE_UPLOAD", label: "Select File", icon: _jsx(BsUploadIcon, {}) }) }))] }) })), _jsxs("div", { className: `md-lib-px-4 md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-flex ${!includes([DriveModes.FOLDERS, DriveModes.FILE], type)
|
|
236
233
|
? "md-lib-justify-between"
|
|
237
|
-
: "md-lib-justify-end md-lib-my-4"}`, children: [
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
setState((prevState) => {
|
|
244
|
-
return Object.assign(Object.assign({}, prevState), { folderSearch: value });
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} }), !includes([DriveModes.FOLDERS, DriveModes.FILE], type) && (_jsx(TypeAndDateFilters, { selectedDateKey: selectedDateKey, selectedType: selectedType, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
249
|
-
if (dates) {
|
|
250
|
-
const [start, end] = dates;
|
|
251
|
-
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
252
|
-
}
|
|
253
|
-
}, loading: isFetching, loadingType: loadingType }))] }), _jsx(ToggleView, { showGrid: showGrid, toggleView: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGrid: value }))) })] }), _jsx("div", { className: "md-lib-border-b md-lib-border-borderColor md-lib-mb-4" }), isLoading ? (_jsx(Loader, {})) : isEmpty(folders) ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: error
|
|
234
|
+
: "md-lib-justify-end md-lib-my-4"}`, children: [!includes([DriveModes.FOLDERS, DriveModes.FILE], type) && (_jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4 md-lib-mb-4", children: _jsx(TypeAndDateFilters, { selectedDateKey: selectedDateKey, selectedType: selectedType, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
235
|
+
if (dates) {
|
|
236
|
+
const [start, end] = dates;
|
|
237
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
238
|
+
}
|
|
239
|
+
}, loading: isFetching, loadingType: loadingType }) })), _jsx(ToggleView, { showGrid: showGrid, toggleView: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGrid: value }))) })] }), _jsx("div", { className: "md-lib-border-b md-lib-border-borderColor md-lib-mb-4" }), isLoading ? (_jsx(Loader, {})) : isEmpty(folders) ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: error
|
|
254
240
|
? get(error, "message", SOMETHING_WENT_WRONG)
|
|
255
241
|
: includes(Object.values(DriveModes), type)
|
|
256
242
|
? "No data found"
|
|
@@ -12,7 +12,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
12
12
|
import { createContext, useContext, useState, useEffect } from "react";
|
|
13
13
|
import { USER_LOGIN, FETCH_TEAMS_LIST, } from "../utilities/constants/apiUrls";
|
|
14
14
|
import axios from "axios";
|
|
15
|
-
import { getBaseUrl } from "./helpers";
|
|
15
|
+
import { getBaseUrl, encodeBase64 } from "./helpers";
|
|
16
16
|
import { get } from "lodash";
|
|
17
17
|
import Loader from "../common/loader/loader";
|
|
18
18
|
import { SUBSCRIPTION_EXPIRED_ERROR_MESSAGE } from "./appConstants";
|
|
@@ -76,23 +76,33 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
76
76
|
console.log("Could not extract teamID from token");
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
// Get the Teams API base URL
|
|
80
|
-
const teamsApiBaseUrl =
|
|
79
|
+
// Get the Teams API base URL from environment variable
|
|
80
|
+
const teamsApiBaseUrl = process.env.REACT_APP_CORE_API_URL || "";
|
|
81
|
+
if (!teamsApiBaseUrl) {
|
|
82
|
+
console.error("REACT_APP_CORE_API_URL is not defined in environment variables");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Get Basic Auth credentials from environment variables
|
|
86
|
+
const username = process.env.REACT_APP_TEAMS_API_TOKEN_USERNAME || "";
|
|
87
|
+
const password = process.env.REACT_APP_TEAMS_API_TOKEN_PASSWORD || "";
|
|
88
|
+
if (!username || !password) {
|
|
89
|
+
console.error("REACT_APP_TEAMS_API_TOKEN_USERNAME or REACT_APP_TEAMS_API_TOKEN_PASSWORD is not defined in environment variables");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Create Basic Auth header by encoding username:password to Base64
|
|
93
|
+
const basicAuthToken = encodeBase64(`${username}:${password}`);
|
|
94
|
+
const authorizationHeader = `Basic ${basicAuthToken}`;
|
|
81
95
|
const teamsEndpoint = FETCH_TEAMS_LIST.replace(":teamID", teamID);
|
|
82
96
|
const fullUrl = teamsApiBaseUrl + teamsEndpoint;
|
|
83
97
|
console.log("Fetching teams from:", fullUrl);
|
|
84
98
|
console.log("TeamID from token:", teamID);
|
|
85
|
-
// Call the new API endpoint using Teams API base URL
|
|
86
99
|
const response = yield axios.get(fullUrl, {
|
|
87
100
|
headers: {
|
|
88
|
-
Authorization:
|
|
101
|
+
Authorization: authorizationHeader,
|
|
89
102
|
},
|
|
90
103
|
});
|
|
91
104
|
console.log("Teams API response:", response === null || response === void 0 ? void 0 : response.data);
|
|
92
|
-
// Set teams from the API response
|
|
93
|
-
// Assuming the response structure is { data: [...] } or similar
|
|
94
105
|
const teamsData = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) || (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
95
|
-
console.log("Parsed teams data:", teamsData);
|
|
96
106
|
setTeams(Array.isArray(teamsData) ? teamsData : []);
|
|
97
107
|
}
|
|
98
108
|
catch (err) {
|
|
@@ -103,7 +113,6 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
103
113
|
status: (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.status,
|
|
104
114
|
url: (_d = err === null || err === void 0 ? void 0 : err.config) === null || _d === void 0 ? void 0 : _d.url,
|
|
105
115
|
});
|
|
106
|
-
// Set empty array on error to prevent stale data
|
|
107
116
|
setTeams([]);
|
|
108
117
|
}
|
|
109
118
|
});
|
|
@@ -117,12 +126,10 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
128
|
}, [damAccessKey, secretKey, subdomain]);
|
|
120
|
-
// Fetch teams after token is available
|
|
121
129
|
useEffect(() => {
|
|
122
130
|
if (accessToken) {
|
|
123
131
|
getTeams(accessToken);
|
|
124
132
|
}
|
|
125
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
133
|
}, [accessToken]);
|
|
127
134
|
return (_jsx(DamConfigContext.Provider, { value: {
|
|
128
135
|
damAccessKey,
|
package/build/hocs/helpers.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const getDateRangeFromKey: (key: string) => {
|
|
|
9
9
|
endDate?: string;
|
|
10
10
|
};
|
|
11
11
|
export declare const getBaseUrl: (appType: string) => string;
|
|
12
|
+
export declare const encodeBase64: (str: string) => string;
|
|
12
13
|
export declare const getRelativeTime: (timestamp: string) => string;
|
|
13
14
|
export declare const getReadableFileType: (file: FileEntity) => string;
|
|
14
15
|
export declare const humanFileSize: (size: any) => any;
|
package/build/hocs/helpers.js
CHANGED
|
@@ -102,6 +102,19 @@ export const getBaseUrl = (appType) => {
|
|
|
102
102
|
return process.env.REACT_APP_MIXDRIVE_API_URL || "";
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
+
export const encodeBase64 = (str) => {
|
|
106
|
+
if (typeof Buffer !== "undefined") {
|
|
107
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
|
111
|
+
return String.fromCharCode(parseInt(p1, 16));
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw new Error("Failed to encode string to Base64");
|
|
116
|
+
}
|
|
117
|
+
};
|
|
105
118
|
export const getRelativeTime = (timestamp) => {
|
|
106
119
|
const now = new Date();
|
|
107
120
|
const created = new Date(timestamp);
|