Skip to content

Commit 105a542

Browse files
More Cms blocks (#214)
* chore: update dependencies and improve type definitions - Updated various dependencies in package.json to their latest versions for better performance and security. - Removed the `readOnlyWriteOnlyBehavior` option from the OpenAPI TypeScript configuration. - Enhanced type definitions in sdk.gen.ts and types.gen.ts to support new blog and comment features, including CRUD operations for blogs and tags. * feat: enhance admin functionality with comments and CMS features - Added new menu items for Comments and CMS in the admin panel. - Updated AdminIndex to utilize ApplicationConfigurationDto for improved type safety. - Enhanced API request handling with error logging and timeout management. - Introduced new query constants for comments and pages. - Improved app configuration hook to handle undefined responses gracefully. - Expanded granted policies to include CRUD operations for comments and pages. * feat: enhance admin navigation and CMS management - Added support for nested submenus in AdminMenus for improved navigation. - Updated the CMS page layout to utilize cards for better content management. - Removed the deprecated Comments page component. - Enhanced the mobile and desktop side navigation bars to handle submenu expansion and active states. * feat: implement comprehensive admin dashboard with user and system information - Redesigned AdminIndex to display a modern admin dashboard featuring user profile details, system status, and quick action buttons. - Introduced user profile card with authentication status, email verification, and role management. - Added system information cards for multi-tenancy status, current tenant details, and session information. - Enhanced layout with responsive design and improved user experience through card components and badges. * feat: enhance side navigation with submenu toggle functionality - Added onClick handler to links in both mobile and desktop side navigation bars to toggle submenus when applicable. - Improved user experience by ensuring submenu expansion is handled correctly based on the current state. * feat: enhance CMS page creation and editing experience - Introduced a rich text editor for content input with HTML support and keyboard shortcuts for formatting. - Implemented auto-slug generation based on the page title. - Added draft saving functionality to localStorage with alerts for unsaved changes. - Enhanced form validation and error handling for better user feedback. - Redesigned the layout to include tabs for content, advanced settings, and preview, improving user navigation and experience. * feat: add menu management features to admin panel - Introduced new menu item for managing menu items in the admin navigation. - Added query constants for fetching menu items and individual menu items, enhancing data retrieval capabilities. * feat: enhance page management with new view functionality and prose styling - Added a new view action in the PageList component for navigating to individual page views. - Introduced prose styling in globals.css for improved content presentation across pages. - Updated the usePages hook to include a new method for fetching pages by slug, enhancing data retrieval capabilities. * feat: enhance comment functionality and page view component - Removed unused policy checks in AddComment component for cleaner code. - Improved error handling in AddComment to provide user feedback on comment creation. - Updated PageView component to include comments section and added documentation for custom styles and scripts. - Introduced new query constant for fetching public comments, enhancing data retrieval capabilities. * feat: update client types and enhance form handling - Refactored client types to improve type safety by replacing readable/writable types with unified types across components. - Updated form handling in various components to utilize new input types, enhancing consistency and reducing errors. - Improved error handling in hooks to allow for undefined responses, ensuring better resilience in data fetching. - Enhanced comment and page management components to align with updated type definitions, improving overall functionality. * feat: refactor permission handling across CMS components - Replaced hardcoded permission strings with a centralized Permissions enum for better maintainability and consistency. - Updated various components including page, menu, and comment management to utilize the new Permissions structure. - Enhanced user experience by ensuring proper permission checks for actions like creating, updating, and deleting pages and menus. - Improved code readability and reduced duplication by standardizing permission checks across the application. * docs: Enhance documentation with comprehensive guides and improvements Co-authored-by: antosubash <antosubash@live.com> * Add comprehensive documentation for authentication, admin interface, and deployment Co-authored-by: antosubash <antosubash@live.com> * Add comprehensive CRUD tutorial for product management with auth Co-authored-by: antosubash <antosubash@live.com> * CMS page working puck working wip: puck Refactor CMS page builder and add Puck error suppression Replaces the HTML/Puck tabbed editor with a full-screen Puck visual editor, introduces quick-add component actions, and ensures all content blocks have unique IDs. Adds a WelcomeBlock component and integrates global and local error suppression for React key warnings from Puck. Updates Puck config, styles for a full-screen editor experience, and refactors editor components for improved reliability and UX. Refactor Puck editor components and enhance content handling This update replaces the existing Puck editor with a more robust version that includes a fallback mechanism for rendering. It improves the handling of Puck data by ensuring all components have unique keys and supports nested components through a new Slots API. The configuration has been updated to include new components like Flexbox, Grid, and TemplateBlock, enhancing layout flexibility. Additionally, error suppression for Puck-related warnings has been refined, improving the overall user experience in the CMS page builder. Enhance PuckEditorFallback with improved error handling and data processing This update introduces robust error handling in the PuckEditorFallback component, allowing for better management of various data formats, including JSON and HTML. It adds state management for error messages and integrates error feedback during component operations such as adding, removing, and updating components. The overall user experience is improved by providing clear error messages and ensuring that the editor remains functional even when data processing encounters issues. Enhance EditPage component with improved data handling and user experience This update refines the EditPage component by implementing better data fetching and error handling mechanisms. It introduces forced refetching of page data on mount and invalidates cache to ensure fresh data is loaded. Additionally, it enhances the user interface with loading indicators and retry options for failed data loads. The content handling has been improved to support both JSON and HTML formats, ensuring compatibility with the Puck editor. Debug logging has been added for better traceability during development. Refactor Puck editor components and remove deprecated files This update refines the Puck editor by replacing the PuckEditorFallback with a more robust PuckEditor that features a modular layout using resizable panels. It enhances the user experience with improved error handling, loading states, and a clear structure for component management. Additionally, deprecated files related to previous editor versions have been removed to streamline the codebase. The README has been updated to reflect the new architecture and features, ensuring clarity for future development. Refactor Puck editor and enhance data validation This update refines the Puck editor by introducing a new data validation mechanism to ensure the integrity of Puck data structures. It replaces deprecated components and improves error handling during data processing. The editor now features a more modular layout with custom header actions, enhancing user experience. Additionally, the default content structure for new pages has been streamlined, and loading states have been improved for better feedback during operations. Enhance EditPage and CreatePage components with improved content handling and loading states This update introduces a new state management for form loading in the EditPage component, ensuring a smoother user experience during data fetching. It enhances content processing by refining how JSON and HTML formats are handled, including better default content structures. Additionally, the CreatePage component has been updated to improve logging and error handling during form submissions. The PuckEditor has also been optimized for immediate data updates without debouncing, enhancing responsiveness during content editing. Refactor EditPage and CreatePage components for improved content handling and UI consistency This update enhances the EditPage and CreatePage components by refining content processing and ensuring a consistent user interface. It introduces better handling of Puck data structures, including default content setups and improved error logging. The layout has been streamlined for better readability, and loading states have been optimized for a smoother user experience during data operations. Additionally, the PuckEditor has been updated to ensure proper data structure validation and immediate updates during content changes. clean up Refactor EditPage component to streamline data fetching and cache management. Removed unnecessary refetching logic and improved cache invalidation on successful updates. Updated usePage hook to enhance data freshness and logging. Remove PageViewPage component and update navigation in PageList to reflect new URL structure. Enhance PageViewPage with improved error handling and user experience - Refactored PageViewPage to include better loading states and error handling for various scenarios, including connection errors and page not found. - Introduced a retry mechanism for failed data fetching attempts, enhancing user experience during network issues. - Added an ErrorBoundary component to gracefully handle rendering errors and provide user feedback. - Updated the AddComment component to improve submission handling and error messaging, ensuring a smoother commenting experience. - Enhanced PageComments component with better error display and retry options for loading comments. - Improved hooks for data fetching to ensure valid responses and added retry logic for better resilience. * Refactor EditPage and CreatePage components to improve content handling and remove debug logging This update enhances the EditPage and CreatePage components by streamlining content processing and ensuring a consistent user interface. It removes unnecessary debug logging to clean up the codebase and improve performance. Additionally, it refines how Puck data structures are handled, ensuring better default content setups and improved error handling during form submissions. * Enhance Puck configuration and editor components with new block support and improved UI This update expands the Puck configuration to include additional components such as ButtonBlock, ContainerBlock, and others, enhancing layout flexibility. The PuckEditor has been redesigned with a new header for better branding and user experience, incorporating a publish button with status indicators. Error handling has been improved, and the overall UI has been refined for a more cohesive editing experience. Additionally, the utility functions have been updated to validate new block types, ensuring robust data handling. * Refactor AdminIndex and CMS page components for improved data handling and error management This update enhances the AdminIndex component by adding fallback data for application configuration and improving date formatting with error handling. The EditPage and CreatePage components have been streamlined by removing the publish state, optimizing content submission, and enhancing user feedback during form operations. Additionally, various Puck components have been updated to ensure text properties are always strings, improving robustness and user experience across the application. * Enhance admin layout and page components with forced dynamic rendering This update introduces forced dynamic rendering for the admin layout and page components to support server-side features and cookie handling. Additionally, it refines the Puck component structure by ensuring that items are conditionally rendered, improving robustness. Default item values in ContainerBlock, FlexBlock, and GridBlock have been updated to undefined for better handling of empty states. * Refactor PuckEditor component by removing the custom header and associated publish functionality. Simplify imports and enhance layout structure for improved readability and maintainability. This update streamlines the editor's design while retaining core functionality. * Enhance Hero component with new preset configurations and improved styling options. This update introduces multiple preset styles for background and button configurations, along with enhanced animation support. Additionally, the HeroFields and HeroDefaults have been updated to reflect these changes, providing a more flexible and visually appealing user experience. * Enhance CardBlock component with Tailwind CSS styling and improved layout features. This update introduces dynamic alignment, padding, and border radius classes, along with enhanced visual effects for titles, descriptions, and buttons. The overall user experience is improved with subtle animations and a more cohesive design, ensuring a modern and responsive interface. * Enhance EditPage component with a new "View Page" button for quick access to the published page. This update improves user experience by allowing admins to easily preview the page in a new tab. Additionally, the GridBlock component has been refactored to utilize Tailwind CSS for styling, enhancing layout flexibility and visual appeal with responsive design features and improved spacing management. * Add custom scrollbar utility and integrate GalleryBlock into Puck configuration This update introduces a new utility class for hiding scrollbars in the global CSS, enhancing the visual aesthetics of components. Additionally, the GalleryBlock has been added to the Puck configuration, allowing for improved media handling and layout flexibility. The utility functions have also been updated to validate the new block type, ensuring robust data management. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 07b553f commit 105a542

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3860
-399
lines changed

src/src/app/admin/cms/pages/[id]/edit/page.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useGrantedPolicies } from '@/lib/hooks/useGrantedPolicies'
1515
import { usePage } from '@/lib/hooks/usePages'
1616
import { Permissions } from '@/lib/utils'
1717
import { useQueryClient } from '@tanstack/react-query'
18-
import { ArrowLeft, Clock, RefreshCw, Save } from 'lucide-react'
18+
import { ArrowLeft, Clock, RefreshCw, Save, Eye } from 'lucide-react'
1919
import { useParams, useRouter } from 'next/navigation'
2020
import { useCallback, useEffect, useState } from 'react'
2121
import { Controller, useForm } from 'react-hook-form'
@@ -44,7 +44,6 @@ export default function EditPage() {
4444
const [isSubmitting, setIsSubmitting] = useState(false)
4545
const [formErrors, setFormErrors] = useState<Record<string, string[]>>({})
4646
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false)
47-
const [isPublished, setIsPublished] = useState(false)
4847
const [isFormLoaded, setIsFormLoaded] = useState(false)
4948

5049
const {
@@ -147,7 +146,6 @@ export default function EditPage() {
147146
style: pageData.style || '',
148147
concurrencyStamp: pageData.concurrencyStamp || '',
149148
})
150-
setIsPublished(pageData.isHomePage || false)
151149
setIsFormLoaded(true)
152150
}
153151
}, [page, reset])
@@ -239,7 +237,9 @@ export default function EditPage() {
239237
queryClient.invalidateQueries({ queryKey: [QueryNames.GetPage, pageId] })
240238
queryClient.invalidateQueries({ queryKey: [QueryNames.GetPages] })
241239
localStorage.removeItem(`page-draft-${pageId}`) // Clear draft after successful save
242-
router.push('/admin/cms')
240+
241+
// Remove the redirect - stay on the current page
242+
// router.push('/admin/cms')
243243
} catch (err: unknown) {
244244
console.error('Page update error:', err)
245245

@@ -371,17 +371,7 @@ export default function EditPage() {
371371
Unsaved Changes
372372
</Badge>
373373
)}
374-
<div className="flex items-center space-x-2">
375-
<Switch
376-
id="publish-status"
377-
checked={isPublished}
378-
onCheckedChange={setIsPublished}
379-
disabled
380-
/>
381-
<Label htmlFor="publish-status" className="text-sm">
382-
{isPublished ? 'Home Page' : 'Regular Page'}
383-
</Label>
384-
</div>
374+
385375

386376
<Button
387377
size="sm"
@@ -395,6 +385,23 @@ export default function EditPage() {
395385
{isLoading ? 'Loading...' : 'Refresh'}
396386
</Button>
397387

388+
{page && (page as VoloCmsKitAdminPagesPageDto).slug && (
389+
<Button
390+
size="sm"
391+
variant="outline"
392+
onClick={() => {
393+
const slug = (page as VoloCmsKitAdminPagesPageDto).slug
394+
if (slug) {
395+
window.open(`/pages/${slug}`, '_blank')
396+
}
397+
}}
398+
disabled={!page || !(page as VoloCmsKitAdminPagesPageDto).slug}
399+
>
400+
<Eye className="w-4 h-4 mr-2" />
401+
View Page
402+
</Button>
403+
)}
404+
398405
<Button size="sm" disabled={isSubmitting} onClick={handleSubmit(onSubmit)}>
399406
<Save className="w-4 h-4 mr-2" />
400407
{isSubmitting ? 'Saving...' : 'Save Changes'}

src/src/app/admin/cms/pages/create/page.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export default function CreatePage() {
4747
const router = useRouter()
4848
const [isSubmitting, setIsSubmitting] = useState(false)
4949
const [formErrors, setFormErrors] = useState<Record<string, string[]>>({})
50-
const [isPublished, setIsPublished] = useState(false)
5150

5251
const {
5352
handleSubmit,
@@ -118,7 +117,6 @@ export default function CreatePage() {
118117
content: contentToSubmit,
119118
script: data.script || '',
120119
style: data.style || '',
121-
isPublished,
122120
}
123121

124122
await pageAdminCreate({
@@ -127,14 +125,15 @@ export default function CreatePage() {
127125

128126
toast({
129127
title: 'Success',
130-
description: `Page ${isPublished ? 'published' : 'created'} successfully.`,
128+
description: 'Page created successfully.',
131129
variant: 'default',
132130
})
133131

134132
// Invalidate and refetch pages list
135133
queryClient.invalidateQueries({ queryKey: ['pages'] })
136134

137-
router.push('/admin/cms/pages')
135+
// Remove the redirect - stay on the current page
136+
// router.push('/admin/cms/pages')
138137
} catch (error: any) {
139138
console.error('Error creating page:', error)
140139

@@ -207,16 +206,9 @@ export default function CreatePage() {
207206
</div>
208207

209208
<div className="flex items-center gap-3">
210-
<div className="flex items-center space-x-2">
211-
<Switch id="publish-status" checked={isPublished} onCheckedChange={setIsPublished} />
212-
<Label htmlFor="publish-status" className="text-sm">
213-
{isPublished ? 'Published' : 'Draft'}
214-
</Label>
215-
</div>
216-
217209
<Button size="sm" disabled={isSubmitting} onClick={handleSubmit(onSubmit)}>
218210
<Save className="w-4 h-4 mr-2" />
219-
{isSubmitting ? 'Creating...' : isPublished ? 'Publish' : 'Create Page'}
211+
{isSubmitting ? 'Creating...' : 'Create Page'}
220212
</Button>
221213
</div>
222214
</div>

src/src/app/admin/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import AdminLayout from '@/layout/admin-layout'
22
import { setUpLayoutConfig } from '@/lib/auth'
33
import React from 'react'
44

5+
// Force dynamic rendering for admin pages since they use cookies and server-side features
6+
export const dynamic = 'force-dynamic'
7+
58
/**
69
* AdminRootLayout component serves as the root layout for the admin section of the application.
710
* It wraps its children with the AdminLayout component.

src/src/app/admin/loading.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { AdminLoading } from '@/components/ui/AdminLoading'
2+
3+
/**
4+
* Next.js loading component for the admin page.
5+
* This file is automatically used by Next.js to show a loading state
6+
* while the admin page is being rendered.
7+
*/
8+
export default function AdminPageLoading() {
9+
return <AdminLoading />
10+
}

src/src/app/admin/page.tsx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,38 @@ import {
1919
} from 'lucide-react'
2020
import Link from 'next/link'
2121

22+
// Force dynamic rendering since this page uses server-side API calls and authentication
23+
export const dynamic = 'force-dynamic'
24+
2225
/**
2326
* The AdminIndex component is an asynchronous function that fetches the application configuration
2427
* and displays a comprehensive admin dashboard with user information and system status.
28+
* Next.js will automatically show the loading.tsx component while this page is loading.
2529
*
2630
* @returns A React component that renders a modern admin dashboard with user details and system information.
2731
*/
2832
export default async function AdminIndex() {
29-
const { data } = await abpApplicationConfigurationGet()
30-
const appConfig = data as ApplicationConfigurationDto
33+
const response = await abpApplicationConfigurationGet()
34+
let appConfig = response.data as ApplicationConfigurationDto
35+
36+
// Provide fallback data if appConfig is null or undefined
37+
if (!appConfig) {
38+
appConfig = {
39+
localization: undefined,
40+
auth: undefined,
41+
setting: undefined,
42+
currentUser: undefined,
43+
features: undefined,
44+
globalFeatures: undefined,
45+
multiTenancy: undefined,
46+
currentTenant: undefined,
47+
timing: undefined,
48+
clock: undefined,
49+
objectExtensions: undefined,
50+
extraProperties: undefined,
51+
} as ApplicationConfigurationDto
52+
}
53+
3154
const currentUser = appConfig?.currentUser
3255

3356
const getInitials = (name?: string | null, surname?: string | null) => {
@@ -38,13 +61,18 @@ export default async function AdminIndex() {
3861

3962
const formatDate = (dateString?: string) => {
4063
if (!dateString) return 'N/A'
41-
return new Date(dateString).toLocaleDateString('en-US', {
42-
year: 'numeric',
43-
month: 'long',
44-
day: 'numeric',
45-
hour: '2-digit',
46-
minute: '2-digit',
47-
})
64+
try {
65+
return new Date(dateString).toLocaleDateString('en-US', {
66+
year: 'numeric',
67+
month: 'long',
68+
day: 'numeric',
69+
hour: '2-digit',
70+
minute: '2-digit',
71+
})
72+
} catch (err) {
73+
console.error('Error formatting date:', err)
74+
return 'Invalid Date'
75+
}
4876
}
4977

5078
return (

src/src/app/globals.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
@import 'tw-animate-css';
33
@import '@measured/puck/dist/index.css';
44

5+
/* Custom utilities */
6+
.scrollbar-hide {
7+
-ms-overflow-style: none;
8+
scrollbar-width: none;
9+
}
10+
.scrollbar-hide::-webkit-scrollbar {
11+
display: none;
12+
}
13+
514
@custom-variant dark (&:is(.dark *));
615

716
@theme {
@@ -42,6 +51,9 @@
4251

4352
--animate-accordion-down: accordion-down 0.2s ease-out;
4453
--animate-accordion-up: accordion-up 0.2s ease-out;
54+
--animate-fade-in: fade-in 0.8s ease-out;
55+
--animate-slide-up: slide-up 0.8s ease-out;
56+
--animate-slide-down: slide-down 0.8s ease-out;
4557

4658
@keyframes accordion-down {
4759
from {
@@ -59,6 +71,34 @@
5971
height: 0;
6072
}
6173
}
74+
@keyframes fade-in {
75+
from {
76+
opacity: 0;
77+
}
78+
to {
79+
opacity: 1;
80+
}
81+
}
82+
@keyframes slide-up {
83+
from {
84+
opacity: 0;
85+
transform: translateY(30px);
86+
}
87+
to {
88+
opacity: 1;
89+
transform: translateY(0);
90+
}
91+
}
92+
@keyframes slide-down {
93+
from {
94+
opacity: 0;
95+
transform: translateY(-30px);
96+
}
97+
to {
98+
opacity: 1;
99+
transform: translateY(0);
100+
}
101+
}
62102
}
63103

64104
@utility container {

0 commit comments

Comments
 (0)