mirror of
https://github.com/xtr-dev/payload-feature-flags.git
synced 2025-12-10 02:43:25 +00:00
Implement proper Payload CMS DefaultTemplate layout integration
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 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
useConfig,
|
useConfig,
|
||||||
useTheme
|
useTheme
|
||||||
} from '@payloadcms/ui'
|
} from '@payloadcms/ui'
|
||||||
|
import { DefaultTemplate } from '@payloadcms/next/templates'
|
||||||
|
|
||||||
interface FeatureFlag {
|
interface FeatureFlag {
|
||||||
id: string
|
id: string
|
||||||
@@ -24,11 +25,17 @@ interface FeatureFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface FeatureFlagsViewProps {
|
interface FeatureFlagsViewProps {
|
||||||
// Props that would typically be passed from the parent view
|
i18n?: any
|
||||||
[key: string]: 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 { config } = useConfig()
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
const [flags, setFlags] = useState<FeatureFlag[]>([])
|
const [flags, setFlags] = useState<FeatureFlag[]>([])
|
||||||
@@ -197,28 +204,7 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => {
|
|||||||
|
|
||||||
const styles = getThemeStyles()
|
const styles = getThemeStyles()
|
||||||
|
|
||||||
if (loading) {
|
const FeatureFlagsContent = () => (
|
||||||
return (
|
|
||||||
<div style={{
|
|
||||||
padding: '2rem',
|
|
||||||
textAlign: 'center',
|
|
||||||
minHeight: '400px',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center'
|
|
||||||
}}>
|
|
||||||
<div style={{ fontSize: '1.125rem', color: styles.textMuted }}>Loading feature flags...</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{
|
|
||||||
padding: '0',
|
|
||||||
height: '100%',
|
|
||||||
overflow: 'auto'
|
|
||||||
}}>
|
|
||||||
{/* Content Container */}
|
|
||||||
<div style={{
|
<div style={{
|
||||||
padding: '2rem',
|
padding: '2rem',
|
||||||
maxWidth: '100%'
|
maxWidth: '100%'
|
||||||
@@ -242,6 +228,19 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<div style={{
|
||||||
|
padding: '2rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
minHeight: '400px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center'
|
||||||
|
}}>
|
||||||
|
<div style={{ fontSize: '1.125rem', color: styles.textMuted }}>Loading feature flags...</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
{/* Success/Error Messages */}
|
{/* Success/Error Messages */}
|
||||||
{successMessage && (
|
{successMessage && (
|
||||||
<div style={{
|
<div style={{
|
||||||
@@ -619,8 +618,24 @@ const FeatureFlagsViewComponent = (props: FeatureFlagsViewProps = {}) => {
|
|||||||
<span style={{ fontWeight: '600' }}>A/B Tests:</span> {flags.filter(f => f && f.variants && f.variants.length > 0).length}
|
<span style={{ fontWeight: '600' }}>A/B Tests:</span> {flags.filter(f => f && f.variants && f.variants.length > 0).length}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DefaultTemplate
|
||||||
|
i18n={props.i18n}
|
||||||
|
locale={props.locale}
|
||||||
|
params={props.params}
|
||||||
|
payload={props.payload}
|
||||||
|
permissions={props.permissions}
|
||||||
|
searchParams={props.searchParams}
|
||||||
|
user={props.user}
|
||||||
|
visibleEntities={props.visibleEntities}
|
||||||
|
>
|
||||||
|
<FeatureFlagsContent />
|
||||||
|
</DefaultTemplate>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user