Skip to main content

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

  1. Menu Selection

    • The command first prompts you to select a portal menu
    • Determines if it's a main menu or settings menu item
  2. Folder Structure Validation

    • Validates the required folder structure in your selected menu
    • Ensures all necessary directories and files exist
  3. Tab Configuration

    • Displays existing record tabs
    • Prompts for additional tabs to be created
    • Confirms the tab creation process
  4. Template Generation

    • Creates new tabs using the _TEMPLATE structure
    • Generates all necessary components and layouts
    • Updates the tab configuration

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 tab
  • name: Display name of the tab
  • tabName: 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 tab
  • page.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

  1. 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
  2. Tab Names

    • Use clear and descriptive names for your tabs
    • Avoid duplicate tab IDs
  3. Configuration

    • Keep your tab configurations organized and well-documented
    • Review generated configurations for accuracy

Examples

Basic Usage

  1. Run the record command:

    platform record
  2. Select your target menu

  3. Follow the prompts to create new tabs

  4. 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;