strapi-plugin-bulk-updater 1.5.14 → 1.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{BulkUpdater-Cn17jk6f.js → BulkUpdater-CrmdSFUB.js} +313 -111
- package/dist/_chunks/BulkUpdater-CrmdSFUB.js.map +1 -0
- package/dist/_chunks/{BulkUpdater-B3m2_z--.mjs → BulkUpdater-DljSFIEd.mjs} +315 -113
- package/dist/_chunks/BulkUpdater-DljSFIEd.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +273 -219
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +273 -219
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-B3m2_z--.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-Cn17jk6f.js.map +0 -1
|
@@ -238,11 +238,23 @@ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
|
|
|
238
238
|
function CsvManagerTab() {
|
|
239
239
|
const { get, post } = admin.useFetchClient();
|
|
240
240
|
const { toggleNotification } = admin.useNotification();
|
|
241
|
+
const fileInputRef = React.useRef(null);
|
|
242
|
+
const countAbortControllerRef = React.useRef(null);
|
|
241
243
|
const [collections, setCollections] = React.useState([]);
|
|
242
244
|
const [loadingCollections, setLoadingCollections] = React.useState(true);
|
|
243
245
|
const [selectedUid, setSelectedUid] = React.useState("");
|
|
244
246
|
const [collectionEntries, setCollectionEntries] = React.useState([]);
|
|
245
247
|
const [pendingBatches, setPendingBatches] = React.useState([]);
|
|
248
|
+
const [relationsMeta, setRelationsMeta] = React.useState({});
|
|
249
|
+
const [attributesMeta, setAttributesMeta] = React.useState({});
|
|
250
|
+
const [searchAttribute, setSearchAttribute] = React.useState("");
|
|
251
|
+
const [filterOperator, setFilterOperator] = React.useState("none");
|
|
252
|
+
const [filterQuery, setFilterQuery] = React.useState("");
|
|
253
|
+
const [entrySearch, setEntrySearch] = React.useState("");
|
|
254
|
+
const [matchingCount, setMatchingCount] = React.useState(null);
|
|
255
|
+
const [countLoading, setCountLoading] = React.useState(false);
|
|
256
|
+
const [searchRelationOptions, setSearchRelationOptions] = React.useState([]);
|
|
257
|
+
const [searchRelationOptionsLoading, setSearchRelationOptionsLoading] = React.useState(false);
|
|
246
258
|
const [exportLimit, setExportLimit] = React.useState(0);
|
|
247
259
|
const [exportLimitInput, setExportLimitInput] = React.useState("");
|
|
248
260
|
const [exportingCollection, setExportingCollection] = React.useState(false);
|
|
@@ -290,10 +302,12 @@ function CsvManagerTab() {
|
|
|
290
302
|
if (modelsRes.data?.collections) {
|
|
291
303
|
loadedCollections = modelsRes.data.collections;
|
|
292
304
|
setCollections(loadedCollections);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
305
|
+
}
|
|
306
|
+
if (modelsRes.data?.relationsMeta) {
|
|
307
|
+
setRelationsMeta(modelsRes.data.relationsMeta);
|
|
308
|
+
}
|
|
309
|
+
if (modelsRes.data?.attributesMeta) {
|
|
310
|
+
setAttributesMeta(modelsRes.data.attributesMeta);
|
|
297
311
|
}
|
|
298
312
|
if (rulesRes.data?.rules) {
|
|
299
313
|
setRules(rulesRes.data.rules);
|
|
@@ -311,6 +325,96 @@ function CsvManagerTab() {
|
|
|
311
325
|
setLoadingCollections(false);
|
|
312
326
|
}
|
|
313
327
|
};
|
|
328
|
+
const getAttrDepth = (attr) => attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
|
|
329
|
+
React.useEffect(() => {
|
|
330
|
+
if (searchAttribute && relationsMeta[searchAttribute]) {
|
|
331
|
+
fetchSearchRelationOptions(relationsMeta[searchAttribute].targetUid);
|
|
332
|
+
} else {
|
|
333
|
+
setSearchRelationOptions([]);
|
|
334
|
+
}
|
|
335
|
+
}, [searchAttribute, relationsMeta]);
|
|
336
|
+
const fetchSearchRelationOptions = async (targetUid) => {
|
|
337
|
+
try {
|
|
338
|
+
setSearchRelationOptionsLoading(true);
|
|
339
|
+
const res = await get(`/bulk-updater/relation-options?targetUid=${encodeURIComponent(targetUid)}`);
|
|
340
|
+
if (res.data && res.data.success) {
|
|
341
|
+
setSearchRelationOptions(res.data.options || []);
|
|
342
|
+
}
|
|
343
|
+
} catch {
|
|
344
|
+
setSearchRelationOptions([]);
|
|
345
|
+
} finally {
|
|
346
|
+
setSearchRelationOptionsLoading(false);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const handleCollectionChange = (newUid) => {
|
|
350
|
+
if (newUid === selectedUid) return;
|
|
351
|
+
if (countAbortControllerRef.current) {
|
|
352
|
+
countAbortControllerRef.current.abort();
|
|
353
|
+
}
|
|
354
|
+
setSelectedUid(newUid);
|
|
355
|
+
setAllParsedRecords([]);
|
|
356
|
+
setCsvRawText("");
|
|
357
|
+
setFileName("");
|
|
358
|
+
setPreviewPage(1);
|
|
359
|
+
setImportProgress(null);
|
|
360
|
+
setImportResult(null);
|
|
361
|
+
setPreflightReport(null);
|
|
362
|
+
setPreflightLoading(false);
|
|
363
|
+
setImporting(false);
|
|
364
|
+
if (fileInputRef.current) {
|
|
365
|
+
fileInputRef.current.value = "";
|
|
366
|
+
}
|
|
367
|
+
setSearchAttribute("");
|
|
368
|
+
setFilterOperator("none");
|
|
369
|
+
setFilterQuery("");
|
|
370
|
+
setEntrySearch("");
|
|
371
|
+
setMatchingCount(null);
|
|
372
|
+
setCountLoading(Boolean(newUid));
|
|
373
|
+
};
|
|
374
|
+
React.useEffect(() => {
|
|
375
|
+
if (!selectedUid) {
|
|
376
|
+
setMatchingCount(null);
|
|
377
|
+
setCountLoading(false);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
setCountLoading(true);
|
|
381
|
+
const timer = setTimeout(async () => {
|
|
382
|
+
if (countAbortControllerRef.current) {
|
|
383
|
+
countAbortControllerRef.current.abort();
|
|
384
|
+
}
|
|
385
|
+
const controller = new AbortController();
|
|
386
|
+
countAbortControllerRef.current = controller;
|
|
387
|
+
try {
|
|
388
|
+
const params = new URLSearchParams({
|
|
389
|
+
page: "1",
|
|
390
|
+
pageSize: "1"
|
|
391
|
+
});
|
|
392
|
+
if (searchAttribute) {
|
|
393
|
+
params.set("attribute", searchAttribute);
|
|
394
|
+
params.set("searchAttribute", searchAttribute);
|
|
395
|
+
}
|
|
396
|
+
if (filterOperator && filterOperator !== "none") {
|
|
397
|
+
params.set("filterOperator", filterOperator);
|
|
398
|
+
if (filterQuery) params.set("filterQuery", filterQuery);
|
|
399
|
+
}
|
|
400
|
+
if (entrySearch && entrySearch.trim()) {
|
|
401
|
+
params.set("search", entrySearch.trim());
|
|
402
|
+
}
|
|
403
|
+
const res = await get(`/bulk-updater/collections/${selectedUid}/entries?${params.toString()}`, {
|
|
404
|
+
signal: controller.signal
|
|
405
|
+
});
|
|
406
|
+
if (res.data) {
|
|
407
|
+
const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
|
|
408
|
+
setMatchingCount(total);
|
|
409
|
+
}
|
|
410
|
+
} catch (err) {
|
|
411
|
+
if (!ValidationRulesTab.isAbortError(err)) ;
|
|
412
|
+
} finally {
|
|
413
|
+
setCountLoading(false);
|
|
414
|
+
}
|
|
415
|
+
}, 300);
|
|
416
|
+
return () => clearTimeout(timer);
|
|
417
|
+
}, [selectedUid, searchAttribute, filterOperator, filterQuery, entrySearch]);
|
|
314
418
|
const fetchAndEnrichEntries = async (colUid, cols = collections, batches = pendingBatches) => {
|
|
315
419
|
if (!colUid) return [];
|
|
316
420
|
try {
|
|
@@ -393,7 +497,17 @@ function CsvManagerTab() {
|
|
|
393
497
|
if (!selectedUid || exportingCollection) return;
|
|
394
498
|
try {
|
|
395
499
|
setExportingCollection(true);
|
|
396
|
-
const
|
|
500
|
+
const queryParams = new URLSearchParams();
|
|
501
|
+
if (exportLimit > 0) queryParams.set("limit", String(exportLimit));
|
|
502
|
+
if (searchAttribute) queryParams.set("searchAttribute", searchAttribute);
|
|
503
|
+
if (filterOperator && filterOperator !== "none") {
|
|
504
|
+
queryParams.set("filterOperator", filterOperator);
|
|
505
|
+
if (filterQuery) queryParams.set("filterQuery", filterQuery);
|
|
506
|
+
}
|
|
507
|
+
if (entrySearch && entrySearch.trim()) {
|
|
508
|
+
queryParams.set("search", entrySearch.trim());
|
|
509
|
+
}
|
|
510
|
+
const res = await get(`/bulk-updater/csv/export/${selectedUid}?${queryParams.toString()}`);
|
|
397
511
|
const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
|
|
398
512
|
const filename = res.data?.filename || `${selectedUid.split(".").pop()}_export.csv`;
|
|
399
513
|
downloadCsvFile(csvStr, filename);
|
|
@@ -677,23 +791,15 @@ function CsvManagerTab() {
|
|
|
677
791
|
{
|
|
678
792
|
value: selectedUid || void 0,
|
|
679
793
|
autocomplete: { type: "list", filter: "contains" },
|
|
680
|
-
placeholder: "
|
|
794
|
+
placeholder: "Select Collection Type...",
|
|
681
795
|
disabled: loadingCollections,
|
|
682
796
|
clearLabel: "Clear collection selection",
|
|
683
|
-
onClear: () =>
|
|
684
|
-
setSelectedUid("");
|
|
685
|
-
setImportResult(null);
|
|
686
|
-
setImportProgress(null);
|
|
687
|
-
},
|
|
797
|
+
onClear: () => handleCollectionChange(""),
|
|
688
798
|
onFocus: (e) => {
|
|
689
799
|
e.target.select();
|
|
690
800
|
},
|
|
691
801
|
onChange: (val) => {
|
|
692
|
-
|
|
693
|
-
setSelectedUid(val);
|
|
694
|
-
setImportResult(null);
|
|
695
|
-
setImportProgress(null);
|
|
696
|
-
}
|
|
802
|
+
handleCollectionChange(val ? String(val) : "");
|
|
697
803
|
},
|
|
698
804
|
children: collections.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ComboboxOption, { value: col.uid, textValue: `${col.displayName} (${col.uid})`, children: [
|
|
699
805
|
col.displayName,
|
|
@@ -719,7 +825,139 @@ function CsvManagerTab() {
|
|
|
719
825
|
] }) }),
|
|
720
826
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 5, background: "neutral100", hasRadius: true, children: [
|
|
721
827
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h3", fontWeight: "bold", marginBottom: 2, children: "1. Export Data to CSV" }),
|
|
722
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", marginBottom: 4, children: "Extract entire collections without artificial limits (streams 10,000+ records in paged chunks) or pinpoint records violating validation quotas." }),
|
|
828
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", marginBottom: 4, children: "Extract entire collections or filtered subsets without artificial limits (streams 10,000+ records in paged chunks) or pinpoint records violating validation quotas." }),
|
|
829
|
+
selectedUid ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef" }, children: [
|
|
830
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, children: [
|
|
831
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral700", textTransform: "uppercase", children: "Search & Filter Collection Before Export" }),
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
833
|
+
countLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral700", size: "S", children: "Calculating matching records..." }) : matchingCount !== null ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
834
|
+
designSystem.Badge,
|
|
835
|
+
{
|
|
836
|
+
backgroundColor: matchingCount > 0 ? "success100" : "warning100",
|
|
837
|
+
textColor: matchingCount > 0 ? "success700" : "warning700",
|
|
838
|
+
size: "S",
|
|
839
|
+
children: [
|
|
840
|
+
matchingCount.toLocaleString(),
|
|
841
|
+
" matching records found"
|
|
842
|
+
]
|
|
843
|
+
}
|
|
844
|
+
) : null,
|
|
845
|
+
(searchAttribute || filterOperator !== "none" || entrySearch.trim()) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
846
|
+
designSystem.Button,
|
|
847
|
+
{
|
|
848
|
+
variant: "ghost",
|
|
849
|
+
size: "S",
|
|
850
|
+
onClick: () => {
|
|
851
|
+
setSearchAttribute("");
|
|
852
|
+
setFilterOperator("none");
|
|
853
|
+
setFilterQuery("");
|
|
854
|
+
setEntrySearch("");
|
|
855
|
+
},
|
|
856
|
+
children: "Clear Filters"
|
|
857
|
+
}
|
|
858
|
+
)
|
|
859
|
+
] })
|
|
860
|
+
] }),
|
|
861
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
862
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: 280, minWidth: 230 }, children: [
|
|
863
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Search Attribute" }),
|
|
864
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
865
|
+
designSystem.Combobox,
|
|
866
|
+
{
|
|
867
|
+
autocomplete: { type: "list", filter: "contains" },
|
|
868
|
+
placeholder: "Select Search Attribute...",
|
|
869
|
+
value: searchAttribute || void 0,
|
|
870
|
+
clearLabel: "Reset search attribute",
|
|
871
|
+
onClear: () => setSearchAttribute(""),
|
|
872
|
+
onFocus: (e) => {
|
|
873
|
+
e.target.select();
|
|
874
|
+
},
|
|
875
|
+
onChange: (val) => {
|
|
876
|
+
if (val && typeof val === "string" && val !== "__none__") {
|
|
877
|
+
setSearchAttribute(val);
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
children: (selectedCol?.attributes || []).map((attr) => {
|
|
881
|
+
const rel = relationsMeta[attr];
|
|
882
|
+
const depth = getAttrDepth(attr);
|
|
883
|
+
const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
|
|
884
|
+
const textValue = badgeText ? `${attr} ${badgeText}` : attr;
|
|
885
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
|
|
886
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
|
|
887
|
+
rel ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
|
|
888
|
+
"relation ➔ ",
|
|
889
|
+
rel.targetDisplayName
|
|
890
|
+
] }) : depth > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
|
|
891
|
+
"L",
|
|
892
|
+
depth,
|
|
893
|
+
" component"
|
|
894
|
+
] }) : null
|
|
895
|
+
] }) }, `search_${attr}`);
|
|
896
|
+
})
|
|
897
|
+
},
|
|
898
|
+
`csv-search-attr-${selectedUid}`
|
|
899
|
+
)
|
|
900
|
+
] }),
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: 200, minWidth: 170 }, children: [
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: searchAttribute ? `Condition for "${searchAttribute}"` : "Filter condition" }),
|
|
903
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
904
|
+
designSystem.SingleSelect,
|
|
905
|
+
{
|
|
906
|
+
value: filterOperator,
|
|
907
|
+
disabled: !searchAttribute,
|
|
908
|
+
onChange: (val) => setFilterOperator(String(val)),
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "none", children: "Show All (No Value Filter)" }),
|
|
911
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "empty", children: "Is Empty or Null" }),
|
|
912
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "not_empty", children: "Is Not Empty" }),
|
|
913
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "equals", children: "Equals Exact Text" }),
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "contains", children: "Contains Substring" }),
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "starts_with", children: "Starts With" })
|
|
916
|
+
]
|
|
917
|
+
}
|
|
918
|
+
)
|
|
919
|
+
] }),
|
|
920
|
+
(filterOperator === "equals" || filterOperator === "contains" || filterOperator === "starts_with") && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: 1, minWidth: 200 }, children: [
|
|
921
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: searchAttribute ? `Value for "${searchAttribute}"` : "Value to match" }),
|
|
922
|
+
searchAttribute && relationsMeta[searchAttribute] ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
923
|
+
designSystem.Combobox,
|
|
924
|
+
{
|
|
925
|
+
autocomplete: { type: "list", filter: "contains" },
|
|
926
|
+
placeholder: searchRelationOptionsLoading ? "Loading entities..." : `Search & pick ${relationsMeta[searchAttribute].targetDisplayName} or type text...`,
|
|
927
|
+
value: filterQuery,
|
|
928
|
+
onClear: () => setFilterQuery(""),
|
|
929
|
+
onChange: (val) => {
|
|
930
|
+
if (typeof val === "string") {
|
|
931
|
+
setFilterQuery(val);
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
onInputChange: (e) => {
|
|
935
|
+
setFilterQuery(e.target.value);
|
|
936
|
+
},
|
|
937
|
+
children: searchRelationOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: opt.label, textValue: opt.label, children: opt.label }, opt.documentId))
|
|
938
|
+
}
|
|
939
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
940
|
+
designSystem.TextInput,
|
|
941
|
+
{
|
|
942
|
+
placeholder: "Type value to match...",
|
|
943
|
+
value: filterQuery,
|
|
944
|
+
onChange: (e) => setFilterQuery(e.target.value)
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
] }),
|
|
948
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { flex: 1, minWidth: 200 }, children: [
|
|
949
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Full-text Entry Search" }),
|
|
950
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
951
|
+
designSystem.TextInput,
|
|
952
|
+
{
|
|
953
|
+
placeholder: "Search title, name, or text across records...",
|
|
954
|
+
value: entrySearch,
|
|
955
|
+
onChange: (e) => setEntrySearch(e.target.value)
|
|
956
|
+
}
|
|
957
|
+
)
|
|
958
|
+
] })
|
|
959
|
+
] })
|
|
960
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef", textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Please select a Target Collection Type above to configure search filters and export data." }) }),
|
|
723
961
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-end", marginTop: 3, children: [
|
|
724
962
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { style: { width: 220 }, children: [
|
|
725
963
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Records to Download" }),
|
|
@@ -772,9 +1010,9 @@ function CsvManagerTab() {
|
|
|
772
1010
|
variant: "default",
|
|
773
1011
|
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
|
774
1012
|
onClick: handleExportCollection,
|
|
775
|
-
disabled: !selectedUid || exportingCollection,
|
|
1013
|
+
disabled: !selectedUid || exportingCollection || matchingCount === 0,
|
|
776
1014
|
loading: exportingCollection,
|
|
777
|
-
children: exportingCollection ? "Preparing CSV download..." : `Export ${exportLimit === 0 ? "All" : exportLimit.toLocaleString()} ${selectedCol?.displayName || "Collection"} Records (.csv)`
|
|
1015
|
+
children: exportingCollection ? "Preparing CSV download..." : countLoading ? "Export (...) Records (.csv)" : matchingCount !== null ? exportLimit > 0 && matchingCount > exportLimit ? `Export First ${exportLimit.toLocaleString()} of (${matchingCount.toLocaleString()}) Records (.csv)` : `Export (${matchingCount.toLocaleString()}) ${selectedCol?.displayName || "Collection"} Records (.csv)` : `Export ${exportLimit === 0 ? "All" : exportLimit.toLocaleString()} ${selectedCol?.displayName || "Collection"} Records (.csv)`
|
|
778
1016
|
}
|
|
779
1017
|
),
|
|
780
1018
|
rules.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", style: { marginLeft: "auto" }, children: [
|
|
@@ -855,6 +1093,7 @@ function CsvManagerTab() {
|
|
|
855
1093
|
type: "file",
|
|
856
1094
|
accept: ".csv",
|
|
857
1095
|
id: "csv-file-input",
|
|
1096
|
+
ref: fileInputRef,
|
|
858
1097
|
style: { display: "none" },
|
|
859
1098
|
onChange: handleFileUpload
|
|
860
1099
|
}
|
|
@@ -3735,24 +3974,8 @@ const BulkUpdater = () => {
|
|
|
3735
3974
|
const MODELS_CACHE_KEY = "strapi_bulk_updater_models_cache";
|
|
3736
3975
|
const LAST_ATTR_KEY = "strapi_bulk_updater_last_attr";
|
|
3737
3976
|
const LAST_COLLECTION_KEY = "strapi_bulk_updater_last_collection";
|
|
3738
|
-
const
|
|
3739
|
-
|
|
3740
|
-
const stored = localStorage.getItem(LAST_COLLECTION_KEY);
|
|
3741
|
-
if (stored) return stored;
|
|
3742
|
-
} catch {
|
|
3743
|
-
}
|
|
3744
|
-
return "";
|
|
3745
|
-
};
|
|
3746
|
-
const [selectedCollectionUid, setSelectedCollectionUid] = React.useState(getInitialCollectionUid);
|
|
3747
|
-
const getInitialAttribute = () => {
|
|
3748
|
-
try {
|
|
3749
|
-
const stored = localStorage.getItem(LAST_ATTR_KEY);
|
|
3750
|
-
if (stored) return stored;
|
|
3751
|
-
} catch {
|
|
3752
|
-
}
|
|
3753
|
-
return "";
|
|
3754
|
-
};
|
|
3755
|
-
const [selectedAttribute, setSelectedAttribute] = React.useState(getInitialAttribute);
|
|
3977
|
+
const [selectedCollectionUid, setSelectedCollectionUid] = React.useState("");
|
|
3978
|
+
const [selectedAttribute, setSelectedAttribute] = React.useState("");
|
|
3756
3979
|
const [attributeValue, setAttributeValue] = React.useState("");
|
|
3757
3980
|
const [selectedEntries, setSelectedEntries] = React.useState({});
|
|
3758
3981
|
const [expandedDzEntries, setExpandedDzEntries] = React.useState({});
|
|
@@ -3826,6 +4049,7 @@ const BulkUpdater = () => {
|
|
|
3826
4049
|
const [filterOperator, setFilterOperator] = React.useState("none");
|
|
3827
4050
|
const [filterQuery, setFilterQuery] = React.useState("");
|
|
3828
4051
|
const [entrySearch, setEntrySearch] = React.useState("");
|
|
4052
|
+
const abortControllersRef = React.useRef({});
|
|
3829
4053
|
const [statusFilter, setStatusFilter] = React.useState("all");
|
|
3830
4054
|
const isFilterActive = Boolean(searchAttribute && searchAttribute !== selectedAttribute) || filterOperator !== "none" && (["empty", "not_empty"].includes(filterOperator) || Boolean(filterQuery.trim())) || Boolean(entrySearch.trim()) || Boolean(statusFilter !== "all") || Boolean(useRegex && regexPattern.trim());
|
|
3831
4055
|
const [lastResults, setLastResults] = React.useState(null);
|
|
@@ -3937,28 +4161,14 @@ const BulkUpdater = () => {
|
|
|
3937
4161
|
setAttributesMeta(data.attributesMeta);
|
|
3938
4162
|
}
|
|
3939
4163
|
let resolvedColUid = selectedCollectionUid;
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
storedCol = localStorage.getItem(LAST_COLLECTION_KEY);
|
|
3943
|
-
} catch {
|
|
3944
|
-
}
|
|
3945
|
-
if (!resolvedColUid || !cols.some((c) => c.uid === resolvedColUid)) {
|
|
3946
|
-
resolvedColUid = storedCol && cols.some((c) => c.uid === storedCol) ? storedCol : cols[0]?.uid || "";
|
|
4164
|
+
if (resolvedColUid && !cols.some((c) => c.uid === resolvedColUid)) {
|
|
4165
|
+
resolvedColUid = "";
|
|
3947
4166
|
}
|
|
3948
4167
|
setSelectedCollectionUid(resolvedColUid);
|
|
3949
|
-
|
|
3950
|
-
if (resolvedColUid) localStorage.setItem(LAST_COLLECTION_KEY, resolvedColUid);
|
|
3951
|
-
} catch {
|
|
3952
|
-
}
|
|
3953
|
-
const activeCol = cols.find((c) => c.uid === resolvedColUid) || cols[0];
|
|
4168
|
+
const activeCol = resolvedColUid ? cols.find((c) => c.uid === resolvedColUid) : null;
|
|
3954
4169
|
const activeAttrs = activeCol?.attributes || [];
|
|
3955
4170
|
setAttributes(activeAttrs);
|
|
3956
|
-
|
|
3957
|
-
try {
|
|
3958
|
-
storedAttr = localStorage.getItem(LAST_ATTR_KEY);
|
|
3959
|
-
} catch {
|
|
3960
|
-
}
|
|
3961
|
-
const resolvedAttr = storedAttr && activeAttrs.includes(storedAttr) ? storedAttr : selectedAttribute && activeAttrs.includes(selectedAttribute) ? selectedAttribute : "";
|
|
4171
|
+
const resolvedAttr = selectedAttribute && activeAttrs.includes(selectedAttribute) ? selectedAttribute : "";
|
|
3962
4172
|
setSelectedAttribute(resolvedAttr);
|
|
3963
4173
|
if (resolvedAttr && data.relationsMeta && data.relationsMeta[resolvedAttr]) {
|
|
3964
4174
|
fetchRelationOptions(data.relationsMeta[resolvedAttr].targetUid);
|
|
@@ -4039,7 +4249,14 @@ const BulkUpdater = () => {
|
|
|
4039
4249
|
params.set("sortField", sortField);
|
|
4040
4250
|
params.set("sortOrder", sortOrder);
|
|
4041
4251
|
}
|
|
4042
|
-
|
|
4252
|
+
if (abortControllersRef.current[colUid]) {
|
|
4253
|
+
abortControllersRef.current[colUid].abort();
|
|
4254
|
+
}
|
|
4255
|
+
const controller = new AbortController();
|
|
4256
|
+
abortControllersRef.current[colUid] = controller;
|
|
4257
|
+
const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
|
|
4258
|
+
signal: controller.signal
|
|
4259
|
+
});
|
|
4043
4260
|
if (res.data && (res.data.success || res.data.entries !== void 0)) {
|
|
4044
4261
|
const fetchedEntries = res.data.entries || [];
|
|
4045
4262
|
const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
|
|
@@ -4181,6 +4398,9 @@ const BulkUpdater = () => {
|
|
|
4181
4398
|
}, [collections, selectedCollectionUid]);
|
|
4182
4399
|
const handleCollectionChange = (newUid) => {
|
|
4183
4400
|
if (newUid === selectedCollectionUid) return;
|
|
4401
|
+
if (abortControllersRef.current) {
|
|
4402
|
+
Object.values(abortControllersRef.current).forEach((ctrl) => ctrl.abort());
|
|
4403
|
+
}
|
|
4184
4404
|
setSelectedCollectionUid(newUid);
|
|
4185
4405
|
try {
|
|
4186
4406
|
if (newUid) {
|
|
@@ -4270,59 +4490,40 @@ const BulkUpdater = () => {
|
|
|
4270
4490
|
});
|
|
4271
4491
|
}, [depthFilteredAttributes, relationsMeta, selectedAttribute, componentDepth, attributesMeta]);
|
|
4272
4492
|
const memoizedSearchComboboxOptions = React.useMemo(() => {
|
|
4273
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
}
|
|
4288
|
-
),
|
|
4289
|
-
|
|
4290
|
-
const rel = relationsMeta[attr];
|
|
4291
|
-
const depth = getAttrDepth(attr);
|
|
4292
|
-
const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
|
|
4293
|
-
const textValue = badgeText ? `${attr} ${badgeText}` : attr;
|
|
4294
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
|
|
4295
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
|
|
4296
|
-
rel ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
|
|
4297
|
-
"relation ➔ ",
|
|
4298
|
-
rel.targetDisplayName
|
|
4299
|
-
] }) : depth > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
|
|
4300
|
-
"L",
|
|
4301
|
-
depth,
|
|
4302
|
-
" component"
|
|
4303
|
-
] }) : null
|
|
4304
|
-
] }) }, `search_${attr}`);
|
|
4305
|
-
})
|
|
4306
|
-
] });
|
|
4493
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: depthFilteredAttributes.map((attr) => {
|
|
4494
|
+
const rel = relationsMeta[attr];
|
|
4495
|
+
const depth = getAttrDepth(attr);
|
|
4496
|
+
const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
|
|
4497
|
+
const textValue = badgeText ? `${attr} ${badgeText}` : attr;
|
|
4498
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
|
|
4499
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
|
|
4500
|
+
rel ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
|
|
4501
|
+
"relation ➔ ",
|
|
4502
|
+
rel.targetDisplayName
|
|
4503
|
+
] }) : depth > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
|
|
4504
|
+
"L",
|
|
4505
|
+
depth,
|
|
4506
|
+
" component"
|
|
4507
|
+
] }) : null
|
|
4508
|
+
] }) }, `search_${attr}`);
|
|
4509
|
+
}) });
|
|
4307
4510
|
}, [depthFilteredAttributes, relationsMeta, searchAttribute, selectedAttribute, componentDepth, attributesMeta]);
|
|
4308
4511
|
const handleSearchAttributeChange = (newAttr) => {
|
|
4309
4512
|
const finalAttr = newAttr === "__default__" ? "" : newAttr;
|
|
4310
4513
|
setSearchAttribute(finalAttr);
|
|
4311
|
-
if (
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
);
|
|
4325
|
-
});
|
|
4514
|
+
if (selectedCollectionUid) {
|
|
4515
|
+
loadCollectionPage(
|
|
4516
|
+
selectedCollectionUid,
|
|
4517
|
+
1,
|
|
4518
|
+
void 0,
|
|
4519
|
+
void 0,
|
|
4520
|
+
void 0,
|
|
4521
|
+
filterOperator,
|
|
4522
|
+
filterQuery,
|
|
4523
|
+
entrySearch,
|
|
4524
|
+
true,
|
|
4525
|
+
finalAttr
|
|
4526
|
+
);
|
|
4326
4527
|
}
|
|
4327
4528
|
};
|
|
4328
4529
|
const handleCollectionPageSizeChange = (colUid, newSize) => {
|
|
@@ -5418,7 +5619,7 @@ const BulkUpdater = () => {
|
|
|
5418
5619
|
designSystem.Combobox,
|
|
5419
5620
|
{
|
|
5420
5621
|
autocomplete: { type: "list", filter: "contains" },
|
|
5421
|
-
placeholder: "
|
|
5622
|
+
placeholder: "Select Collection Type...",
|
|
5422
5623
|
value: selectedCollectionUid || void 0,
|
|
5423
5624
|
clearLabel: "Clear collection selection",
|
|
5424
5625
|
onClear: () => handleCollectionChange(""),
|
|
@@ -5519,8 +5720,8 @@ const BulkUpdater = () => {
|
|
|
5519
5720
|
designSystem.Combobox,
|
|
5520
5721
|
{
|
|
5521
5722
|
autocomplete: { type: "list", filter: "contains" },
|
|
5522
|
-
placeholder:
|
|
5523
|
-
value: searchAttribute ||
|
|
5723
|
+
placeholder: "Select Search Attribute...",
|
|
5724
|
+
value: searchAttribute || void 0,
|
|
5524
5725
|
clearLabel: "Reset search attribute",
|
|
5525
5726
|
onClear: () => handleSearchAttributeChange(""),
|
|
5526
5727
|
onFocus: (e) => {
|
|
@@ -5539,8 +5740,9 @@ const BulkUpdater = () => {
|
|
|
5539
5740
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 200, minWidth: 170 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5540
5741
|
designSystem.SingleSelect,
|
|
5541
5742
|
{
|
|
5542
|
-
label:
|
|
5743
|
+
label: searchAttribute ? `Condition for "${searchAttribute}"` : "Filter condition",
|
|
5543
5744
|
value: filterOperator,
|
|
5745
|
+
disabled: !searchAttribute,
|
|
5544
5746
|
onChange: (val) => setFilterOperator(String(val)),
|
|
5545
5747
|
children: [
|
|
5546
5748
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "none", children: "Show All (No Value Filter)" }),
|
|
@@ -6308,7 +6510,7 @@ const BulkUpdater = () => {
|
|
|
6308
6510
|
designSystem.Combobox,
|
|
6309
6511
|
{
|
|
6310
6512
|
autocomplete: { type: "list", filter: "contains" },
|
|
6311
|
-
placeholder: "
|
|
6513
|
+
placeholder: "Select Attribute to Update...",
|
|
6312
6514
|
value: selectedAttribute || void 0,
|
|
6313
6515
|
clearLabel: "Clear attribute selection",
|
|
6314
6516
|
onClear: () => handleAttributeChange(""),
|
|
@@ -7711,4 +7913,4 @@ exports.getNestedValue = getNestedValue;
|
|
|
7711
7913
|
exports.getPropertyValue = getPropertyValue;
|
|
7712
7914
|
exports.getSortOptionsForCollection = getSortOptionsForCollection;
|
|
7713
7915
|
exports.parseDynamicZonePath = parseDynamicZonePath;
|
|
7714
|
-
//# sourceMappingURL=BulkUpdater-
|
|
7916
|
+
//# sourceMappingURL=BulkUpdater-CrmdSFUB.js.map
|