strapi-plugin-bulk-updater 1.5.2 → 1.5.4

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.
@@ -2857,6 +2857,91 @@ const CheckerReviewModal = ({
2857
2857
  }
2858
2858
  );
2859
2859
  };
2860
+ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
2861
+ const isPendingApproval = pendingBatches.some((b) => {
2862
+ if (b.status !== "pending_approval") return false;
2863
+ const targets = b.payload?.selectedEntries || [];
2864
+ return targets.some((t) => entry.documentId && t.documentId === entry.documentId || String(t.documentId) === String(entry.id));
2865
+ });
2866
+ if (isPendingApproval) {
2867
+ return {
2868
+ status: "pending_review",
2869
+ label: "Pending Review",
2870
+ badgeColor: "warning100",
2871
+ textColor: "warning700"
2872
+ };
2873
+ }
2874
+ if (col && col.draftAndPublish === false) {
2875
+ return {
2876
+ status: "published",
2877
+ label: "Published",
2878
+ badgeColor: "success100",
2879
+ textColor: "success700"
2880
+ };
2881
+ }
2882
+ if (entry.status === "modified") {
2883
+ return {
2884
+ status: "modified",
2885
+ label: "Modified",
2886
+ badgeColor: "primary100",
2887
+ textColor: "primary700"
2888
+ };
2889
+ }
2890
+ if (entry.status === "draft") {
2891
+ return {
2892
+ status: "draft",
2893
+ label: "Draft",
2894
+ badgeColor: "neutral150",
2895
+ textColor: "neutral700"
2896
+ };
2897
+ }
2898
+ if (entry.status === "published") {
2899
+ return {
2900
+ status: "published",
2901
+ label: "Published",
2902
+ badgeColor: "success100",
2903
+ textColor: "success700"
2904
+ };
2905
+ }
2906
+ if (entry.status === "unknown") {
2907
+ return {
2908
+ status: "unknown",
2909
+ label: "Unknown",
2910
+ badgeColor: "neutral200",
2911
+ textColor: "neutral600"
2912
+ };
2913
+ }
2914
+ if (!entry.documentId && !entry.id && !entry.slug) {
2915
+ return {
2916
+ status: "unknown",
2917
+ label: "Unknown",
2918
+ badgeColor: "neutral200",
2919
+ textColor: "neutral600"
2920
+ };
2921
+ }
2922
+ if (entry.publishedAt) {
2923
+ if (entry.updatedAt && new Date(entry.updatedAt).getTime() > new Date(entry.publishedAt).getTime()) {
2924
+ return {
2925
+ status: "modified",
2926
+ label: "Modified",
2927
+ badgeColor: "primary100",
2928
+ textColor: "primary700"
2929
+ };
2930
+ }
2931
+ return {
2932
+ status: "published",
2933
+ label: "Published",
2934
+ badgeColor: "success100",
2935
+ textColor: "success700"
2936
+ };
2937
+ }
2938
+ return {
2939
+ status: "draft",
2940
+ label: "Draft",
2941
+ badgeColor: "neutral150",
2942
+ textColor: "neutral700"
2943
+ };
2944
+ }
2860
2945
  function parseDynamicZonePath(path) {
2861
2946
  if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
2862
2947
  const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
@@ -3269,67 +3354,6 @@ function formatDisplayValue(val) {
3269
3354
  }
3270
3355
  return String(val);
3271
3356
  }
3272
- function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
3273
- const isPendingApproval = pendingBatches.some((b) => {
3274
- if (b.status !== "pending_approval") return false;
3275
- const targets = b.payload?.selectedEntries || [];
3276
- return targets.some((t) => t.documentId === entry.documentId || String(t.documentId) === String(entry.id));
3277
- });
3278
- if (isPendingApproval) {
3279
- return {
3280
- status: "pending_review",
3281
- label: "Pending Review",
3282
- badgeColor: "warning100",
3283
- textColor: "warning700"
3284
- };
3285
- }
3286
- if (entry.status === "modified") {
3287
- return {
3288
- status: "modified",
3289
- label: "Modified",
3290
- badgeColor: "primary100",
3291
- textColor: "primary700"
3292
- };
3293
- }
3294
- if (entry.status === "draft") {
3295
- return {
3296
- status: "draft",
3297
- label: "Draft",
3298
- badgeColor: "neutral150",
3299
- textColor: "neutral700"
3300
- };
3301
- }
3302
- if (entry.status === "published") {
3303
- return {
3304
- status: "published",
3305
- label: "Published",
3306
- badgeColor: "success100",
3307
- textColor: "success700"
3308
- };
3309
- }
3310
- if (col && col.draftAndPublish === false) {
3311
- return {
3312
- status: "published",
3313
- label: "Published",
3314
- badgeColor: "success100",
3315
- textColor: "success700"
3316
- };
3317
- }
3318
- if (entry.publishedAt) {
3319
- return {
3320
- status: "published",
3321
- label: "Published",
3322
- badgeColor: "success100",
3323
- textColor: "success700"
3324
- };
3325
- }
3326
- return {
3327
- status: "draft",
3328
- label: "Draft",
3329
- badgeColor: "neutral150",
3330
- textColor: "neutral700"
3331
- };
3332
- }
3333
3357
  function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "") {
3334
3358
  switch (colDef.key) {
3335
3359
  case "select":
@@ -3736,12 +3760,23 @@ const BulkUpdater = () => {
3736
3760
  cols.forEach((col) => {
3737
3761
  const total = col.totalEntries !== void 0 ? col.totalEntries : col.entries ? col.entries.length : 0;
3738
3762
  const initialPageSize = col.isSingleType ? 1 : 10;
3763
+ const previewSlice = (col.entries || []).slice(0, initialPageSize).map((entry) => {
3764
+ if (!entry.status) {
3765
+ const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
3766
+ return {
3767
+ ...entry,
3768
+ status: lifecycle.status,
3769
+ publishedAt: entry.publishedAt ?? (lifecycle.status === "published" ? entry.updatedAt || null : null)
3770
+ };
3771
+ }
3772
+ return entry;
3773
+ });
3739
3774
  pages[col.uid] = {
3740
3775
  page: 1,
3741
3776
  pageSize: initialPageSize,
3742
3777
  total,
3743
3778
  pageCount: col.isSingleType ? 1 : Math.ceil(total / initialPageSize) || 1,
3744
- entries: (col.entries || []).slice(0, initialPageSize),
3779
+ entries: previewSlice,
3745
3780
  loading: false
3746
3781
  };
3747
3782
  initialVisibility[col.uid] = true;
@@ -3863,6 +3898,18 @@ const BulkUpdater = () => {
3863
3898
  const pageSizeNum = res.data.pagination?.pageSize ?? size ?? defaultPageSize;
3864
3899
  const totalNum = res.data.pagination?.total !== void 0 ? res.data.pagination.total : fetchedEntries.length;
3865
3900
  const pageCountNum = res.data.pagination?.pageCount ?? Math.max(1, Math.ceil(totalNum / pageSizeNum));
3901
+ const col = collections.find((c) => c.uid === colUid) || null;
3902
+ const enrichedEntries = fetchedEntries.map((entry) => {
3903
+ if (!entry.status) {
3904
+ const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
3905
+ return {
3906
+ ...entry,
3907
+ status: lifecycle.status,
3908
+ publishedAt: entry.publishedAt ?? (lifecycle.status === "published" ? entry.updatedAt || null : null)
3909
+ };
3910
+ }
3911
+ return entry;
3912
+ });
3866
3913
  setCollectionPages((prev) => ({
3867
3914
  ...prev,
3868
3915
  [colUid]: {
@@ -3870,7 +3917,7 @@ const BulkUpdater = () => {
3870
3917
  pageSize: pageSizeNum,
3871
3918
  total: totalNum,
3872
3919
  pageCount: pageCountNum,
3873
- entries: fetchedEntries,
3920
+ entries: enrichedEntries,
3874
3921
  loading: false
3875
3922
  }
3876
3923
  }));
@@ -3993,7 +4040,6 @@ const BulkUpdater = () => {
3993
4040
  }
3994
4041
  setSelectedEntries({});
3995
4042
  setSearchAttribute("");
3996
- setSearchAttributeSearch("");
3997
4043
  const targetCol = collections.find((c) => c.uid === newUid);
3998
4044
  const colAttrs = targetCol?.attributes || [];
3999
4045
  setAttributes(colAttrs);
@@ -4344,6 +4390,7 @@ const BulkUpdater = () => {
4344
4390
  let modified = 0;
4345
4391
  let draft = 0;
4346
4392
  let pendingReview = 0;
4393
+ let unknown = 0;
4347
4394
  Object.keys(selectedEntries).forEach((key) => {
4348
4395
  if (!selectedEntries[key]) return;
4349
4396
  const parts = key.split(KEY_SEP);
@@ -4359,18 +4406,20 @@ const BulkUpdater = () => {
4359
4406
  else if (status === "modified") modified++;
4360
4407
  else if (status === "draft") draft++;
4361
4408
  else if (status === "pending_review") pendingReview++;
4409
+ else unknown++;
4362
4410
  } else {
4363
4411
  draft++;
4364
4412
  }
4365
4413
  });
4366
- const unreviewedCount = draft + modified + pendingReview;
4414
+ const unreviewedCount = draft + modified + pendingReview + unknown;
4367
4415
  return {
4368
4416
  published,
4369
4417
  modified,
4370
4418
  draft,
4371
4419
  pendingReview,
4420
+ unknown,
4372
4421
  unreviewedCount,
4373
- total: published + modified + draft + pendingReview
4422
+ total: published + modified + draft + pendingReview + unknown
4374
4423
  };
4375
4424
  }, [selectedEntries, collections, collectionPages, pendingBatches]);
4376
4425
  const handleOpenConfirmModal = () => {
@@ -5377,7 +5426,8 @@ const BulkUpdater = () => {
5377
5426
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "pending_review", children: "Pending Review (Due)" }),
5378
5427
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "draft", children: "Draft" }),
5379
5428
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "published", children: "Published" }),
5380
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "modified", children: "Modified" })
5429
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "modified", children: "Modified" }),
5430
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "unknown", children: "Unknown" })
5381
5431
  ]
5382
5432
  }
5383
5433
  ) }),
@@ -7467,4 +7517,4 @@ exports.getNestedValue = getNestedValue;
7467
7517
  exports.getPropertyValue = getPropertyValue;
7468
7518
  exports.getSortOptionsForCollection = getSortOptionsForCollection;
7469
7519
  exports.parseDynamicZonePath = parseDynamicZonePath;
7470
- //# sourceMappingURL=BulkUpdater-JZW74XM4.js.map
7520
+ //# sourceMappingURL=BulkUpdater-BTWJq8UX.js.map