Skip to content

[8416] Add Expired Date to the Content Type Editor Add Field's System types#4811

Open
jvega190 wants to merge 3 commits intocraftercms:developfrom
jvega190:enhancement/8416
Open

[8416] Add Expired Date to the Content Type Editor Add Field's System types#4811
jvega190 wants to merge 3 commits intocraftercms:developfrom
jvega190:enhancement/8416

Conversation

@jvega190
Copy link
Member

@jvega190 jvega190 commented Feb 19, 2026

craftercms/craftercms#8416

Summary by CodeRabbit

  • New Features

    • Added support for a new "expired-date" field control in content type management with configurable properties (date display, time display, timezone, read-only status) and constraints.
  • Improvements

    • Enhanced read-only status handling for form fields to properly respect field-level restrictions.
    • Improved dashboard data structure for expiring items.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Walkthrough

These changes introduce a new "expired-date" control to the Content Type Management system by registering it across descriptors, control maps, value retrievers and serializers, while updating field initialization logic and read-only status handling in the UI layer.

Changes

Cohort / File(s) Summary
Expired-Date Control Registration
ui/app/src/components/ContentTypeManagement/descriptors/controls/expiredDate.ts, ui/app/src/components/ContentTypeManagement/descriptors/controls/index.ts, ui/app/src/components/FormsEngine/lib/controlMap.ts, ui/app/src/components/FormsEngine/lib/valueRetrievers.ts, ui/app/src/components/FormsEngine/lib/valueSerializers.ts
New expired-date descriptor with internationalized metadata, properties, and constraints configuration; registered in control descriptors, control map (with lazy-loaded DateTime control), and value handling maps.
Content Type Management UI Updates
ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx, ui/app/src/components/ContentTypeManagement/components/PickControlDialog.tsx, ui/app/src/components/ContentTypeManagement/controls/Variable.tsx
Changed new field ID initialization from empty string to null; added 'expired-date' to system field IDs; integrated isFieldReadOnly utility into disabled field computation.
Dashboard Service
ui/app/src/services/dashboard.ts
Updated fetchExpiring to expose prepared item properties via new contentItem field instead of overwriting sandboxItem property.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • rart
  • sumerjabri
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description provides only a GitHub issue link without substantive details about the changes, objectives, or implementation approach required by the template. Expand the description with a ticket reference section explaining what changes are included and why they were made, following the provided template structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding an 'Expired Date' system type to the Content Type Editor's Add Field options, which aligns with the changeset's primary objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx (1)

1249-1260: ⚠️ Potential issue | 🟠 Major

Add 'expired-date': 'expired_dt' to systemFieldsIdsMap in utils.ts.

The expired-date field type is missing from systemFieldsIdsMap. Since the expiredDate descriptor marks the Variable Name field as readonly with defaultValue: 'expired_dt', new expired-date fields must initialize with a proper ID set via the map. Without this entry, systemFieldsIdsMap['expired-date'] returns undefined, and the ?? null fallback causes newly added fields to be saved with id: null, producing a broken content type definition. Add the mapping: 'expired-date': 'expired_dt' (or extract the appropriate variable name from the descriptor's metadata/defaultValue).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx`
around lines 1249 - 1260, Add the missing mapping for the expired-date system
field in the systemFieldsIdsMap so new fields get the correct ID; update
systemFieldsIdsMap to include the entry 'expired-date': 'expired_dt' (or use the
variable name used as defaultValue in the expiredDate descriptor) so
getNewFieldFromDescriptor will set id from systemFieldsIdsMap['expired-date']
instead of falling back to null.
🧹 Nitpick comments (1)
ui/app/src/components/ContentTypeManagement/descriptors/controls/expiredDate.ts (1)

89-111: Consider a future-oriented populateDateExp default for the content expiration field

With populate: true and populateDateExp: 'now', the expiration date auto-populates to the end of the current minute (since allowPastDate: false constrains the 'now' expression). This means content will expire almost immediately by default unless the content type editor changes the expression.

For a system field specifically designed to track content expiration, a more future-biased default expression (e.g., now+1year) would provide a safer starting point and reduce the risk of content type editors accidentally shipping with misconfigured expiration dates.

♻️ Suggested defaults

Option 1: Disable auto-population

  populate: {
    id: 'populate',
    type: 'boolean',
    name: defineMessage({ defaultMessage: 'Populated' }),
-   defaultValue: true,
+   defaultValue: false,
    validations: immutableEmptyObject
  },

Option 2: Use a future-oriented expression

  populateDateExp: {
    id: 'populateDateExp',
    type: 'date-time-expression-input',
    name: defineMessage({ defaultMessage: 'Populate Expression' }),
-   defaultValue: 'now',
+   defaultValue: 'now+1year',
    validations: {
      type: createValidation('type', 'dateTime')
    }
  },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@ui/app/src/components/ContentTypeManagement/descriptors/controls/expiredDate.ts`
around lines 89 - 111, The populateDateExp default currently set to 'now' causes
immediate expirations when populate is true and allowPastDate is false; change
the default in the control definition (populateDateExp) to a future-oriented
expression or disable auto-population: either set populateDateExp to a future
expression like 'now+1year' (or another agreed offset) or set populate: false by
default so the field is not auto-filled; update the descriptor for
populateDateExp and/or the populate property in expiredDate control to reflect
the chosen safer default (ensure validations using
createValidation('type','dateTime') remain intact).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx`:
- Around line 1249-1260: Add the missing mapping for the expired-date system
field in the systemFieldsIdsMap so new fields get the correct ID; update
systemFieldsIdsMap to include the entry 'expired-date': 'expired_dt' (or use the
variable name used as defaultValue in the expiredDate descriptor) so
getNewFieldFromDescriptor will set id from systemFieldsIdsMap['expired-date']
instead of falling back to null.

---

Nitpick comments:
In
`@ui/app/src/components/ContentTypeManagement/descriptors/controls/expiredDate.ts`:
- Around line 89-111: The populateDateExp default currently set to 'now' causes
immediate expirations when populate is true and allowPastDate is false; change
the default in the control definition (populateDateExp) to a future-oriented
expression or disable auto-population: either set populateDateExp to a future
expression like 'now+1year' (or another agreed offset) or set populate: false by
default so the field is not auto-filled; update the descriptor for
populateDateExp and/or the populate property in expiredDate control to reflect
the chosen safer default (ensure validations using
createValidation('type','dateTime') remain intact).

@jvega190 jvega190 marked this pull request as ready for review February 19, 2026 16:58
@jvega190 jvega190 requested a review from rart as a code owner February 19, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments