Skip to content

Commit c5a42bd

Browse files
Cms module (page and comments) (#211)
* 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. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 75380c8 commit c5a42bd

File tree

203 files changed

+33239
-8634
lines changed

Some content is hidden

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

203 files changed

+33239
-8634
lines changed

docs/docs/contributing.md

Lines changed: 499 additions & 0 deletions
Large diffs are not rendered by default.

docs/docs/development/setup.md

Lines changed: 640 additions & 0 deletions
Large diffs are not rendered by default.

docs/docs/faq.md

Lines changed: 601 additions & 0 deletions
Large diffs are not rendered by default.

docs/docs/fundamentals/admin-interface.md

Lines changed: 682 additions & 0 deletions
Large diffs are not rendered by default.

docs/docs/fundamentals/api-integration.md

Lines changed: 651 additions & 0 deletions
Large diffs are not rendered by default.

docs/docs/fundamentals/authentication.md

Lines changed: 479 additions & 73 deletions
Large diffs are not rendered by default.
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Project Structure
6+
7+
Understanding the project structure is crucial for effective development with ABP React. This guide explains the organization of files and directories in your ABP React application.
8+
9+
## Overview
10+
11+
ABP React follows a clean, scalable architecture that separates concerns and promotes maintainability. The project structure is designed to be intuitive for developers familiar with modern React applications while integrating seamlessly with ABP Framework patterns.
12+
13+
## Root Directory Structure
14+
15+
```
16+
my-awesome-app/
17+
├── .env.sample # Environment variables template
18+
├── .eslintrc.json # ESLint configuration
19+
├── .gitignore # Git ignore rules
20+
├── components.json # shadcn/ui configuration
21+
├── Dockerfile # Docker configuration
22+
├── next.config.mjs # Next.js configuration
23+
├── package.json # Node.js dependencies and scripts
24+
├── pnpm-lock.yaml # Package lock file
25+
├── postcss.config.mjs # PostCSS configuration
26+
├── prettier.config.js # Prettier configuration
27+
├── README.md # Project documentation
28+
├── tsconfig.json # TypeScript configuration
29+
├── public/ # Static assets
30+
├── src/ # Source code
31+
└── .template.config/ # Template configuration
32+
```
33+
34+
## Source Code Structure (`src/`)
35+
36+
The `src` directory contains all the application source code, organized by feature and responsibility:
37+
38+
```
39+
src/
40+
├── app/ # Next.js App Router
41+
│ ├── api/ # API routes
42+
│ ├── auth/ # Authentication pages
43+
│ ├── admin/ # Admin panel pages
44+
│ ├── session/ # Session management
45+
│ ├── globals.css # Global styles
46+
│ ├── layout.tsx # Root layout component
47+
│ └── page.tsx # Home page
48+
├── components/ # Reusable UI components
49+
│ ├── ui/ # shadcn/ui components
50+
│ ├── sections/ # Page sections
51+
│ ├── navbar/ # Navigation components
52+
│ ├── menu/ # Menu components
53+
│ ├── user/ # User-related components
54+
│ ├── role/ # Role management components
55+
│ ├── tenant/ # Tenant components
56+
│ ├── permission/ # Permission components
57+
│ ├── profile/ # Profile components
58+
│ ├── settings/ # Settings components
59+
│ └── analytics/ # Analytics components
60+
├── hooks/ # Custom React hooks
61+
├── lib/ # Utility functions and configurations
62+
├── client/ # API client and services
63+
├── layout/ # Layout components
64+
├── config.ts # Application configuration
65+
├── middleware.ts # Next.js middleware
66+
├── sessionOptions.ts # Session configuration
67+
└── useSession.ts # Session hook
68+
```
69+
70+
## Key Directories Explained
71+
72+
### `app/` - Next.js App Router
73+
74+
This directory contains the Next.js 13+ App Router structure:
75+
76+
- **`api/`**: Server-side API routes for handling backend communication
77+
- **`auth/`**: Authentication-related pages (login, register, forgot password)
78+
- **`admin/`**: Administrative interface pages
79+
- **`session/`**: Session management pages
80+
- **`layout.tsx`**: Root layout component that wraps all pages
81+
- **`page.tsx`**: The main homepage component
82+
83+
### `components/` - UI Components
84+
85+
Organized by feature and responsibility:
86+
87+
- **`ui/`**: Base UI components from shadcn/ui (Button, Input, Dialog, etc.)
88+
- **`sections/`**: Larger page sections and layouts
89+
- **`navbar/`**: Navigation bar components
90+
- **`menu/`**: Menu and navigation components
91+
- **`user/`**: User management components (UserList, UserForm, etc.)
92+
- **`role/`**: Role management components
93+
- **`tenant/`**: Multi-tenancy components
94+
- **`permission/`**: Permission management components
95+
- **`profile/`**: User profile components
96+
- **`settings/`**: Application settings components
97+
- **`analytics/`**: Analytics and reporting components
98+
99+
### `hooks/` - Custom React Hooks
100+
101+
Contains custom hooks for:
102+
- Data fetching and caching
103+
- Form handling
104+
- Authentication state
105+
- Permission checking
106+
- Multi-tenancy operations
107+
108+
### `lib/` - Utilities and Configurations
109+
110+
Contains utility functions and configurations:
111+
- API client configuration
112+
- Validation schemas
113+
- Helper functions
114+
- Constants and enums
115+
- Type definitions
116+
117+
### `client/` - API Client
118+
119+
Contains the generated API client and services:
120+
- OpenAPI generated clients
121+
- Custom service wrappers
122+
- Request/response interceptors
123+
- Error handling utilities
124+
125+
## Configuration Files
126+
127+
### `next.config.mjs`
128+
129+
Next.js configuration including:
130+
- Build optimization settings
131+
- Environment variables
132+
- Webpack customizations
133+
- Routing configuration
134+
135+
### `tsconfig.json`
136+
137+
TypeScript configuration with:
138+
- Path mappings for clean imports
139+
- Strict type checking rules
140+
- Module resolution settings
141+
- Compilation targets
142+
143+
### `components.json`
144+
145+
shadcn/ui configuration specifying:
146+
- Component library settings
147+
- Theme configuration
148+
- CSS variables
149+
- Utility classes
150+
151+
### `package.json`
152+
153+
Node.js project configuration with:
154+
- Dependencies and dev dependencies
155+
- Build and development scripts
156+
- Project metadata
157+
158+
## File Naming Conventions
159+
160+
### Components
161+
- **PascalCase**: `UserProfile.tsx`, `NavigationMenu.tsx`
162+
- **Directory-based**: Components with multiple files go in directories
163+
- **Index files**: Use `index.tsx` for main component exports
164+
165+
### Hooks
166+
- **camelCase with 'use' prefix**: `useAuth.ts`, `usePermissions.ts`
167+
168+
### Utilities
169+
- **camelCase**: `apiClient.ts`, `validation.ts`
170+
171+
### Pages (App Router)
172+
- **kebab-case**: `user-profile/page.tsx`, `admin/users/page.tsx`
173+
- **Special files**: `layout.tsx`, `loading.tsx`, `error.tsx`
174+
175+
## Import Organization
176+
177+
Imports should be organized in the following order:
178+
179+
1. **React and Next.js imports**
180+
2. **Third-party libraries**
181+
3. **Internal utilities and configurations**
182+
4. **Components (UI, then feature-specific)**
183+
5. **Types and interfaces**
184+
6. **Relative imports**
185+
186+
Example:
187+
```typescript
188+
// React and Next.js
189+
import React from 'react';
190+
import { useRouter } from 'next/navigation';
191+
192+
// Third-party libraries
193+
import { useForm } from 'react-hook-form';
194+
import { zodResolver } from '@hookform/resolvers/zod';
195+
196+
// Internal utilities
197+
import { apiClient } from '@/lib/api-client';
198+
import { userSchema } from '@/lib/schemas';
199+
200+
// Components
201+
import { Button } from '@/components/ui/button';
202+
import { UserForm } from '@/components/user/user-form';
203+
204+
// Types
205+
import type { User } from '@/types/user';
206+
207+
// Relative imports
208+
import './user-profile.css';
209+
```
210+
211+
## Environment Configuration
212+
213+
### `.env.sample`
214+
215+
Template for environment variables:
216+
```env
217+
# Application
218+
NEXTAUTH_URL=http://localhost:3000
219+
NEXTAUTH_SECRET=your-secret-key
220+
221+
# API Configuration
222+
NEXT_PUBLIC_API_URL=https://your-api-url.com
223+
224+
# Authentication
225+
NEXT_PUBLIC_AUTH_PROVIDERS=credentials,google,github
226+
227+
# Feature Flags
228+
NEXT_PUBLIC_ENABLE_ANALYTICS=true
229+
NEXT_PUBLIC_ENABLE_MULTI_TENANCY=true
230+
```
231+
232+
### `.env.local`
233+
234+
Local development environment variables (not committed to git):
235+
```env
236+
NEXTAUTH_SECRET=your-development-secret
237+
NEXT_PUBLIC_API_URL=http://localhost:44300
238+
```
239+
240+
## Build and Deployment Structure
241+
242+
### Production Build
243+
244+
```
245+
.next/ # Next.js build output
246+
├── static/ # Static assets
247+
├── server/ # Server-side code
248+
└── cache/ # Build cache
249+
```
250+
251+
### Docker
252+
253+
The project includes Docker configuration for containerized deployment:
254+
255+
```dockerfile
256+
# Multi-stage build for production
257+
FROM node:18-alpine AS builder
258+
# ... build steps
259+
260+
FROM node:18-alpine AS runner
261+
# ... runtime configuration
262+
```
263+
264+
## Best Practices
265+
266+
### Directory Organization
267+
- **Feature-based**: Group related components, hooks, and utilities together
268+
- **Consistent naming**: Use consistent naming conventions across the project
269+
- **Clear separation**: Separate concerns between UI, business logic, and data access
270+
271+
### Component Structure
272+
- **Single responsibility**: Each component should have a single, well-defined purpose
273+
- **Reusability**: Design components to be reusable across different parts of the application
274+
- **Composition**: Use composition over inheritance for complex components
275+
276+
### Import Management
277+
- **Absolute imports**: Use path mappings for cleaner imports
278+
- **Barrel exports**: Use index files to simplify imports
279+
- **Lazy loading**: Implement code splitting for large components
280+
281+
## Next Steps
282+
283+
Now that you understand the project structure, explore these related topics:
284+
285+
- **[Configuration Guide](/docs/fundamentals/configuration)** - Learn about configuration options
286+
- **[Authentication Setup](/docs/fundamentals/authentication)** - Set up authentication
287+
- **[Component Development](/docs/components/ui-components)** - Build custom components
288+
- **[API Integration](/docs/fundamentals/api-integration)** - Connect to your ABP backend
289+
290+
---
291+
292+
Understanding the project structure is the foundation for successful development with ABP React. This organization promotes maintainability, scalability, and developer productivity.

0 commit comments

Comments
 (0)