Skip to content

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

Open
jvega190 wants to merge 2 commits intocraftercms:developfrom
jvega190:enhancement/8583
Open

[8583] Retrieve OOB controls/datasources from config file#4829
jvega190 wants to merge 2 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 now show custom icons for controls and data sources.
    • Dialogs respect configured controls/data sources, including 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: 8948d658-db39-4a08-ba44-d7680535f0bc

📥 Commits

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

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

Walkthrough

Refactors ContentTypeManagement to accept optional plugin descriptors, normalizes descriptor fields during config parsing, threads config-driven control/dataSource lookups through picker dialogs, updates picker filtering to respect config entries, and adds icon rendering based on config metadata.

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 and normalize optional descriptors (fields → lookup, default validations), fixed property access from dataSourcesdatasources, and expose parsed lookup to dialogs.
Control Dialogs
ui/app/src/components/ContentTypeManagement/components/PickControlDialog.tsx
Added optional configControls prop to PickControlDialogProps. Extended systemFieldsIds with forcehttps and uuid. Filter now excludes out-of-bounds control types unless present in configControls. Passes configControls into PickFieldDialog.
DataSource Dialogs
ui/app/src/components/ContentTypeManagement/components/PickDataSourceDialog.tsx
Added optional configDataSources prop and forward to PickFieldDialog. Filtering now excludes datasources not present in configDataSources (in addition to dataSourceExclusions).
Field Selection & Icons
ui/app/src/components/ContentTypeManagement/components/PickFieldDialog.tsx
Added optional configLookup prop to PickFieldDialogProps / SelectField. Threaded lookup into SelectField and render SystemIcon when configLookup[field.id].icon.id is present; otherwise use fallback icon. Imported LookupTable and SystemIcon.

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 description only contains a GitHub issue link without any explanation of what the PR does, changes, or why it's needed, failing to follow the template's requirement for a meaningful description. Replace the issue link with a proper description explaining what changes are made, why they're needed, and how the OOB controls/datasources retrieval works from the config file.
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 and specifically describes the main change: retrieving out-of-bounds controls and datasources from a config file, which matches the core functionality added 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
{configLookup?.[field.id]?.icon?.id ? (
<SystemIcon icon={configLookup[field.id].icon} />
) : (
<StarBorderIcon />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The Star was a placeholder on the mockup. If not configured, use the puzzle piece icon.

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.

2 participants