infrahub-menu-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Infrahub Menu Creator

Infrahub菜单创建器

Overview

概述

Expert guidance for creating Infrahub custom menus. Menus control the left-side navigation in the web interface, organizing schema node types into a custom hierarchy.
为创建Infrahub自定义菜单提供专业指导。 菜单控制网页界面的左侧导航,可将schema节点类型组织为自定义层级结构。

When to Use

适用场景

  • Designing navigation menus for the Infrahub web UI
  • Organizing node types into logical groups and hierarchies
  • Adding icons and labels to menu items
  • Setting up group headers (non-clickable) with nested children
  • Configuring schema nodes to use custom menus instead of auto-generated ones
  • 为Infrahub网页UI设计导航菜单
  • 将节点类型组织为逻辑分组和层级结构
  • 为菜单项添加图标和标签
  • 设置带有嵌套子项的组标题(不可点击)
  • 配置schema节点使用自定义菜单,而非自动生成的菜单

Rule Categories

规则分类

PriorityCategoryPrefixDescription
CRITICALFormat
format-
apiVersion, kind, spec
CRITICALProperties
item-
name, namespace, label, kind
HIGHHierarchy
hierarchy-
Nesting, group headers, data
HIGHIcons
icons-
MDI icon reference, choices
MEDIUMSchema
schema-
include_in_menu, kind links
LOWPatterns
patterns-
Flat menu, comments, links
优先级分类前缀描述
CRITICAL格式
format-
apiVersion、kind、spec
CRITICAL属性
item-
name、namespace、label、kind
HIGH层级
hierarchy-
嵌套、组标题、数据
HIGH图标
icons-
MDI图标引用、可选值
MEDIUMSchema
schema-
include_in_menu、kind链接
LOW模式
patterns-
扁平菜单、注释、链接

Menu File Basics

菜单文件基础

yaml
---
apiVersion: infrahub.app/v1
kind: Menu
spec:
  data:
    - namespace: Dcim
      name: DeviceMenu
      label: "Devices"
      icon: "mdi:server"
      kind: DcimDevice        # Links to schema node list view
apiVersion
,
kind: Menu
, and
spec.data
are always required. Each menu item needs
name
and
namespace
.
yaml
---
apiVersion: infrahub.app/v1
kind: Menu
spec:
  data:
    - namespace: Dcim
      name: DeviceMenu
      label: "Devices"
      icon: "mdi:server"
      kind: DcimDevice        # Links to schema node list view
apiVersion
kind: Menu
spec.data
为必填项。每个菜单项都需要配置
name
namespace

Workflow

工作流

Follow these steps when creating a menu:
  1. Gather requirements — Ask what schema nodes exist, how they should be grouped, and whether the user wants flat or hierarchical navigation.
  2. Read relevant rules — Read
    rules/format-structure.md
    for the required YAML structure,
    rules/item-properties.md
    for item fields, and
    rules/hierarchy-nesting.md
    if nesting is needed. Read
    rules/icons-reference.md
    to pick appropriate MDI icons.
  3. Generate the menu YAML — Start with the
    $schema
    comment and
    apiVersion
    /
    kind
    /
    spec
    structure. Apply rules from step 2.
  4. Add registration and schema guidance — Every menu file output must include:
    • A YAML comment block showing how to register the file in
      .infrahub.yml
      under the
      menus:
      key (see
      rules/format-structure.md
      )
    • A YAML comment block advising to set
      include_in_menu: false
      on every schema node that appears in the custom menu, to prevent duplicate sidebar entries (see
      rules/schema-integration.md
      )
    Include these as comments at the top of the file, before the
    ---
    document separator. This ensures the user sees the guidance alongside the menu definition.
创建菜单时请遵循以下步骤:
  1. 收集需求 — 询问现有schema节点有哪些、如何分组,以及用户需要扁平还是层级导航。
  2. 阅读相关规则 — 如需了解必填YAML结构,请阅读
    rules/format-structure.md
    ;如需了解项字段,请阅读
    rules/item-properties.md
    ;如果需要嵌套结构,请阅读
    rules/hierarchy-nesting.md
    。如需选择合适的MDI图标,请阅读
    rules/icons-reference.md
  3. 生成菜单YAML — 从
    $schema
    注释和
    apiVersion
    /
    kind
    /
    spec
    结构开始编写,应用第2步中对应的规则。
  4. 添加注册和schema指引 — 所有输出的菜单文件都必须包含:
    • 一段YAML注释块,说明如何在
      .infrahub.yml
      menus:
      键下注册该文件(参见
      rules/format-structure.md
    • 一段YAML注释块,建议为所有出现在自定义菜单中的schema节点设置
      include_in_menu: false
      ,避免侧边栏出现重复条目(参见
      rules/schema-integration.md
    请将这些内容作为注释放在文件顶部、
    ---
    文档分隔符之前,确保用户在查看菜单定义的同时能看到相关指引。

Supporting References

参考资料

  • infrahub-yml-reference.md -- .infrahub.yml project configuration
  • common/rules/ -- Shared rules (git integration, caching gotchas) that apply across all skills
  • schema-creator -- Schema node kinds that menus link to
  • rules/ -- Individual rules organized by category prefix
  • infrahub-yml-reference.md -- .infrahub.yml项目配置
  • common/rules/ -- 适用于所有skill的共享规则(git集成、缓存注意事项) 可用于所有skill
  • schema-creator -- 菜单链接对应的Schema节点类型
  • rules/ -- 按分类前缀整理的各规则详情