strapi-plugin-bulk-updater 1.5.14 → 1.5.16

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.
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import React__default, { useState, useEffect, useMemo, useRef } from "react";
2
+ import React__default, { useRef, useState, useEffect, useMemo } from "react";
3
3
  import { useFetchClient, useNotification } from "@strapi/strapi/admin";
4
- import { Box, Flex, Typography, Button, Combobox, ComboboxOption, TextInput, SingleSelect, SingleSelectOption, Badge, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Field } from "@strapi/design-system";
4
+ import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Field } from "@strapi/design-system";
5
5
  import { ArrowClockwise, Download, Upload, ChevronLeft, ChevronRight, Eye, Check, Cog, Play } from "@strapi/icons";
6
6
  import { i as isAbortError, V as ValidationRulesTab } from "./ValidationRulesTab-BtOCWK8E.mjs";
7
7
  function parseCsvRows(csvText) {
@@ -72,10 +72,11 @@ function parseCsvRows(csvText) {
72
72
  }
73
73
  return rows;
74
74
  }
75
- function parseCsv(csvText) {
75
+ function parseCsvWithHeaders(csvText) {
76
76
  const rows = parseCsvRows(csvText);
77
- if (rows.length < 2) return [];
77
+ if (rows.length === 0) return { headers: [], records: [] };
78
78
  const headers = rows[0].map((h) => h.trim());
79
+ if (rows.length < 2) return { headers, records: [] };
79
80
  const records = [];
80
81
  for (let i = 1; i < rows.length; i++) {
81
82
  const row = rows[i];
@@ -89,7 +90,125 @@ function parseCsv(csvText) {
89
90
  });
90
91
  records.push(record);
91
92
  }
92
- return records;
93
+ return { headers, records };
94
+ }
95
+ function escapeCsvCell(val) {
96
+ if (val === null || val === void 0) return "";
97
+ let str = "";
98
+ if (val instanceof Date) {
99
+ str = val.toISOString();
100
+ } else if (typeof val === "object") {
101
+ str = JSON.stringify(val);
102
+ } else {
103
+ str = String(val);
104
+ }
105
+ str = str.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
106
+ if (/^[=+@-]/.test(str)) {
107
+ str = `'${str}`;
108
+ }
109
+ if (str.includes(",") || str.includes('"') || str.includes("\n") || str.includes("\r")) {
110
+ return `"${str.replace(/"/g, '""')}"`;
111
+ }
112
+ return str;
113
+ }
114
+ function sanitizeUserErrorMessage(msg) {
115
+ if (msg === null || msg === void 0) return "Error processing row";
116
+ const raw = typeof msg === "string" ? msg : String(msg);
117
+ const cleanedLines = raw.split(/\r?\n/).filter((line) => !/^\s+at\s+.+(\(.+\)|:\d+:\d+)\s*$/.test(line)).map((line) => line.trim()).filter(Boolean);
118
+ return cleanedLines.join(" ").trim() || "Error processing row";
119
+ }
120
+ function resolveErrorColumnName(existingHeaders) {
121
+ const existingLower = new Set(
122
+ existingHeaders.map((h) => String(h || "").trim().toLowerCase())
123
+ );
124
+ if (!existingLower.has("error")) return "Error";
125
+ if (!existingLower.has("import error")) return "Import Error";
126
+ let suffix = 2;
127
+ while (existingLower.has(`import error (${suffix})`)) {
128
+ suffix++;
129
+ }
130
+ return `Import Error (${suffix})`;
131
+ }
132
+ function formatErrorCsvFilename(collectionTypeOrUid, date = /* @__PURE__ */ new Date()) {
133
+ const rawSegment = collectionTypeOrUid ? String(collectionTypeOrUid).split(".").pop() || String(collectionTypeOrUid) : "collection";
134
+ const safeType = rawSegment.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "collection";
135
+ const pad = (n) => String(n).padStart(2, "0");
136
+ const stamp = `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}_${pad(
137
+ date.getHours()
138
+ )}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
139
+ return `error_${safeType}_${stamp}.csv`;
140
+ }
141
+ function buildErrorCsv(options) {
142
+ const { headers, failedRows } = options || {};
143
+ if (!Array.isArray(failedRows) || failedRows.length === 0) {
144
+ return {
145
+ csvContent: "",
146
+ headers: headers ? [...headers] : [],
147
+ errorColumnName: "Error",
148
+ errorCount: 0
149
+ };
150
+ }
151
+ const groupedByRow = /* @__PURE__ */ new Map();
152
+ for (const item of failedRows) {
153
+ if (!item || typeof item !== "object") continue;
154
+ const rowNum = typeof item.row === "number" && !isNaN(item.row) ? item.row : groupedByRow.size + 2;
155
+ const msg = sanitizeUserErrorMessage(item.error);
156
+ const existing = groupedByRow.get(rowNum);
157
+ if (existing) {
158
+ if (!existing.messages.includes(msg)) {
159
+ existing.messages.push(msg);
160
+ }
161
+ } else {
162
+ groupedByRow.set(rowNum, {
163
+ row: rowNum,
164
+ documentId: item.documentId,
165
+ messages: [msg],
166
+ originalRow: item.originalRow && typeof item.originalRow === "object" ? item.originalRow : {}
167
+ });
168
+ }
169
+ }
170
+ const orderedEntries = Array.from(groupedByRow.values()).sort((a, b) => a.row - b.row);
171
+ if (orderedEntries.length === 0) {
172
+ return {
173
+ csvContent: "",
174
+ headers: headers ? [...headers] : [],
175
+ errorColumnName: "Error",
176
+ errorCount: 0
177
+ };
178
+ }
179
+ let baseHeaders = [];
180
+ if (Array.isArray(headers) && headers.length > 0) {
181
+ baseHeaders = [...headers];
182
+ } else {
183
+ const keySet = /* @__PURE__ */ new Set();
184
+ for (const entry of orderedEntries) {
185
+ for (const k of Object.keys(entry.originalRow || {})) {
186
+ if (!keySet.has(k)) {
187
+ keySet.add(k);
188
+ baseHeaders.push(k);
189
+ }
190
+ }
191
+ }
192
+ }
193
+ const errorColumnName = resolveErrorColumnName(baseHeaders);
194
+ const finalHeaders = [...baseHeaders, errorColumnName];
195
+ const lines = [];
196
+ lines.push(finalHeaders.map(escapeCsvCell).join(","));
197
+ for (const entry of orderedEntries) {
198
+ const cells = baseHeaders.map((h) => {
199
+ const val = entry.originalRow ? entry.originalRow[h] : "";
200
+ return escapeCsvCell(val === void 0 || val === null ? "" : val);
201
+ });
202
+ cells.push(escapeCsvCell(entry.messages.join("; ")));
203
+ lines.push(cells.join(","));
204
+ }
205
+ const csvContent = "\uFEFF" + lines.join("\r\n") + "\r\n";
206
+ return {
207
+ csvContent,
208
+ headers: finalHeaders,
209
+ errorColumnName,
210
+ errorCount: orderedEntries.length
211
+ };
93
212
  }
94
213
  const LIFECYCLE_STATUS_WORDS = /* @__PURE__ */ new Set([
95
214
  "pending review",
@@ -234,11 +353,23 @@ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
234
353
  function CsvManagerTab() {
235
354
  const { get, post } = useFetchClient();
236
355
  const { toggleNotification } = useNotification();
356
+ const fileInputRef = useRef(null);
357
+ const countAbortControllerRef = useRef(null);
237
358
  const [collections, setCollections] = useState([]);
238
359
  const [loadingCollections, setLoadingCollections] = useState(true);
239
360
  const [selectedUid, setSelectedUid] = useState("");
240
361
  const [collectionEntries, setCollectionEntries] = useState([]);
241
362
  const [pendingBatches, setPendingBatches] = useState([]);
363
+ const [relationsMeta, setRelationsMeta] = useState({});
364
+ const [attributesMeta, setAttributesMeta] = useState({});
365
+ const [searchAttribute, setSearchAttribute] = useState("");
366
+ const [filterOperator, setFilterOperator] = useState("none");
367
+ const [filterQuery, setFilterQuery] = useState("");
368
+ const [entrySearch, setEntrySearch] = useState("");
369
+ const [matchingCount, setMatchingCount] = useState(null);
370
+ const [countLoading, setCountLoading] = useState(false);
371
+ const [searchRelationOptions, setSearchRelationOptions] = useState([]);
372
+ const [searchRelationOptionsLoading, setSearchRelationOptionsLoading] = useState(false);
242
373
  const [exportLimit, setExportLimit] = useState(0);
243
374
  const [exportLimitInput, setExportLimitInput] = useState("");
244
375
  const [exportingCollection, setExportingCollection] = useState(false);
@@ -249,7 +380,7 @@ function CsvManagerTab() {
249
380
  const [selectedRuleId, setSelectedRuleId] = useState("");
250
381
  const [importMode, setImportMode] = useState("auto");
251
382
  const [publishOnImport, setPublishOnImport] = useState(true);
252
- const [csvRawText, setCsvRawText] = useState("");
383
+ const [originalHeaders, setOriginalHeaders] = useState([]);
253
384
  const [fileName, setFileName] = useState("");
254
385
  const [allParsedRecords, setAllParsedRecords] = useState([]);
255
386
  const [previewPage, setPreviewPage] = useState(1);
@@ -257,6 +388,8 @@ function CsvManagerTab() {
257
388
  const [importing, setImporting] = useState(false);
258
389
  const [importProgress, setImportProgress] = useState(null);
259
390
  const [importResult, setImportResult] = useState(null);
391
+ const [errorReport, setErrorReport] = useState(null);
392
+ const activeBatchIdRef = useRef(null);
260
393
  const [executionWindow, setExecutionWindow] = useState(null);
261
394
  const [preflightLoading, setPreflightLoading] = useState(false);
262
395
  const [preflightReport, setPreflightReport] = useState(null);
@@ -286,10 +419,12 @@ function CsvManagerTab() {
286
419
  if (modelsRes.data?.collections) {
287
420
  loadedCollections = modelsRes.data.collections;
288
421
  setCollections(loadedCollections);
289
- if (loadedCollections.length > 0) {
290
- const firstUid = loadedCollections[0].uid;
291
- setSelectedUid(firstUid);
292
- }
422
+ }
423
+ if (modelsRes.data?.relationsMeta) {
424
+ setRelationsMeta(modelsRes.data.relationsMeta);
425
+ }
426
+ if (modelsRes.data?.attributesMeta) {
427
+ setAttributesMeta(modelsRes.data.attributesMeta);
293
428
  }
294
429
  if (rulesRes.data?.rules) {
295
430
  setRules(rulesRes.data.rules);
@@ -307,6 +442,98 @@ function CsvManagerTab() {
307
442
  setLoadingCollections(false);
308
443
  }
309
444
  };
445
+ const getAttrDepth = (attr) => attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
446
+ useEffect(() => {
447
+ if (searchAttribute && relationsMeta[searchAttribute]) {
448
+ fetchSearchRelationOptions(relationsMeta[searchAttribute].targetUid);
449
+ } else {
450
+ setSearchRelationOptions([]);
451
+ }
452
+ }, [searchAttribute, relationsMeta]);
453
+ const fetchSearchRelationOptions = async (targetUid) => {
454
+ try {
455
+ setSearchRelationOptionsLoading(true);
456
+ const res = await get(`/bulk-updater/relation-options?targetUid=${encodeURIComponent(targetUid)}`);
457
+ if (res.data && res.data.success) {
458
+ setSearchRelationOptions(res.data.options || []);
459
+ }
460
+ } catch {
461
+ setSearchRelationOptions([]);
462
+ } finally {
463
+ setSearchRelationOptionsLoading(false);
464
+ }
465
+ };
466
+ const handleCollectionChange = (newUid) => {
467
+ if (newUid === selectedUid) return;
468
+ if (countAbortControllerRef.current) {
469
+ countAbortControllerRef.current.abort();
470
+ }
471
+ activeBatchIdRef.current = null;
472
+ setSelectedUid(newUid);
473
+ setAllParsedRecords([]);
474
+ setOriginalHeaders([]);
475
+ setFileName("");
476
+ setPreviewPage(1);
477
+ setImportProgress(null);
478
+ setImportResult(null);
479
+ setErrorReport(null);
480
+ setPreflightReport(null);
481
+ setPreflightLoading(false);
482
+ setImporting(false);
483
+ if (fileInputRef.current) {
484
+ fileInputRef.current.value = "";
485
+ }
486
+ setSearchAttribute("");
487
+ setFilterOperator("none");
488
+ setFilterQuery("");
489
+ setEntrySearch("");
490
+ setMatchingCount(null);
491
+ setCountLoading(Boolean(newUid));
492
+ };
493
+ useEffect(() => {
494
+ if (!selectedUid) {
495
+ setMatchingCount(null);
496
+ setCountLoading(false);
497
+ return;
498
+ }
499
+ setCountLoading(true);
500
+ const timer = setTimeout(async () => {
501
+ if (countAbortControllerRef.current) {
502
+ countAbortControllerRef.current.abort();
503
+ }
504
+ const controller = new AbortController();
505
+ countAbortControllerRef.current = controller;
506
+ try {
507
+ const params = new URLSearchParams({
508
+ page: "1",
509
+ pageSize: "1"
510
+ });
511
+ if (searchAttribute) {
512
+ params.set("attribute", searchAttribute);
513
+ params.set("searchAttribute", searchAttribute);
514
+ }
515
+ if (filterOperator && filterOperator !== "none") {
516
+ params.set("filterOperator", filterOperator);
517
+ if (filterQuery) params.set("filterQuery", filterQuery);
518
+ }
519
+ if (entrySearch && entrySearch.trim()) {
520
+ params.set("search", entrySearch.trim());
521
+ }
522
+ const res = await get(`/bulk-updater/collections/${selectedUid}/entries?${params.toString()}`, {
523
+ signal: controller.signal
524
+ });
525
+ if (res.data) {
526
+ const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
527
+ setMatchingCount(total);
528
+ }
529
+ } catch (err) {
530
+ if (!isAbortError(err)) ;
531
+ } finally {
532
+ setCountLoading(false);
533
+ }
534
+ }, 300);
535
+ return () => clearTimeout(timer);
536
+ }, [selectedUid, searchAttribute, filterOperator, filterQuery, entrySearch]);
310
537
  const fetchAndEnrichEntries = async (colUid, cols = collections, batches = pendingBatches) => {
311
538
  if (!colUid) return [];
312
539
  try {
@@ -389,7 +616,17 @@ function CsvManagerTab() {
389
616
  if (!selectedUid || exportingCollection) return;
390
617
  try {
391
618
  setExportingCollection(true);
392
- const res = await get(`/bulk-updater/csv/export/${selectedUid}?limit=${exportLimit}`);
619
+ const queryParams = new URLSearchParams();
620
+ if (exportLimit > 0) queryParams.set("limit", String(exportLimit));
621
+ if (searchAttribute) queryParams.set("searchAttribute", searchAttribute);
622
+ if (filterOperator && filterOperator !== "none") {
623
+ queryParams.set("filterOperator", filterOperator);
624
+ if (filterQuery) queryParams.set("filterQuery", filterQuery);
625
+ }
626
+ if (entrySearch && entrySearch.trim()) {
627
+ queryParams.set("search", entrySearch.trim());
628
+ }
629
+ const res = await get(`/bulk-updater/csv/export/${selectedUid}?${queryParams.toString()}`);
393
630
  const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
394
631
  const filename = res.data?.filename || `${selectedUid.split(".").pop()}_export.csv`;
395
632
  downloadCsvFile(csvStr, filename);
@@ -451,43 +688,76 @@ function CsvManagerTab() {
451
688
  const handleFileUpload = (e) => {
452
689
  const file = e.target.files?.[0];
453
690
  if (!file) return;
691
+ activeBatchIdRef.current = null;
454
692
  setFileName(file.name);
455
693
  setImportResult(null);
456
694
  setImportProgress(null);
695
+ setPreflightReport(null);
696
+ setErrorReport(null);
697
+ setOriginalHeaders([]);
457
698
  const reader = new FileReader();
458
699
  reader.onload = (event) => {
459
700
  const text = event.target?.result;
460
- setCsvRawText(text);
461
701
  try {
462
- const records = parseCsv(text);
463
- const enriched = enrichCsvRowsWithLifecycle(records, collectionEntries);
464
- setAllParsedRecords(enriched);
702
+ const { headers, records } = parseCsvWithHeaders(text);
703
+ setOriginalHeaders(headers);
704
+ setAllParsedRecords(records);
465
705
  setPreviewPage(1);
466
706
  } catch (err) {
707
+ setOriginalHeaders([]);
467
708
  setAllParsedRecords([]);
468
709
  }
469
710
  };
470
711
  reader.readAsText(file);
471
712
  };
713
+ const handleDownloadErrorCsv = () => {
714
+ if (!errorReport || errorReport.uid !== selectedUid || errorReport.failedRows.length === 0) {
715
+ return;
716
+ }
717
+ const { csvContent } = buildErrorCsv({
718
+ headers: errorReport.headers,
719
+ failedRows: errorReport.failedRows
720
+ });
721
+ const targetType = selectedCol?.singularName || selectedUid;
722
+ const errFilename = formatErrorCsvFilename(targetType);
723
+ downloadCsvFile(csvContent, errFilename);
724
+ };
472
725
  const handleExecuteImport = async () => {
473
726
  if (!selectedUid || allParsedRecords.length === 0) return;
474
- let currentEntries = collectionEntries;
475
- if (currentEntries.length === 0) {
476
- currentEntries = await fetchAndEnrichEntries(selectedUid);
477
- }
478
- const enrichedRecords = enrichCsvRowsWithLifecycle(allParsedRecords, currentEntries);
479
- const totalRows = enrichedRecords.length;
480
- const CHUNK_SIZE = 100;
481
- const totalChunks = Math.ceil(totalRows / CHUNK_SIZE);
727
+ const runUid = selectedUid;
728
+ const runHeaders = originalHeaders;
729
+ const originalRecordsSnapshot = allParsedRecords;
482
730
  const batchId = `csv_batch_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
731
+ activeBatchIdRef.current = batchId;
483
732
  try {
484
733
  setImporting(true);
485
734
  setImportResult(null);
735
+ setErrorReport(null);
736
+ let currentEntries = collectionEntries;
737
+ if (currentEntries.length === 0) {
738
+ currentEntries = await fetchAndEnrichEntries(runUid);
739
+ }
740
+ if (activeBatchIdRef.current !== batchId) return;
741
+ const enrichedRecords = enrichCsvRowsWithLifecycle(originalRecordsSnapshot, currentEntries);
742
+ const totalRows = enrichedRecords.length;
743
+ const CHUNK_SIZE = 100;
744
+ const totalChunks = Math.ceil(totalRows / CHUNK_SIZE);
486
745
  let liveCreated = 0;
487
746
  let liveUpdated = 0;
488
747
  let liveSkipped = 0;
748
+ let liveNewWithoutDocId = 0;
489
749
  let liveErrors = 0;
490
750
  let finalResultData = null;
751
+ const accumulatedErrors = [];
752
+ const accumulatedFailedRows = [];
753
+ const accumulatedDiffs = [];
754
+ const mapOriginalRowForIndex = (rowNum, backendOrigRow) => {
755
+ const idx = typeof rowNum === "number" ? rowNum - 2 : -1;
756
+ if (idx >= 0 && idx < originalRecordsSnapshot.length) {
757
+ return originalRecordsSnapshot[idx];
758
+ }
759
+ return backendOrigRow && typeof backendOrigRow === "object" ? backendOrigRow : {};
760
+ };
491
761
  setImportProgress({
492
762
  currentChunk: 0,
493
763
  totalChunks,
@@ -500,53 +770,152 @@ function CsvManagerTab() {
500
770
  liveErrors: 0
501
771
  });
502
772
  for (let chunkIdx = 0; chunkIdx < totalChunks; chunkIdx++) {
773
+ if (activeBatchIdRef.current !== batchId) return;
503
774
  const startIdx = chunkIdx * CHUNK_SIZE;
504
775
  const endIdx = Math.min(startIdx + CHUNK_SIZE, totalRows);
505
776
  const chunkRows = enrichedRecords.slice(startIdx, endIdx);
506
777
  const isFirst = chunkIdx === 0;
507
778
  const isLast = chunkIdx === totalChunks - 1;
508
779
  const startRowNumber = startIdx + 2;
509
- const res = await post("/bulk-updater/csv/import-chunk", {
510
- uid: selectedUid,
511
- rows: chunkRows,
512
- batchId,
513
- isFirstChunk: isFirst,
514
- isLastChunk: isLast,
515
- startRowNumber,
516
- mode: importMode,
517
- publish: publishOnImport,
518
- publishStrategy,
519
- unreviewedConsent
520
- });
521
- if (!res.data || !res.data.success) {
522
- throw new Error(res.data?.error || `Chunk ${chunkIdx + 1} failed to process`);
523
- }
524
- const chunkStats = res.data.chunkStats;
525
- if (chunkStats) {
526
- liveCreated += chunkStats.created || 0;
527
- liveUpdated += chunkStats.updated || 0;
528
- liveSkipped += chunkStats.skipped || 0;
529
- liveErrors += chunkStats.errors?.length || 0;
530
- }
531
- const currentProgressPercent = Math.round((chunkIdx + 1) / totalChunks * 100);
532
- setImportProgress({
533
- currentChunk: chunkIdx + 1,
534
- totalChunks,
535
- percent: currentProgressPercent,
536
- processedRows: endIdx,
537
- totalRows,
538
- liveCreated,
539
- liveUpdated,
540
- liveSkipped,
541
- liveErrors
542
- });
543
- if (isLast) {
544
- finalResultData = res.data;
780
+ try {
781
+ const res = await post("/bulk-updater/csv/import-chunk", {
782
+ uid: runUid,
783
+ rows: chunkRows,
784
+ batchId,
785
+ isFirstChunk: isFirst,
786
+ isLastChunk: isLast,
787
+ startRowNumber,
788
+ mode: importMode,
789
+ publish: publishOnImport,
790
+ publishStrategy,
791
+ unreviewedConsent,
792
+ ...isFirst && runHeaders.length > 0 ? { originalHeaders: runHeaders } : {}
793
+ });
794
+ if (activeBatchIdRef.current !== batchId) return;
795
+ if (!res.data || !res.data.success) {
796
+ throw new Error(res.data?.error || `Chunk ${chunkIdx + 1} failed to process`);
797
+ }
798
+ const chunkStats = res.data.chunkStats;
799
+ if (chunkStats) {
800
+ liveCreated += chunkStats.created || 0;
801
+ liveUpdated += chunkStats.updated || 0;
802
+ liveSkipped += chunkStats.skipped || 0;
803
+ liveNewWithoutDocId += chunkStats.newWithoutDocId || 0;
804
+ liveErrors += chunkStats.errors?.length || 0;
805
+ if (Array.isArray(chunkStats.errors)) {
806
+ accumulatedErrors.push(...chunkStats.errors);
807
+ }
808
+ if (Array.isArray(chunkStats.failedRows) && chunkStats.failedRows.length > 0) {
809
+ for (const f of chunkStats.failedRows) {
810
+ accumulatedFailedRows.push({
811
+ row: f.row,
812
+ documentId: f.documentId,
813
+ error: f.error,
814
+ originalRow: mapOriginalRowForIndex(f.row, f.originalRow)
815
+ });
816
+ }
817
+ } else if (Array.isArray(chunkStats.errors) && chunkStats.errors.length > 0) {
818
+ for (const errItem of chunkStats.errors) {
819
+ accumulatedFailedRows.push({
820
+ row: errItem.row,
821
+ documentId: errItem.documentId,
822
+ error: errItem.error,
823
+ originalRow: mapOriginalRowForIndex(errItem.row)
824
+ });
825
+ }
826
+ }
827
+ if (Array.isArray(chunkStats.diffs)) {
828
+ accumulatedDiffs.push(...chunkStats.diffs);
829
+ }
830
+ }
831
+ const currentProgressPercent = Math.round((chunkIdx + 1) / totalChunks * 100);
832
+ setImportProgress({
833
+ currentChunk: chunkIdx + 1,
834
+ totalChunks,
835
+ percent: currentProgressPercent,
836
+ processedRows: endIdx,
837
+ totalRows,
838
+ liveCreated,
839
+ liveUpdated,
840
+ liveSkipped,
841
+ liveErrors
842
+ });
843
+ if (isLast) {
844
+ finalResultData = res.data;
845
+ }
846
+ } catch (chunkErr) {
847
+ if (isAbortError(chunkErr)) return;
848
+ if (activeBatchIdRef.current !== batchId) return;
849
+ const apiErrMsg = sanitizeUserErrorMessage(
850
+ chunkErr?.response?.data?.error?.message || chunkErr?.response?.data?.error || chunkErr?.message || `Chunk ${chunkIdx + 1} failed to process`
851
+ );
852
+ for (let j = startIdx; j < endIdx; j++) {
853
+ const rowNum = j + 2;
854
+ const rawRow = originalRecordsSnapshot[j] || {};
855
+ const rowDocId = extractDocId(rawRow) || void 0;
856
+ accumulatedErrors.push({
857
+ row: rowNum,
858
+ ...rowDocId ? { documentId: rowDocId } : {},
859
+ error: apiErrMsg
860
+ });
861
+ accumulatedFailedRows.push({
862
+ row: rowNum,
863
+ ...rowDocId ? { documentId: rowDocId } : {},
864
+ error: apiErrMsg,
865
+ originalRow: rawRow
866
+ });
867
+ liveSkipped++;
868
+ liveErrors++;
869
+ }
870
+ setImportResult({
871
+ success: false,
872
+ batchId,
873
+ stats: {
874
+ total: totalRows,
875
+ created: liveCreated,
876
+ updated: liveUpdated,
877
+ skipped: liveSkipped,
878
+ newWithoutDocId: liveNewWithoutDocId,
879
+ errors: accumulatedErrors,
880
+ diffs: accumulatedDiffs
881
+ }
882
+ });
883
+ if (accumulatedFailedRows.length > 0) {
884
+ setErrorReport({
885
+ uid: runUid,
886
+ batchId,
887
+ headers: runHeaders,
888
+ failedRows: accumulatedFailedRows
889
+ });
890
+ }
891
+ throw new Error(apiErrMsg);
545
892
  }
546
893
  }
894
+ if (activeBatchIdRef.current !== batchId) return;
547
895
  if (finalResultData && finalResultData.stats) {
548
896
  setImportResult(finalResultData);
549
897
  const stats = finalResultData.stats;
898
+ const finalFailedRows = accumulatedFailedRows.length > 0 ? accumulatedFailedRows : Array.isArray(stats.failedRows) && stats.failedRows.length > 0 ? stats.failedRows.map((f) => ({
899
+ row: f.row,
900
+ documentId: f.documentId,
901
+ error: f.error,
902
+ originalRow: mapOriginalRowForIndex(f.row, f.originalRow)
903
+ })) : Array.isArray(stats.errors) ? stats.errors.map((errItem) => ({
904
+ row: errItem.row,
905
+ documentId: errItem.documentId,
906
+ error: errItem.error,
907
+ originalRow: mapOriginalRowForIndex(errItem.row)
908
+ })) : [];
909
+ if (finalFailedRows.length > 0) {
910
+ setErrorReport({
911
+ uid: runUid,
912
+ batchId: finalResultData.batchId || batchId,
913
+ headers: runHeaders,
914
+ failedRows: finalFailedRows
915
+ });
916
+ } else {
917
+ setErrorReport(null);
918
+ }
550
919
  let notifMsg = `CSV Import complete: ${stats.created} created, ${stats.updated} updated across ${stats.total} records.`;
551
920
  if (stats.newWithoutDocId && stats.newWithoutDocId > 0) {
552
921
  notifMsg += ` (${stats.newWithoutDocId} new entries created due to omitted documentId)`;
@@ -563,7 +932,9 @@ function CsvManagerTab() {
563
932
  message: err.message || "Error processing CSV import batch"
564
933
  });
565
934
  } finally {
566
- setImporting(false);
935
+ if (activeBatchIdRef.current === batchId || activeBatchIdRef.current === null) {
936
+ setImporting(false);
937
+ }
567
938
  }
568
939
  };
569
940
  const handleRunPreflight = async () => {
@@ -673,23 +1044,15 @@ function CsvManagerTab() {
673
1044
  {
674
1045
  value: selectedUid || void 0,
675
1046
  autocomplete: { type: "list", filter: "contains" },
676
- placeholder: "Search & select a collection...",
1047
+ placeholder: "Select Collection Type...",
677
1048
  disabled: loadingCollections,
678
1049
  clearLabel: "Clear collection selection",
679
- onClear: () => {
680
- setSelectedUid("");
681
- setImportResult(null);
682
- setImportProgress(null);
683
- },
1050
+ onClear: () => handleCollectionChange(""),
684
1051
  onFocus: (e) => {
685
1052
  e.target.select();
686
1053
  },
687
1054
  onChange: (val) => {
688
- if (val && typeof val === "string") {
689
- setSelectedUid(val);
690
- setImportResult(null);
691
- setImportProgress(null);
692
- }
1055
+ handleCollectionChange(val ? String(val) : "");
693
1056
  },
694
1057
  children: collections.map((col) => /* @__PURE__ */ jsxs(ComboboxOption, { value: col.uid, textValue: `${col.displayName} (${col.uid})`, children: [
695
1058
  col.displayName,
@@ -715,7 +1078,139 @@ function CsvManagerTab() {
715
1078
  ] }) }),
716
1079
  /* @__PURE__ */ jsxs(Box, { padding: 5, background: "neutral100", hasRadius: true, children: [
717
1080
  /* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h3", fontWeight: "bold", marginBottom: 2, children: "1. Export Data to CSV" }),
718
- /* @__PURE__ */ jsx(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." }),
1081
+ /* @__PURE__ */ jsx(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." }),
1082
+ selectedUid ? /* @__PURE__ */ jsxs(Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef" }, children: [
1083
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, children: [
1084
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral700", textTransform: "uppercase", children: "Search & Filter Collection Before Export" }),
1085
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
1086
+ countLoading ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral700", size: "S", children: "Calculating matching records..." }) : matchingCount !== null ? /* @__PURE__ */ jsxs(
1087
+ Badge,
1088
+ {
1089
+ backgroundColor: matchingCount > 0 ? "success100" : "warning100",
1090
+ textColor: matchingCount > 0 ? "success700" : "warning700",
1091
+ size: "S",
1092
+ children: [
1093
+ matchingCount.toLocaleString(),
1094
+ " matching records found"
1095
+ ]
1096
+ }
1097
+ ) : null,
1098
+ (searchAttribute || filterOperator !== "none" || entrySearch.trim()) && /* @__PURE__ */ jsx(
1099
+ Button,
1100
+ {
1101
+ variant: "ghost",
1102
+ size: "S",
1103
+ onClick: () => {
1104
+ setSearchAttribute("");
1105
+ setFilterOperator("none");
1106
+ setFilterQuery("");
1107
+ setEntrySearch("");
1108
+ },
1109
+ children: "Clear Filters"
1110
+ }
1111
+ )
1112
+ ] })
1113
+ ] }),
1114
+ /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
1115
+ /* @__PURE__ */ jsxs(Box, { style: { width: 280, minWidth: 230 }, children: [
1116
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Search Attribute" }),
1117
+ /* @__PURE__ */ jsx(
1118
+ Combobox,
1119
+ {
1120
+ autocomplete: { type: "list", filter: "contains" },
1121
+ placeholder: "Select Search Attribute...",
1122
+ value: searchAttribute || void 0,
1123
+ clearLabel: "Reset search attribute",
1124
+ onClear: () => setSearchAttribute(""),
1125
+ onFocus: (e) => {
1126
+ e.target.select();
1127
+ },
1128
+ onChange: (val) => {
1129
+ if (val && typeof val === "string" && val !== "__none__") {
1130
+ setSearchAttribute(val);
1131
+ }
1132
+ },
1133
+ children: (selectedCol?.attributes || []).map((attr) => {
1134
+ const rel = relationsMeta[attr];
1135
+ const depth = getAttrDepth(attr);
1136
+ const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
1137
+ const textValue = badgeText ? `${attr} ${badgeText}` : attr;
1138
+ return /* @__PURE__ */ jsx(ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
1139
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
1140
+ rel ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
1141
+ "relation ➔ ",
1142
+ rel.targetDisplayName
1143
+ ] }) : depth > 0 ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
1144
+ "L",
1145
+ depth,
1146
+ " component"
1147
+ ] }) : null
1148
+ ] }) }, `search_${attr}`);
1149
+ })
1150
+ },
1151
+ `csv-search-attr-${selectedUid}`
1152
+ )
1153
+ ] }),
1154
+ /* @__PURE__ */ jsxs(Box, { style: { width: 200, minWidth: 170 }, children: [
1155
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: searchAttribute ? `Condition for "${searchAttribute}"` : "Filter condition" }),
1156
+ /* @__PURE__ */ jsxs(
1157
+ SingleSelect,
1158
+ {
1159
+ value: filterOperator,
1160
+ disabled: !searchAttribute,
1161
+ onChange: (val) => setFilterOperator(String(val)),
1162
+ children: [
1163
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "none", children: "Show All (No Value Filter)" }),
1164
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "empty", children: "Is Empty or Null" }),
1165
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "not_empty", children: "Is Not Empty" }),
1166
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "equals", children: "Equals Exact Text" }),
1167
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "contains", children: "Contains Substring" }),
1168
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "starts_with", children: "Starts With" })
1169
+ ]
1170
+ }
1171
+ )
1172
+ ] }),
1173
+ (filterOperator === "equals" || filterOperator === "contains" || filterOperator === "starts_with") && /* @__PURE__ */ jsxs(Box, { style: { flex: 1, minWidth: 200 }, children: [
1174
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: searchAttribute ? `Value for "${searchAttribute}"` : "Value to match" }),
1175
+ searchAttribute && relationsMeta[searchAttribute] ? /* @__PURE__ */ jsx(
1176
+ Combobox,
1177
+ {
1178
+ autocomplete: { type: "list", filter: "contains" },
1179
+ placeholder: searchRelationOptionsLoading ? "Loading entities..." : `Search & pick ${relationsMeta[searchAttribute].targetDisplayName} or type text...`,
1180
+ value: filterQuery,
1181
+ onClear: () => setFilterQuery(""),
1182
+ onChange: (val) => {
1183
+ if (typeof val === "string") {
1184
+ setFilterQuery(val);
1185
+ }
1186
+ },
1187
+ onInputChange: (e) => {
1188
+ setFilterQuery(e.target.value);
1189
+ },
1190
+ children: searchRelationOptions.map((opt) => /* @__PURE__ */ jsx(ComboboxOption, { value: opt.label, textValue: opt.label, children: opt.label }, opt.documentId))
1191
+ }
1192
+ ) : /* @__PURE__ */ jsx(
1193
+ TextInput,
1194
+ {
1195
+ placeholder: "Type value to match...",
1196
+ value: filterQuery,
1197
+ onChange: (e) => setFilterQuery(e.target.value)
1198
+ }
1199
+ )
1200
+ ] }),
1201
+ /* @__PURE__ */ jsxs(Box, { style: { flex: 1, minWidth: 200 }, children: [
1202
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Full-text Entry Search" }),
1203
+ /* @__PURE__ */ jsx(
1204
+ TextInput,
1205
+ {
1206
+ placeholder: "Search title, name, or text across records...",
1207
+ value: entrySearch,
1208
+ onChange: (e) => setEntrySearch(e.target.value)
1209
+ }
1210
+ )
1211
+ ] })
1212
+ ] })
1213
+ ] }) : /* @__PURE__ */ jsx(Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef", textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Please select a Target Collection Type above to configure search filters and export data." }) }),
719
1214
  /* @__PURE__ */ jsxs(Flex, { gap: 4, wrap: "wrap", alignItems: "flex-end", marginTop: 3, children: [
720
1215
  /* @__PURE__ */ jsxs(Box, { style: { width: 220 }, children: [
721
1216
  /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", marginBottom: 1, display: "block", children: "Records to Download" }),
@@ -768,9 +1263,9 @@ function CsvManagerTab() {
768
1263
  variant: "default",
769
1264
  startIcon: /* @__PURE__ */ jsx(Download, {}),
770
1265
  onClick: handleExportCollection,
771
- disabled: !selectedUid || exportingCollection,
1266
+ disabled: !selectedUid || exportingCollection || matchingCount === 0,
772
1267
  loading: exportingCollection,
773
- children: exportingCollection ? "Preparing CSV download..." : `Export ${exportLimit === 0 ? "All" : exportLimit.toLocaleString()} ${selectedCol?.displayName || "Collection"} Records (.csv)`
1268
+ 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)`
774
1269
  }
775
1270
  ),
776
1271
  rules.length > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", style: { marginLeft: "auto" }, children: [
@@ -851,6 +1346,7 @@ function CsvManagerTab() {
851
1346
  type: "file",
852
1347
  accept: ".csv",
853
1348
  id: "csv-file-input",
1349
+ ref: fileInputRef,
854
1350
  style: { display: "none" },
855
1351
  onChange: handleFileUpload
856
1352
  }
@@ -1210,6 +1706,25 @@ function CsvManagerTab() {
1210
1706
  importResult.stats.errors.length - 10,
1211
1707
  " more error",
1212
1708
  importResult.stats.errors.length - 10 > 1 ? "s" : ""
1709
+ ] }),
1710
+ errorReport && errorReport.uid === selectedUid && (!importResult.batchId || errorReport.batchId === importResult.batchId) && errorReport.failedRows.length > 0 && /* @__PURE__ */ jsxs(Flex, { marginTop: 3, gap: 2, alignItems: "center", wrap: "wrap", children: [
1711
+ /* @__PURE__ */ jsxs(
1712
+ Button,
1713
+ {
1714
+ variant: "danger-light",
1715
+ size: "S",
1716
+ startIcon: /* @__PURE__ */ jsx(Download, {}),
1717
+ onClick: handleDownloadErrorCsv,
1718
+ children: [
1719
+ "Download Error CSV (",
1720
+ errorReport.failedRows.length.toLocaleString(),
1721
+ " failed row",
1722
+ errorReport.failedRows.length > 1 ? "s" : "",
1723
+ ")"
1724
+ ]
1725
+ }
1726
+ ),
1727
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Contains only failed rows with all original columns preserved and an Error column." })
1213
1728
  ] })
1214
1729
  ] }),
1215
1730
  importResult.stats.diffs && importResult.stats.diffs.length > 0 && /* @__PURE__ */ jsxs(Box, { marginTop: 3, padding: 3, background: "neutral0", hasRadius: true, style: { border: "1px solid #dcdce4" }, children: [
@@ -3731,24 +4246,8 @@ const BulkUpdater = () => {
3731
4246
  const MODELS_CACHE_KEY = "strapi_bulk_updater_models_cache";
3732
4247
  const LAST_ATTR_KEY = "strapi_bulk_updater_last_attr";
3733
4248
  const LAST_COLLECTION_KEY = "strapi_bulk_updater_last_collection";
3734
- const getInitialCollectionUid = () => {
3735
- try {
3736
- const stored = localStorage.getItem(LAST_COLLECTION_KEY);
3737
- if (stored) return stored;
3738
- } catch {
3739
- }
3740
- return "";
3741
- };
3742
- const [selectedCollectionUid, setSelectedCollectionUid] = useState(getInitialCollectionUid);
3743
- const getInitialAttribute = () => {
3744
- try {
3745
- const stored = localStorage.getItem(LAST_ATTR_KEY);
3746
- if (stored) return stored;
3747
- } catch {
3748
- }
3749
- return "";
3750
- };
3751
- const [selectedAttribute, setSelectedAttribute] = useState(getInitialAttribute);
4249
+ const [selectedCollectionUid, setSelectedCollectionUid] = useState("");
4250
+ const [selectedAttribute, setSelectedAttribute] = useState("");
3752
4251
  const [attributeValue, setAttributeValue] = useState("");
3753
4252
  const [selectedEntries, setSelectedEntries] = useState({});
3754
4253
  const [expandedDzEntries, setExpandedDzEntries] = useState({});
@@ -3822,6 +4321,7 @@ const BulkUpdater = () => {
3822
4321
  const [filterOperator, setFilterOperator] = useState("none");
3823
4322
  const [filterQuery, setFilterQuery] = useState("");
3824
4323
  const [entrySearch, setEntrySearch] = useState("");
4324
+ const abortControllersRef = useRef({});
3825
4325
  const [statusFilter, setStatusFilter] = useState("all");
3826
4326
  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());
3827
4327
  const [lastResults, setLastResults] = useState(null);
@@ -3933,28 +4433,14 @@ const BulkUpdater = () => {
3933
4433
  setAttributesMeta(data.attributesMeta);
3934
4434
  }
3935
4435
  let resolvedColUid = selectedCollectionUid;
3936
- let storedCol = null;
3937
- try {
3938
- storedCol = localStorage.getItem(LAST_COLLECTION_KEY);
3939
- } catch {
3940
- }
3941
- if (!resolvedColUid || !cols.some((c) => c.uid === resolvedColUid)) {
3942
- resolvedColUid = storedCol && cols.some((c) => c.uid === storedCol) ? storedCol : cols[0]?.uid || "";
4436
+ if (resolvedColUid && !cols.some((c) => c.uid === resolvedColUid)) {
4437
+ resolvedColUid = "";
3943
4438
  }
3944
4439
  setSelectedCollectionUid(resolvedColUid);
3945
- try {
3946
- if (resolvedColUid) localStorage.setItem(LAST_COLLECTION_KEY, resolvedColUid);
3947
- } catch {
3948
- }
3949
- const activeCol = cols.find((c) => c.uid === resolvedColUid) || cols[0];
4440
+ const activeCol = resolvedColUid ? cols.find((c) => c.uid === resolvedColUid) : null;
3950
4441
  const activeAttrs = activeCol?.attributes || [];
3951
4442
  setAttributes(activeAttrs);
3952
- let storedAttr = null;
3953
- try {
3954
- storedAttr = localStorage.getItem(LAST_ATTR_KEY);
3955
- } catch {
3956
- }
3957
- const resolvedAttr = storedAttr && activeAttrs.includes(storedAttr) ? storedAttr : selectedAttribute && activeAttrs.includes(selectedAttribute) ? selectedAttribute : "";
4443
+ const resolvedAttr = selectedAttribute && activeAttrs.includes(selectedAttribute) ? selectedAttribute : "";
3958
4444
  setSelectedAttribute(resolvedAttr);
3959
4445
  if (resolvedAttr && data.relationsMeta && data.relationsMeta[resolvedAttr]) {
3960
4446
  fetchRelationOptions(data.relationsMeta[resolvedAttr].targetUid);
@@ -4035,7 +4521,14 @@ const BulkUpdater = () => {
4035
4521
  params.set("sortField", sortField);
4036
4522
  params.set("sortOrder", sortOrder);
4037
4523
  }
4038
- const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`);
4524
+ if (abortControllersRef.current[colUid]) {
4525
+ abortControllersRef.current[colUid].abort();
4526
+ }
4527
+ const controller = new AbortController();
4528
+ abortControllersRef.current[colUid] = controller;
4529
+ const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
4530
+ signal: controller.signal
4531
+ });
4039
4532
  if (res.data && (res.data.success || res.data.entries !== void 0)) {
4040
4533
  const fetchedEntries = res.data.entries || [];
4041
4534
  const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
@@ -4177,6 +4670,9 @@ const BulkUpdater = () => {
4177
4670
  }, [collections, selectedCollectionUid]);
4178
4671
  const handleCollectionChange = (newUid) => {
4179
4672
  if (newUid === selectedCollectionUid) return;
4673
+ if (abortControllersRef.current) {
4674
+ Object.values(abortControllersRef.current).forEach((ctrl) => ctrl.abort());
4675
+ }
4180
4676
  setSelectedCollectionUid(newUid);
4181
4677
  try {
4182
4678
  if (newUid) {
@@ -4266,59 +4762,40 @@ const BulkUpdater = () => {
4266
4762
  });
4267
4763
  }, [depthFilteredAttributes, relationsMeta, selectedAttribute, componentDepth, attributesMeta]);
4268
4764
  const memoizedSearchComboboxOptions = useMemo(() => {
4269
- return /* @__PURE__ */ jsxs(Fragment, { children: [
4270
- /* @__PURE__ */ jsx(
4271
- ComboboxOption,
4272
- {
4273
- value: "__default__",
4274
- textValue: `Same as Update Attribute (${selectedAttribute || "None"}) default`,
4275
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
4276
- /* @__PURE__ */ jsxs(Typography, { variant: "omega", fontStyle: "italic", textColor: "neutral600", children: [
4277
- "-- Same as Update Attribute (",
4278
- selectedAttribute || "None",
4279
- ") --"
4280
- ] }),
4281
- /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral600", size: "S", children: "Default" })
4282
- ] })
4283
- }
4284
- ),
4285
- depthFilteredAttributes.map((attr) => {
4286
- const rel = relationsMeta[attr];
4287
- const depth = getAttrDepth(attr);
4288
- const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
4289
- const textValue = badgeText ? `${attr} ${badgeText}` : attr;
4290
- return /* @__PURE__ */ jsx(ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
4291
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
4292
- rel ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
4293
- "relation ➔ ",
4294
- rel.targetDisplayName
4295
- ] }) : depth > 0 ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
4296
- "L",
4297
- depth,
4298
- " component"
4299
- ] }) : null
4300
- ] }) }, `search_${attr}`);
4301
- })
4302
- ] });
4765
+ return /* @__PURE__ */ jsx(Fragment, { children: depthFilteredAttributes.map((attr) => {
4766
+ const rel = relationsMeta[attr];
4767
+ const depth = getAttrDepth(attr);
4768
+ const badgeText = rel ? `relation ${rel.targetDisplayName}` : depth > 0 ? `L${depth} component` : "";
4769
+ const textValue = badgeText ? `${attr} ${badgeText}` : attr;
4770
+ return /* @__PURE__ */ jsx(ComboboxOption, { value: attr, textValue, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", width: "100%", gap: 2, children: [
4771
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: attr === searchAttribute ? "bold" : "regular", children: attr }),
4772
+ rel ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", size: "S", children: [
4773
+ "relation ➔ ",
4774
+ rel.targetDisplayName
4775
+ ] }) : depth > 0 ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: depth === 1 ? "neutral150" : depth === 2 ? "primary100" : "secondary100", textColor: depth === 1 ? "neutral700" : depth === 2 ? "primary700" : "secondary700", size: "S", children: [
4776
+ "L",
4777
+ depth,
4778
+ " component"
4779
+ ] }) : null
4780
+ ] }) }, `search_${attr}`);
4781
+ }) });
4303
4782
  }, [depthFilteredAttributes, relationsMeta, searchAttribute, selectedAttribute, componentDepth, attributesMeta]);
4304
4783
  const handleSearchAttributeChange = (newAttr) => {
4305
4784
  const finalAttr = newAttr === "__default__" ? "" : newAttr;
4306
4785
  setSearchAttribute(finalAttr);
4307
- if (collections.length > 0) {
4308
- collections.forEach((col) => {
4309
- loadCollectionPage(
4310
- col.uid,
4311
- 1,
4312
- void 0,
4313
- void 0,
4314
- void 0,
4315
- filterOperator,
4316
- filterQuery,
4317
- entrySearch,
4318
- true,
4319
- finalAttr
4320
- );
4321
- });
4786
+ if (selectedCollectionUid) {
4787
+ loadCollectionPage(
4788
+ selectedCollectionUid,
4789
+ 1,
4790
+ void 0,
4791
+ void 0,
4792
+ void 0,
4793
+ filterOperator,
4794
+ filterQuery,
4795
+ entrySearch,
4796
+ true,
4797
+ finalAttr
4798
+ );
4322
4799
  }
4323
4800
  };
4324
4801
  const handleCollectionPageSizeChange = (colUid, newSize) => {
@@ -5414,7 +5891,7 @@ const BulkUpdater = () => {
5414
5891
  Combobox,
5415
5892
  {
5416
5893
  autocomplete: { type: "list", filter: "contains" },
5417
- placeholder: "Search Collection Type...",
5894
+ placeholder: "Select Collection Type...",
5418
5895
  value: selectedCollectionUid || void 0,
5419
5896
  clearLabel: "Clear collection selection",
5420
5897
  onClear: () => handleCollectionChange(""),
@@ -5515,8 +5992,8 @@ const BulkUpdater = () => {
5515
5992
  Combobox,
5516
5993
  {
5517
5994
  autocomplete: { type: "list", filter: "contains" },
5518
- placeholder: searchAttribute || `Same as Update (${selectedAttribute || "None"})`,
5519
- value: searchAttribute || "__default__",
5995
+ placeholder: "Select Search Attribute...",
5996
+ value: searchAttribute || void 0,
5520
5997
  clearLabel: "Reset search attribute",
5521
5998
  onClear: () => handleSearchAttributeChange(""),
5522
5999
  onFocus: (e) => {
@@ -5535,8 +6012,9 @@ const BulkUpdater = () => {
5535
6012
  /* @__PURE__ */ jsx(Box, { style: { width: 200, minWidth: 170 }, children: /* @__PURE__ */ jsxs(
5536
6013
  SingleSelect,
5537
6014
  {
5538
- label: effectiveSearchAttribute ? `Condition for "${effectiveSearchAttribute}"` : "Filter condition",
6015
+ label: searchAttribute ? `Condition for "${searchAttribute}"` : "Filter condition",
5539
6016
  value: filterOperator,
6017
+ disabled: !searchAttribute,
5540
6018
  onChange: (val) => setFilterOperator(String(val)),
5541
6019
  children: [
5542
6020
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "none", children: "Show All (No Value Filter)" }),
@@ -6304,7 +6782,7 @@ const BulkUpdater = () => {
6304
6782
  Combobox,
6305
6783
  {
6306
6784
  autocomplete: { type: "list", filter: "contains" },
6307
- placeholder: "Search attribute by name or relation...",
6785
+ placeholder: "Select Attribute to Update...",
6308
6786
  value: selectedAttribute || void 0,
6309
6787
  clearLabel: "Clear attribute selection",
6310
6788
  onClear: () => handleAttributeChange(""),
@@ -7709,4 +8187,4 @@ export {
7709
8187
  getSortOptionsForCollection,
7710
8188
  parseDynamicZonePath
7711
8189
  };
7712
- //# sourceMappingURL=BulkUpdater-B3m2_z--.mjs.map
8190
+ //# sourceMappingURL=BulkUpdater-Bj-8DvpD.mjs.map