Record Tab
The platform record command allows you to generate and configure record tabs in your portal application. This command helps you create new tabs with proper template structure and configuration.
Command Overview
The record command validates your folder structure, creates new tabs, and updates the necessary configurations automatically.
platform record
Features
- Validates required folder structure
- Generates new record tabs using templates
- Updates tab configurations automatically
- Supports both main portal and settings menu locations
Command Flow
-
Menu Selection
- The command first prompts you to select a portal menu
- Determines if it's a main menu or settings menu item
-
Folder Structure Validation
- Validates the required folder structure in your selected menu
- Ensures all necessary directories and files exist
-
Tab Configuration
- Displays existing record tabs
- Prompts for additional tabs to be created
- Confirms the tab creation process
-
Template Generation
- Creates new tabs using the
_TEMPLATEstructure - Generates all necessary components and layouts
- Updates the tab configuration
- Creates new tabs using the
Tab Configuration
The tabs are configured in the _config/tabs.ts file. Here's an example configuration:
const tabs = [
{
id: "dashboard",
name: "Dashboard",
tabName: "dashboard?categories=",
},
];
export default tabs;
Each tab configuration requires:
id: Unique identifier for the tabname: Display name of the tabtabName: URL parameter for the tab
Template Structure
When generating a new tab, the command uses the _TEMPLATE structure to create the following files:
└── @record/
└── [your-tab-name]/
├── @guideline/
├── layout.tsx
└── page.tsx
The template includes:
layout.tsx: Defines the layout structure for the record tabpage.tsx: Contains the main content and functionality of the tab
Error Handling
The command includes built-in error handling for:
- Invalid folder structures
- Configuration errors
- Template generation failures
Error messages are displayed in red with detailed information about the issue.
Best Practices
-
Folder Structure
- Ensure your menu folder structure is properly set up before running the command
- Follow the recommended portal structure for main and settings menus
-
Tab Names
- Use clear and descriptive names for your tabs
- Avoid duplicate tab IDs
-
Configuration
- Keep your tab configurations organized and well-documented
- Review generated configurations for accuracy
Examples
Basic Usage
-
Run the record command:
platform record -
Select your target menu
-
Follow the prompts to create new tabs
-
Confirm the changes to proceed with generation
Configuration Example
After generating new tabs, your tabs.ts might look like this:
const tabs = [
{
id: "dashboard",
name: "Dashboard",
tabName: "dashboard?categories=",
},
{
id: "details",
name: "Details",
tabName: "details?categories=",
}
];
export default tabs;