strapi-plugin-bulk-updater 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -354,6 +354,86 @@ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
354
354
  textColor: "neutral700"
355
355
  };
356
356
  }
357
+ const EMPTY_SEARCH_FILTER = {
358
+ searchAttribute: "",
359
+ filterOperator: "none",
360
+ filterQuery: "",
361
+ entrySearch: "",
362
+ statusFilter: "all",
363
+ useRegex: false,
364
+ regexPattern: ""
365
+ };
366
+ function areSearchFiltersEqual(a, b, options = {}) {
367
+ if ((a.searchAttribute || "") !== (b.searchAttribute || "") || (a.filterOperator || "none") !== (b.filterOperator || "none") || (a.filterQuery || "") !== (b.filterQuery || "") || (a.entrySearch || "") !== (b.entrySearch || "")) {
368
+ return false;
369
+ }
370
+ if (options.includeWorkspaceExtras) {
371
+ if ((a.statusFilter || "all") !== (b.statusFilter || "all") || Boolean(a.useRegex) !== Boolean(b.useRegex) || (a.regexPattern || "") !== (b.regexPattern || "")) {
372
+ return false;
373
+ }
374
+ }
375
+ return true;
376
+ }
377
+ function isSearchFilterActive(filter, selectedTargetAttribute = "") {
378
+ const hasAttrFilter = Boolean(filter.searchAttribute && filter.searchAttribute !== selectedTargetAttribute);
379
+ const hasOp = filter.filterOperator !== "none" && (["empty", "not_empty"].includes(filter.filterOperator) || Boolean((filter.filterQuery || "").trim()));
380
+ const hasSearchText = Boolean((filter.entrySearch || "").trim());
381
+ const hasStatus = Boolean(filter.statusFilter && filter.statusFilter !== "all");
382
+ const hasRegex = Boolean(filter.useRegex && (filter.regexPattern || "").trim());
383
+ return hasAttrFilter || hasOp || hasSearchText || hasStatus || hasRegex;
384
+ }
385
+ function buildEntriesQueryParams(options) {
386
+ const { page, pageSize, filter, selectedAttribute, sortField, sortOrder, includeAttributeEvenIfSame } = options;
387
+ const params = new URLSearchParams({
388
+ page: String(page),
389
+ pageSize: String(pageSize)
390
+ });
391
+ if (includeAttributeEvenIfSame) {
392
+ if (filter.searchAttribute) {
393
+ params.set("attribute", filter.searchAttribute);
394
+ params.set("searchAttribute", filter.searchAttribute);
395
+ }
396
+ } else {
397
+ if (selectedAttribute) params.set("attribute", selectedAttribute);
398
+ if (filter.searchAttribute && filter.searchAttribute !== selectedAttribute) {
399
+ params.set("searchAttribute", filter.searchAttribute);
400
+ }
401
+ }
402
+ if (filter.filterOperator && filter.filterOperator !== "none") {
403
+ params.set("filterOperator", filter.filterOperator);
404
+ if (filter.filterQuery) {
405
+ params.set("filterQuery", filter.filterQuery);
406
+ }
407
+ }
408
+ if (filter.entrySearch && filter.entrySearch.trim()) {
409
+ params.set("search", filter.entrySearch.trim());
410
+ }
411
+ if (sortField) {
412
+ params.set("sortField", sortField);
413
+ if (sortOrder) params.set("sortOrder", sortOrder);
414
+ }
415
+ return params;
416
+ }
417
+ function buildCsvExportQueryParams(options) {
418
+ const { limit, filter } = options;
419
+ const queryParams = new URLSearchParams();
420
+ if (limit && limit > 0) {
421
+ queryParams.set("limit", String(limit));
422
+ }
423
+ if (filter.searchAttribute) {
424
+ queryParams.set("searchAttribute", filter.searchAttribute);
425
+ }
426
+ if (filter.filterOperator && filter.filterOperator !== "none") {
427
+ queryParams.set("filterOperator", filter.filterOperator);
428
+ if (filter.filterQuery) {
429
+ queryParams.set("filterQuery", filter.filterQuery);
430
+ }
431
+ }
432
+ if (filter.entrySearch && filter.entrySearch.trim()) {
433
+ queryParams.set("search", filter.entrySearch.trim());
434
+ }
435
+ return queryParams;
436
+ }
357
437
  function CsvManagerTab() {
358
438
  const { get, post } = admin.useFetchClient();
359
439
  const { toggleNotification } = admin.useNotification();
@@ -370,8 +450,17 @@ function CsvManagerTab() {
370
450
  const [filterOperator, setFilterOperator] = React.useState("none");
371
451
  const [filterQuery, setFilterQuery] = React.useState("");
372
452
  const [entrySearch, setEntrySearch] = React.useState("");
453
+ const [appliedFilter, setAppliedFilter] = React.useState(EMPTY_SEARCH_FILTER);
454
+ const appliedFilterRef = React.useRef(EMPTY_SEARCH_FILTER);
373
455
  const [matchingCount, setMatchingCount] = React.useState(null);
374
456
  const [countLoading, setCountLoading] = React.useState(false);
457
+ const draftFilter = {
458
+ searchAttribute,
459
+ filterOperator,
460
+ filterQuery,
461
+ entrySearch
462
+ };
463
+ const hasPendingFilterChanges = !areSearchFiltersEqual(draftFilter, appliedFilter);
375
464
  const [searchRelationOptions, setSearchRelationOptions] = React.useState([]);
376
465
  const [searchRelationOptionsLoading, setSearchRelationOptionsLoading] = React.useState(false);
377
466
  const [exportLimit, setExportLimit] = React.useState(0);
@@ -491,53 +580,78 @@ function CsvManagerTab() {
491
580
  setFilterOperator("none");
492
581
  setFilterQuery("");
493
582
  setEntrySearch("");
583
+ appliedFilterRef.current = EMPTY_SEARCH_FILTER;
584
+ setAppliedFilter(EMPTY_SEARCH_FILTER);
494
585
  setMatchingCount(null);
495
586
  setCountLoading(Boolean(newUid));
496
587
  };
497
- React.useEffect(() => {
498
- if (!selectedUid) {
588
+ const executeMatchingCountSearch = async (targetUid, filterToApply) => {
589
+ if (!targetUid) {
499
590
  setMatchingCount(null);
500
591
  setCountLoading(false);
501
592
  return;
502
593
  }
594
+ if (countAbortControllerRef.current) {
595
+ countAbortControllerRef.current.abort();
596
+ }
597
+ const controller = new AbortController();
598
+ countAbortControllerRef.current = controller;
503
599
  setCountLoading(true);
504
- const timer = setTimeout(async () => {
505
- if (countAbortControllerRef.current) {
506
- countAbortControllerRef.current.abort();
600
+ try {
601
+ const params = buildEntriesQueryParams({
602
+ page: 1,
603
+ pageSize: 1,
604
+ filter: filterToApply,
605
+ includeAttributeEvenIfSame: true
606
+ });
607
+ const res = await get(`/bulk-updater/collections/${targetUid}/entries?${params.toString()}`, {
608
+ signal: controller.signal
609
+ });
610
+ if (countAbortControllerRef.current !== controller) return;
611
+ if (res.data) {
612
+ const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
613
+ setMatchingCount(total);
507
614
  }
508
- const controller = new AbortController();
509
- countAbortControllerRef.current = controller;
510
- try {
511
- const params = new URLSearchParams({
512
- page: "1",
513
- pageSize: "1"
514
- });
515
- if (searchAttribute) {
516
- params.set("attribute", searchAttribute);
517
- params.set("searchAttribute", searchAttribute);
518
- }
519
- if (filterOperator && filterOperator !== "none") {
520
- params.set("filterOperator", filterOperator);
521
- if (filterQuery) params.set("filterQuery", filterQuery);
522
- }
523
- if (entrySearch && entrySearch.trim()) {
524
- params.set("search", entrySearch.trim());
525
- }
526
- const res = await get(`/bulk-updater/collections/${selectedUid}/entries?${params.toString()}`, {
527
- signal: controller.signal
528
- });
529
- if (res.data) {
530
- const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
531
- setMatchingCount(total);
532
- }
533
- } catch (err) {
534
- if (!ValidationRulesTab.isAbortError(err)) ;
535
- } finally {
615
+ } catch (err) {
616
+ if (!ValidationRulesTab.isAbortError(err)) ;
617
+ } finally {
618
+ if (countAbortControllerRef.current === controller) {
536
619
  setCountLoading(false);
537
620
  }
538
- }, 300);
539
- return () => clearTimeout(timer);
540
- }, [selectedUid, searchAttribute, filterOperator, filterQuery, entrySearch]);
621
+ }
622
+ };
623
+ React.useEffect(() => {
624
+ if (!selectedUid) {
625
+ setMatchingCount(null);
626
+ setCountLoading(false);
627
+ return;
628
+ }
629
+ executeMatchingCountSearch(selectedUid, appliedFilterRef.current);
630
+ }, [selectedUid]);
631
+ const handleApplySearch = () => {
632
+ const nextApplied = {
633
+ searchAttribute,
634
+ filterOperator,
635
+ filterQuery,
636
+ entrySearch
637
+ };
638
+ appliedFilterRef.current = nextApplied;
639
+ setAppliedFilter(nextApplied);
640
+ if (selectedUid) {
641
+ executeMatchingCountSearch(selectedUid, nextApplied);
642
+ }
643
+ };
644
+ const handleClearFilters = () => {
645
+ setSearchAttribute("");
646
+ setFilterOperator("none");
647
+ setFilterQuery("");
648
+ setEntrySearch("");
649
+ appliedFilterRef.current = EMPTY_SEARCH_FILTER;
650
+ setAppliedFilter(EMPTY_SEARCH_FILTER);
651
+ if (selectedUid) {
652
+ executeMatchingCountSearch(selectedUid, EMPTY_SEARCH_FILTER);
653
+ }
654
+ };
541
655
  const fetchAndEnrichEntries = async (colUid, cols = collections, batches = pendingBatches) => {
542
656
  if (!colUid) return [];
543
657
  try {
@@ -620,16 +734,10 @@ function CsvManagerTab() {
620
734
  if (!selectedUid || exportingCollection) return;
621
735
  try {
622
736
  setExportingCollection(true);
623
- const queryParams = new URLSearchParams();
624
- if (exportLimit > 0) queryParams.set("limit", String(exportLimit));
625
- if (searchAttribute) queryParams.set("searchAttribute", searchAttribute);
626
- if (filterOperator && filterOperator !== "none") {
627
- queryParams.set("filterOperator", filterOperator);
628
- if (filterQuery) queryParams.set("filterQuery", filterQuery);
629
- }
630
- if (entrySearch && entrySearch.trim()) {
631
- queryParams.set("search", entrySearch.trim());
632
- }
737
+ const queryParams = buildCsvExportQueryParams({
738
+ limit: exportLimit,
739
+ filter: appliedFilterRef.current
740
+ });
633
741
  const res = await get(`/bulk-updater/csv/export/${selectedUid}?${queryParams.toString()}`);
634
742
  const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
635
743
  const filename = res.data?.filename || `${selectedUid.split(".").pop()}_export.csv`;
@@ -1099,20 +1207,8 @@ function CsvManagerTab() {
1099
1207
  ]
1100
1208
  }
1101
1209
  ) : null,
1102
- (searchAttribute || filterOperator !== "none" || entrySearch.trim()) && /* @__PURE__ */ jsxRuntime.jsx(
1103
- designSystem.Button,
1104
- {
1105
- variant: "ghost",
1106
- size: "S",
1107
- onClick: () => {
1108
- setSearchAttribute("");
1109
- setFilterOperator("none");
1110
- setFilterQuery("");
1111
- setEntrySearch("");
1112
- },
1113
- children: "Clear Filters"
1114
- }
1115
- )
1210
+ hasPendingFilterChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", size: "S", children: "Filters modified — click Search to apply" }),
1211
+ (searchAttribute || filterOperator !== "none" || entrySearch.trim() || hasPendingFilterChanges) && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: handleClearFilters, children: "Clear Filters" })
1116
1212
  ] })
1117
1213
  ] }),
1118
1214
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
@@ -1198,7 +1294,13 @@ function CsvManagerTab() {
1198
1294
  {
1199
1295
  placeholder: "Type value to match...",
1200
1296
  value: filterQuery,
1201
- onChange: (e) => setFilterQuery(e.target.value)
1297
+ onChange: (e) => setFilterQuery(e.target.value),
1298
+ onKeyDown: (e) => {
1299
+ if (e.key === "Enter") {
1300
+ e.preventDefault();
1301
+ handleApplySearch();
1302
+ }
1303
+ }
1202
1304
  }
1203
1305
  )
1204
1306
  ] }),
@@ -1209,10 +1311,27 @@ function CsvManagerTab() {
1209
1311
  {
1210
1312
  placeholder: "Search title, name, or text across records...",
1211
1313
  value: entrySearch,
1212
- onChange: (e) => setEntrySearch(e.target.value)
1314
+ onChange: (e) => setEntrySearch(e.target.value),
1315
+ onKeyDown: (e) => {
1316
+ if (e.key === "Enter") {
1317
+ e.preventDefault();
1318
+ handleApplySearch();
1319
+ }
1320
+ }
1213
1321
  }
1214
1322
  )
1215
- ] })
1323
+ ] }),
1324
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
1325
+ designSystem.Button,
1326
+ {
1327
+ variant: hasPendingFilterChanges ? "default" : "secondary",
1328
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}),
1329
+ onClick: handleApplySearch,
1330
+ loading: countLoading,
1331
+ disabled: !selectedUid || countLoading,
1332
+ children: "Search"
1333
+ }
1334
+ ) })
1216
1335
  ] })
1217
1336
  ] }) : /* @__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." }) }),
1218
1337
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", alignItems: "flex-end", marginTop: 3, children: [
@@ -5748,7 +5867,27 @@ const BulkUpdater = () => {
5748
5867
  const [entrySearch, setEntrySearch] = React.useState("");
5749
5868
  const abortControllersRef = React.useRef({});
5750
5869
  const [statusFilter, setStatusFilter] = React.useState("all");
5751
- 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());
5870
+ const [appliedSearchFilter, setAppliedSearchFilter] = React.useState(EMPTY_SEARCH_FILTER);
5871
+ const appliedSearchFilterRef = React.useRef(EMPTY_SEARCH_FILTER);
5872
+ const draftSearchFilter = React.useMemo(
5873
+ () => ({
5874
+ searchAttribute,
5875
+ filterOperator,
5876
+ filterQuery,
5877
+ entrySearch,
5878
+ statusFilter,
5879
+ useRegex,
5880
+ regexPattern
5881
+ }),
5882
+ [searchAttribute, filterOperator, filterQuery, entrySearch, statusFilter, useRegex, regexPattern]
5883
+ );
5884
+ const hasPendingFilterChanges = React.useMemo(
5885
+ () => !areSearchFiltersEqual(draftSearchFilter, appliedSearchFilter, {
5886
+ includeWorkspaceExtras: true
5887
+ }),
5888
+ [draftSearchFilter, appliedSearchFilter]
5889
+ );
5890
+ const isFilterActive = isSearchFilterActive(appliedSearchFilter, selectedAttribute);
5752
5891
  const [lastResults, setLastResults] = React.useState(null);
5753
5892
  const [updateSummary, setUpdateSummary] = React.useState(null);
5754
5893
  const [collectionPages, setCollectionPages] = React.useState({});
@@ -5915,10 +6054,11 @@ const BulkUpdater = () => {
5915
6054
  const currentSort = collectionSorts[colUid] || { field: "createdAt", order: "desc" };
5916
6055
  const sortField = customSortField !== void 0 ? customSortField : currentSort.field;
5917
6056
  const sortOrder = customSortOrder !== void 0 ? customSortOrder : currentSort.order;
5918
- const op = overrideFilterOp !== void 0 ? overrideFilterOp : filterOperator;
5919
- const q = overrideFilterQuery !== void 0 ? overrideFilterQuery : filterQuery;
5920
- const s = overrideEntrySearch !== void 0 ? overrideEntrySearch : entrySearch;
5921
- const searchAttr = overrideSearchAttr !== void 0 ? overrideSearchAttr : searchAttribute;
6057
+ const appliedSnapshot = appliedSearchFilterRef.current;
6058
+ const op = overrideFilterOp !== void 0 ? overrideFilterOp : appliedSnapshot.filterOperator;
6059
+ const q = overrideFilterQuery !== void 0 ? overrideFilterQuery : appliedSnapshot.filterQuery;
6060
+ const s = overrideEntrySearch !== void 0 ? overrideEntrySearch : appliedSnapshot.entrySearch;
6061
+ const searchAttr = overrideSearchAttr !== void 0 ? overrideSearchAttr : appliedSnapshot.searchAttribute;
5922
6062
  setCollectionPages((prev) => ({
5923
6063
  ...prev,
5924
6064
  [colUid]: {
@@ -5926,34 +6066,30 @@ const BulkUpdater = () => {
5926
6066
  loading: true
5927
6067
  }
5928
6068
  }));
6069
+ let controller = null;
5929
6070
  try {
5930
- const params = new URLSearchParams({
5931
- page: String(targetPage),
5932
- pageSize: String(size)
6071
+ const params = buildEntriesQueryParams({
6072
+ page: targetPage,
6073
+ pageSize: size,
6074
+ filter: {
6075
+ searchAttribute: searchAttr,
6076
+ filterOperator: op,
6077
+ filterQuery: q,
6078
+ entrySearch: s
6079
+ },
6080
+ selectedAttribute,
6081
+ sortField,
6082
+ sortOrder
5933
6083
  });
5934
- if (selectedAttribute) params.set("attribute", selectedAttribute);
5935
- if (searchAttr && searchAttr !== selectedAttribute) {
5936
- params.set("searchAttribute", searchAttr);
5937
- }
5938
- if (op && op !== "none") {
5939
- params.set("filterOperator", op);
5940
- if (q) params.set("filterQuery", q);
5941
- }
5942
- if (s && s.trim()) {
5943
- params.set("search", s.trim());
5944
- }
5945
- if (sortField) {
5946
- params.set("sortField", sortField);
5947
- params.set("sortOrder", sortOrder);
5948
- }
5949
6084
  if (abortControllersRef.current[colUid]) {
5950
6085
  abortControllersRef.current[colUid].abort();
5951
6086
  }
5952
- const controller = new AbortController();
6087
+ controller = new AbortController();
5953
6088
  abortControllersRef.current[colUid] = controller;
5954
6089
  const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
5955
6090
  signal: controller.signal
5956
6091
  });
6092
+ if (abortControllersRef.current[colUid] !== controller) return;
5957
6093
  if (res.data && (res.data.success || res.data.entries !== void 0)) {
5958
6094
  const fetchedEntries = res.data.entries || [];
5959
6095
  const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
@@ -6001,13 +6137,15 @@ const BulkUpdater = () => {
6001
6137
  message: `Failed to load entries for ${colUid}: ${err?.message || "Network error"}`
6002
6138
  });
6003
6139
  }
6004
- setCollectionPages((prev) => ({
6005
- ...prev,
6006
- [colUid]: {
6007
- ...prev[colUid] || {},
6008
- loading: false
6009
- }
6010
- }));
6140
+ if (abortControllersRef.current[colUid] === controller) {
6141
+ setCollectionPages((prev) => ({
6142
+ ...prev,
6143
+ [colUid]: {
6144
+ ...prev[colUid] || {},
6145
+ loading: false
6146
+ }
6147
+ }));
6148
+ }
6011
6149
  }
6012
6150
  };
6013
6151
  const fetchAuditHistory = async () => {
@@ -6070,44 +6208,46 @@ const BulkUpdater = () => {
6070
6208
  fetchPendingBatches();
6071
6209
  }
6072
6210
  }, [activeTab]);
6073
- const isInitialFilterMount = React.useRef(true);
6074
- React.useEffect(() => {
6075
- if (isInitialFilterMount.current) {
6076
- isInitialFilterMount.current = false;
6077
- return;
6078
- }
6079
- const timer = setTimeout(() => {
6080
- if (selectedCollectionUid) {
6081
- const isFilterActiveNow = Boolean(searchAttribute && searchAttribute !== selectedAttribute) || filterOperator !== "none" && (["empty", "not_empty"].includes(filterOperator) || Boolean(filterQuery.trim())) || Boolean(entrySearch.trim()) || Boolean(useRegex && regexPattern.trim());
6082
- if (isFilterActiveNow) {
6083
- if (gridEditMode) {
6084
- setSelectedEntries((prev) => {
6085
- const retained = {};
6086
- Object.keys(gridEdits).forEach((k) => {
6087
- if (prev[k]) retained[k] = true;
6088
- });
6089
- return retained;
6090
- });
6091
- } else {
6092
- setSelectedEntries({});
6093
- }
6094
- }
6095
- loadCollectionPage(
6096
- selectedCollectionUid,
6097
- 1,
6098
- void 0,
6099
- void 0,
6100
- void 0,
6101
- filterOperator,
6102
- filterQuery,
6103
- entrySearch,
6104
- true,
6105
- searchAttribute
6106
- );
6211
+ const handleApplySearch = () => {
6212
+ const nextApplied = {
6213
+ searchAttribute,
6214
+ filterOperator,
6215
+ filterQuery,
6216
+ entrySearch,
6217
+ statusFilter,
6218
+ useRegex,
6219
+ regexPattern
6220
+ };
6221
+ appliedSearchFilterRef.current = nextApplied;
6222
+ setAppliedSearchFilter(nextApplied);
6223
+ if (!selectedCollectionUid) return;
6224
+ const isFilterActiveNow = isSearchFilterActive(nextApplied, selectedAttribute);
6225
+ if (isFilterActiveNow) {
6226
+ if (gridEditMode) {
6227
+ setSelectedEntries((prev) => {
6228
+ const retained = {};
6229
+ Object.keys(gridEdits).forEach((k) => {
6230
+ if (prev[k]) retained[k] = true;
6231
+ });
6232
+ return retained;
6233
+ });
6234
+ } else {
6235
+ setSelectedEntries({});
6107
6236
  }
6108
- }, 350);
6109
- return () => clearTimeout(timer);
6110
- }, [selectedCollectionUid, searchAttribute, filterOperator, filterQuery, entrySearch, useRegex, regexPattern]);
6237
+ }
6238
+ loadCollectionPage(
6239
+ selectedCollectionUid,
6240
+ 1,
6241
+ void 0,
6242
+ void 0,
6243
+ void 0,
6244
+ nextApplied.filterOperator,
6245
+ nextApplied.filterQuery,
6246
+ nextApplied.entrySearch,
6247
+ true,
6248
+ nextApplied.searchAttribute
6249
+ );
6250
+ };
6111
6251
  const KEY_SEP = "@@@";
6112
6252
  const selectedCol = React.useMemo(() => {
6113
6253
  if (!collections.length || !selectedCollectionUid) return null;
@@ -6248,6 +6388,12 @@ const BulkUpdater = () => {
6248
6388
  }
6249
6389
  setSelectedEntries({});
6250
6390
  setSearchAttribute("");
6391
+ const nextAppliedOnColSwitch = {
6392
+ ...appliedSearchFilterRef.current,
6393
+ searchAttribute: ""
6394
+ };
6395
+ appliedSearchFilterRef.current = nextAppliedOnColSwitch;
6396
+ setAppliedSearchFilter(nextAppliedOnColSwitch);
6251
6397
  if (!newUid || !newUid.trim()) {
6252
6398
  setAttributes([]);
6253
6399
  setSelectedAttribute("");
@@ -6267,7 +6413,18 @@ const BulkUpdater = () => {
6267
6413
  setSelectedRelationDocId("");
6268
6414
  setAttributeValue("");
6269
6415
  }
6270
- loadCollectionPage(newUid, 1, void 0, void 0, void 0, filterOperator, filterQuery, entrySearch, true, "");
6416
+ loadCollectionPage(
6417
+ newUid,
6418
+ 1,
6419
+ void 0,
6420
+ void 0,
6421
+ void 0,
6422
+ nextAppliedOnColSwitch.filterOperator,
6423
+ nextAppliedOnColSwitch.filterQuery,
6424
+ nextAppliedOnColSwitch.entrySearch,
6425
+ true,
6426
+ ""
6427
+ );
6271
6428
  };
6272
6429
  const handleAttributeChange = (newAttr) => {
6273
6430
  if (newAttr !== selectedAttribute) {
@@ -6355,20 +6512,6 @@ const BulkUpdater = () => {
6355
6512
  const handleSearchAttributeChange = (newAttr) => {
6356
6513
  const finalAttr = newAttr === "__default__" ? "" : newAttr;
6357
6514
  setSearchAttribute(finalAttr);
6358
- if (selectedCollectionUid) {
6359
- loadCollectionPage(
6360
- selectedCollectionUid,
6361
- 1,
6362
- void 0,
6363
- void 0,
6364
- void 0,
6365
- filterOperator,
6366
- filterQuery,
6367
- entrySearch,
6368
- true,
6369
- finalAttr
6370
- );
6371
- }
6372
6515
  };
6373
6516
  const handleCollectionPageSizeChange = (colUid, newSize) => {
6374
6517
  const capped = Math.min(500, Math.max(1, newSize));
@@ -6424,9 +6567,13 @@ const BulkUpdater = () => {
6424
6567
  };
6425
6568
  const entryMatchesFilter = (entry, attr) => {
6426
6569
  const matches = getAllNestedValues(entry, attr);
6427
- if (useRegex && regexPattern.trim()) {
6570
+ const activeOp = appliedSearchFilter.filterOperator;
6571
+ const activeQuery = appliedSearchFilter.filterQuery || "";
6572
+ const activeUseRegex = Boolean(appliedSearchFilter.useRegex);
6573
+ const activeRegexPattern = appliedSearchFilter.regexPattern || "";
6574
+ if (activeUseRegex && activeRegexPattern.trim()) {
6428
6575
  try {
6429
- const regex = new RegExp(regexPattern, "i");
6576
+ const regex = new RegExp(activeRegexPattern, "i");
6430
6577
  const anyRegexMatch = matches.some((m) => regex.test(formatDisplayValue(m.value)));
6431
6578
  if (!anyRegexMatch) {
6432
6579
  return false;
@@ -6434,22 +6581,22 @@ const BulkUpdater = () => {
6434
6581
  } catch {
6435
6582
  }
6436
6583
  }
6437
- if (filterOperator === "none") return true;
6584
+ if (activeOp === "none") return true;
6438
6585
  if (matches.length === 0) {
6439
- return filterOperator === "empty";
6586
+ return activeOp === "empty";
6440
6587
  }
6441
6588
  const checkMatch = (val) => {
6442
6589
  const displayStr = formatDisplayValue(val);
6443
6590
  const isValEmpty = val === void 0 || val === null || Array.isArray(val) && val.length === 0 || displayStr.trim() === "" || displayStr.trim().toLowerCase() === "(not set)" || displayStr.trim().toLowerCase() === "(empty / not set)" || displayStr.trim().toLowerCase() === "(empty / unlinked)";
6444
- if (filterOperator === "empty") return isValEmpty;
6445
- if (filterOperator === "not_empty") return !isValEmpty;
6591
+ if (activeOp === "empty") return isValEmpty;
6592
+ if (activeOp === "not_empty") return !isValEmpty;
6446
6593
  if (isValEmpty) return false;
6447
- const q = filterQuery.trim().toLowerCase();
6594
+ const q = activeQuery.trim().toLowerCase();
6448
6595
  if (!q) return true;
6449
6596
  const testString = (str) => {
6450
6597
  if (str === void 0 || str === null) return false;
6451
6598
  const s = String(str).trim().toLowerCase();
6452
- switch (filterOperator) {
6599
+ switch (activeOp) {
6453
6600
  case "equals":
6454
6601
  return s === q;
6455
6602
  case "contains":
@@ -6480,7 +6627,7 @@ const BulkUpdater = () => {
6480
6627
  }
6481
6628
  return testString(displayStr);
6482
6629
  };
6483
- if (filterOperator === "empty") {
6630
+ if (activeOp === "empty") {
6484
6631
  return matches.every((m) => checkMatch(m.value));
6485
6632
  }
6486
6633
  return matches.some((m) => checkMatch(m.value));
@@ -6491,10 +6638,11 @@ const BulkUpdater = () => {
6491
6638
  if (gridEditMode && gridFilterModifiedOnly) {
6492
6639
  raw = raw.filter((entry) => Boolean(gridEdits[`${col.uid}${KEY_SEP}${entry.documentId}`]));
6493
6640
  }
6494
- if (statusFilter === "all") return raw;
6641
+ const activeStatus = appliedSearchFilter.statusFilter || "all";
6642
+ if (activeStatus === "all") return raw;
6495
6643
  return raw.filter((entry) => {
6496
6644
  const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
6497
- return lifecycle.status === statusFilter;
6645
+ return lifecycle.status === activeStatus;
6498
6646
  });
6499
6647
  };
6500
6648
  const matchingEntriesCount = React__default.default.useMemo(() => {
@@ -6504,7 +6652,7 @@ const BulkUpdater = () => {
6504
6652
  count += getVisibleEntries(col).length;
6505
6653
  });
6506
6654
  return count;
6507
- }, [filteredCollections, collectionPages, isFilterActive, statusFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
6655
+ }, [filteredCollections, collectionPages, isFilterActive, appliedSearchFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
6508
6656
  const selectAllMatching = () => {
6509
6657
  const updated = { ...selectedEntries };
6510
6658
  filteredCollections.forEach((col) => {
@@ -6532,6 +6680,8 @@ const BulkUpdater = () => {
6532
6680
  setEntrySearch("");
6533
6681
  setStatusFilter("all");
6534
6682
  setRegexPattern("");
6683
+ appliedSearchFilterRef.current = EMPTY_SEARCH_FILTER;
6684
+ setAppliedSearchFilter(EMPTY_SEARCH_FILTER);
6535
6685
  if (gridEditMode) {
6536
6686
  setSelectedEntries((prev) => {
6537
6687
  const retained = {};
@@ -6931,17 +7081,18 @@ const BulkUpdater = () => {
6931
7081
  await fetchModels();
6932
7082
  await fetchAuditHistory();
6933
7083
  if (selectedCollectionUid) {
7084
+ const appliedNow = appliedSearchFilterRef.current;
6934
7085
  loadCollectionPage(
6935
7086
  selectedCollectionUid,
6936
7087
  collectionPages[selectedCollectionUid]?.page || 1,
6937
7088
  void 0,
6938
7089
  void 0,
6939
7090
  void 0,
6940
- filterOperator,
6941
- filterQuery,
6942
- entrySearch,
7091
+ appliedNow.filterOperator,
7092
+ appliedNow.filterQuery,
7093
+ appliedNow.entrySearch,
6943
7094
  false,
6944
- searchAttribute
7095
+ appliedNow.searchAttribute
6945
7096
  );
6946
7097
  }
6947
7098
  }
@@ -7641,14 +7792,15 @@ const BulkUpdater = () => {
7641
7792
  matchingEntriesCount === 1 ? "entry" : "entries",
7642
7793
  " found in database"
7643
7794
  ] }),
7644
- searchAttribute && searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
7795
+ appliedSearchFilter.searchAttribute && appliedSearchFilter.searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
7645
7796
  "Searching by: ",
7646
- searchAttribute,
7797
+ appliedSearchFilter.searchAttribute,
7647
7798
  " → Target to update: ",
7648
7799
  selectedAttribute
7649
- ] })
7800
+ ] }),
7801
+ hasPendingFilterChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Filters modified — click Search to apply" })
7650
7802
  ] }),
7651
- isFilterActive && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
7803
+ (isFilterActive || hasPendingFilterChanges || Boolean(searchAttribute) || filterOperator !== "none" || Boolean(entrySearch.trim()) || statusFilter !== "all" || Boolean(useRegex && regexPattern.trim())) && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
7652
7804
  ] }),
7653
7805
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
7654
7806
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { children: [
@@ -7717,7 +7869,13 @@ const BulkUpdater = () => {
7717
7869
  label: effectiveSearchAttribute ? `Value for "${effectiveSearchAttribute}"` : "Value to match",
7718
7870
  placeholder: "Type value to match...",
7719
7871
  value: filterQuery,
7720
- onChange: (e) => setFilterQuery(e.target.value)
7872
+ onChange: (e) => setFilterQuery(e.target.value),
7873
+ onKeyDown: (e) => {
7874
+ if (e.key === "Enter") {
7875
+ e.preventDefault();
7876
+ handleApplySearch();
7877
+ }
7878
+ }
7721
7879
  }
7722
7880
  ) }),
7723
7881
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: 180 }, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -7726,7 +7884,13 @@ const BulkUpdater = () => {
7726
7884
  label: "Full-text Entry Search",
7727
7885
  placeholder: "Search title, name, or text across records...",
7728
7886
  value: entrySearch,
7729
- onChange: (e) => setEntrySearch(e.target.value)
7887
+ onChange: (e) => setEntrySearch(e.target.value),
7888
+ onKeyDown: (e) => {
7889
+ if (e.key === "Enter") {
7890
+ e.preventDefault();
7891
+ handleApplySearch();
7892
+ }
7893
+ }
7730
7894
  }
7731
7895
  ) }),
7732
7896
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: 190, minWidth: 160 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7745,6 +7909,17 @@ const BulkUpdater = () => {
7745
7909
  ]
7746
7910
  }
7747
7911
  ) }),
7912
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
7913
+ designSystem.Button,
7914
+ {
7915
+ variant: hasPendingFilterChanges ? "default" : "secondary",
7916
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}),
7917
+ onClick: handleApplySearch,
7918
+ loading: Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
7919
+ disabled: !selectedCollectionUid || Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
7920
+ children: "Search"
7921
+ }
7922
+ ) }),
7748
7923
  isFilterActive && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
7749
7924
  /* @__PURE__ */ jsxRuntime.jsx(
7750
7925
  designSystem.Button,
@@ -9953,4 +10128,4 @@ exports.getNestedValue = getNestedValue;
9953
10128
  exports.getPropertyValue = getPropertyValue;
9954
10129
  exports.getSortOptionsForCollection = getSortOptionsForCollection;
9955
10130
  exports.parseDynamicZonePath = parseDynamicZonePath;
9956
- //# sourceMappingURL=BulkUpdater-D12SUhTd.js.map
10131
+ //# sourceMappingURL=BulkUpdater-DTJLdJJy.js.map