From 98cab95411b93e0767c327aba99ebc6153b68678 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 3 Oct 2025 16:16:42 +0200 Subject: [PATCH] Implement proper Payload CMS DefaultTemplate layout integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Layout Implementation: - Fixed import to use DefaultTemplate from '@payloadcms/next/templates' - Added proper template props interface with i18n, locale, payload, etc. - Restructured component to use DefaultTemplate wrapper correctly - Created FeatureFlagsContent as child component for template Template Structure: - Component now receives standard Payload admin view props - DefaultTemplate provides proper admin layout with sidebar navigation - All template props (i18n, locale, params, payload, permissions, etc.) are passed through - Maintains theme integration and responsive design within admin layout The feature flags dashboard now properly integrates with Payload's admin layout system, including the navigation sidebar and standard admin styling, while preserving all spreadsheet functionality and inline editing capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/views/FeatureFlagsView.tsx | 161 ++++++++++++++++++--------------- 1 file changed, 88 insertions(+), 73 deletions(-) diff --git a/src/views/FeatureFlagsView.tsx b/src/views/FeatureFlagsView.tsx index 7c2afba..ee592b3 100644 --- a/src/views/FeatureFlagsView.tsx +++ b/src/views/FeatureFlagsView.tsx @@ -4,6 +4,7 @@ import { useConfig, useTheme } from '@payloadcms/ui' +import { DefaultTemplate } from '@payloadcms/next/templates' interface FeatureFlag { id: string @@ -24,11 +25,17 @@ interface FeatureFlag { } interface FeatureFlagsViewProps { - // Props that would typically be passed from the parent view - [key: string]: any + i18n?: any + locale?: any + params?: any + payload?: any + permissions?: any + searchParams?: any + user?: any + visibleEntities?: any } -const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => { +const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps) => { const { config } = useConfig() const { theme } = useTheme() const [flags, setFlags] = useState([]) @@ -197,80 +204,72 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => { const styles = getThemeStyles() - if (loading) { - return ( -
-
Loading feature flags...
-
- ) - } - - return ( + const FeatureFlagsContent = () => (
- {/* Content Container */} -
- {/* Header */} -
-

- Feature Flags Dashboard -

-

- Manage all feature flags in a spreadsheet view with inline editing capabilities -

-
- - {/* Success/Error Messages */} - {successMessage && ( -
+

- {successMessage} -

- )} - - {error && ( -
+

- Error: {error} + Manage all feature flags in a spreadsheet view with inline editing capabilities +

+
+ + {loading ? ( +
+
Loading feature flags...
- )} + ) : ( + <> + {/* Success/Error Messages */} + {successMessage && ( +
+ {successMessage} +
+ )} + + {error && ( +
+ Error: {error} +
+ )} {/* Controls */}
{ A/B Tests: {flags.filter(f => f && f.variants && f.variants.length > 0).length}
-
+ + )} ) + + return ( + + + + ) } export const FeatureFlagsView = memo(FeatureFlagsViewComponent)