Skip to content

[8583] Retrieve OOB controls/datasources from config file#4829

Merged
sumerjabri merged 3 commits intocraftercms:developfrom
jvega190:enhancement/8583
Apr 22, 2026
Merged

[8583] Retrieve OOB controls/datasources from config file#4829
sumerjabri merged 3 commits intocraftercms:developfrom
jvega190:enhancement/8583

Conversation

@jvega190
Copy link
Copy Markdown
Member

@jvega190 jvega190 commented Mar 23, 2026

craftercms/craftercms#8583

Summary by CodeRabbit

  • Bug Fixes

    • Fixed data source configuration loading so configured data sources are recognized correctly.
  • New Features

    • Selection dialogs show custom icons for controls and data sources.
    • Dialogs respect configured controls/data sources, including previously out-of-bound items when present.
    • Added built-in fields: forcehttps and uuid.
    • Configuration now accepts controls and data sources with optional descriptor metadata.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 99403881-b4a8-4faf-b9cb-222fba0eff55

📥 Commits

Reviewing files that changed from the base of the PR and between 16252eb and beb008c.

📒 Files selected for processing (1)
  • ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx

Walkthrough

Make plugin descriptors optional in content-type config, normalize descriptor fields during parsing, read datasources from the corrected property, and thread parsed config lookups into picker dialogs to influence filtering and icon rendering.

Changes

Cohort / File(s) Summary
Configuration & Plugin Parsing
ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx
Made plugin descriptor optional in ContentTypeManagementConfig for controls and dataSources. Refactored parseConfigPlugins to accept/return items with descriptor?: DescriptorContentType, normalize descriptor.fields into a lookup and default validations to {}, renamed parsedControlsparsedPlugins, and fixed init to read contentTypesConfig.datasources when building config.dataSources.
Control Dialog
ui/app/src/components/ContentTypeManagement/components/PickControlDialog.tsx
Added optional configControls?: ContentTypeManagementConfig['controls'] prop. Extended systemFieldsIds with forcehttps and uuid. Filter now excludes out-of-bounds control types unless present in configControls. Forwards configControls to PickFieldDialog as configLookup.
DataSource Dialog
ui/app/src/components/ContentTypeManagement/components/PickDataSourceDialog.tsx
Added optional configDataSources?: ContentTypeManagementConfig['dataSources'] prop. typesFullList now filters out datasource types not present in configDataSources (plus existing exclusions). Forwards configDataSources to PickFieldDialog as configLookup.
Field Selection & Icons
ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx
Added optional configLookup prop to PickFieldDialogProps and SelectField. Threaded configLookup into SelectField; conditionally render SystemIcon when configLookup[field.id].icon.id exists, otherwise fallback to ComponentIcon. Added imports for LookupTable, SystemIcon, and ComponentIcon.

Sequence Diagram(s)

sequenceDiagram
    participant EditView as EditTypeView
    participant Parser as parseConfigPlugins
    participant Dialog as PickControl/PickDataSource
    participant FieldDlg as PickFieldDialog
    participant UI as SelectField

    EditView->>Parser: supply contentTypesConfig (controls, datasources)
    Parser-->>EditView: return parsed lookups (items with optional descriptor, fields normalized)
    EditView->>Dialog: open dialog with configControls/configDataSources (configLookup)
    Dialog->>FieldDlg: forward configLookup prop
    FieldDlg->>UI: provide configLookup to SelectField for filtering/icon rendering
    UI-->>FieldDlg: render list items with SystemIcon or fallback (ComponentIcon)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

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 PR description only provides a GitHub issue link without any substantive explanation of the changes, objectives, or implementation details required by the template. Expand the description to explain what changes were made, why they were needed, and how they address issue #8583. Include details about the config file structure and the OOB controls/datasources loading mechanism.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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 summarizes the main change: retrieving out-of-bounds controls and datasources from a config file, which aligns with the substantial modifications to config handling across multiple components.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

@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.

Actionable comments posted: 1

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/PickFieldDialog.tsx (1)

185-208: ⚠️ Potential issue | 🟠 Major

configLookup is not passed to PickFieldDialogBody.

The configLookup prop is defined in PickFieldDialogProps and received by PickFieldDialog, but it's not destructured or forwarded to PickFieldDialogBody. This means SelectField will never receive the config lookup, and custom icons will never render.

🐛 Proposed fix
 export function PickFieldDialog({
 	type,
 	title,
 	onInsert,
+	configLookup,
 	typesFullList,
 	typesCurrentList,
 	systemFieldsTitle,
 	systemFieldsIds,
 	...dialogProps
 }: PickFieldDialogProps) {
 	return (
 		<EnhancedDialog title={title} maxWidth="lg" {...dialogProps}>
 			<PickFieldDialogBody
 				{...dialogProps}
 				type={type}
 				onInsert={onInsert}
+				configLookup={configLookup}
 				typesFullList={typesFullList}
 				typesCurrentList={typesCurrentList}
 				systemFieldsTitle={systemFieldsTitle}
 				systemFieldsIds={systemFieldsIds}
 			/>
 		</EnhancedDialog>
 	);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx`
around lines 185 - 208, PickFieldDialog is receiving configLookup via
PickFieldDialogProps but does not destructure or forward it to
PickFieldDialogBody, so downstream SelectField never gets the lookup; update the
PickFieldDialog function signature to destructure configLookup from props and
pass configLookup into the PickFieldDialogBody props (alongside type, onInsert,
typesFullList, typesCurrentList, systemFieldsTitle, systemFieldsIds and
...dialogProps) so SelectField can use the configLookup to render custom icons.
🧹 Nitpick comments (1)
ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx (1)

47-47: Incomplete TODO comment.

The TODO comment appears truncated: // TODO: not a li. Please complete or clarify this comment to document the intended follow-up work.

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

In `@ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx`
at line 47, The inline TODO on the configLookup prop is truncated and unclear;
update the comment on the configLookup?: LookupTable<{ descriptor?:
DescriptorContentType; icon: { id: string }; id: string }>; declaration in
PickFieldDialog.tsx to a clear, actionable note describing the intended
follow-up (for example: "TODO: this is not a list — ensure LookupTable is keyed
by id (Record<string, ...>) or change the type to an array if a list is
intended; adjust usages and rename prop if necessary"), so future maintainers
understand whether to change the type to a keyed map, rename the prop, or update
call sites.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@ui/app/src/components/ContentTypeManagement/components/PickDataSourceDialog.tsx`:
- Around line 43-48: The array construction for typesFullList spreads
configDescriptors directly which can be undefined; update the build of
typesFullList (the const typesFullList expression) to guard the spread by
defaulting configDescriptors to an empty array (e.g., use configDescriptors ??
[]) so that ...(configDescriptors ?? []) is used instead of
...configDescriptors, ensuring no runtime error when configDescriptors is
null/undefined.

---

Outside diff comments:
In `@ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx`:
- Around line 185-208: PickFieldDialog is receiving configLookup via
PickFieldDialogProps but does not destructure or forward it to
PickFieldDialogBody, so downstream SelectField never gets the lookup; update the
PickFieldDialog function signature to destructure configLookup from props and
pass configLookup into the PickFieldDialogBody props (alongside type, onInsert,
typesFullList, typesCurrentList, systemFieldsTitle, systemFieldsIds and
...dialogProps) so SelectField can use the configLookup to render custom icons.

---

Nitpick comments:
In `@ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx`:
- Line 47: The inline TODO on the configLookup prop is truncated and unclear;
update the comment on the configLookup?: LookupTable<{ descriptor?:
DescriptorContentType; icon: { id: string }; id: string }>; declaration in
PickFieldDialog.tsx to a clear, actionable note describing the intended
follow-up (for example: "TODO: this is not a list — ensure LookupTable is keyed
by id (Record<string, ...>) or change the type to an array if a list is
intended; adjust usages and rename prop if necessary"), so future maintainers
understand whether to change the type to a keyed map, rename the prop, or update
call sites.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3fba6da4-577f-4dd9-a901-b4e7ec7c04df

📥 Commits

Reviewing files that changed from the base of the PR and between 6bb8c74 and f3fea4d.

📒 Files selected for processing (4)
  • ui/app/src/components/ContentTypeManagement/components/EditTypeView.tsx
  • ui/app/src/components/ContentTypeManagement/components/PickControlDialog.tsx
  • ui/app/src/components/ContentTypeManagement/components/PickDataSourceDialog.tsx
  • ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx

@jvega190
Copy link
Copy Markdown
Member Author

Outside diff range comment addresed

@jvega190 jvega190 marked this pull request as ready for review March 25, 2026 17:23
@jvega190 jvega190 requested a review from rart as a code owner March 25, 2026 17:23
Comment thread ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx Outdated
@jvega190 jvega190 requested a review from rart April 20, 2026 16:25
@sumerjabri sumerjabri merged commit d62f727 into craftercms:develop Apr 22, 2026
3 of 4 checks passed
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.

3 participants