infrahub-menu-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInfrahub 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
规则分类
| Priority | Category | Prefix | Description |
|---|---|---|---|
| CRITICAL | Format | | apiVersion, kind, spec |
| CRITICAL | Properties | | name, namespace, label, kind |
| HIGH | Hierarchy | | Nesting, group headers, data |
| HIGH | Icons | | MDI icon reference, choices |
| MEDIUM | Schema | | include_in_menu, kind links |
| LOW | Patterns | | Flat menu, comments, links |
| 优先级 | 分类 | 前缀 | 描述 |
|---|---|---|---|
| CRITICAL | 格式 | | apiVersion、kind、spec |
| CRITICAL | 属性 | | name、namespace、label、kind |
| HIGH | 层级 | | 嵌套、组标题、数据 |
| HIGH | 图标 | | MDI图标引用、可选值 |
| MEDIUM | Schema | | include_in_menu、kind链接 |
| LOW | 模式 | | 扁平菜单、注释、链接 |
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 viewapiVersionkind: Menuspec.datanamenamespaceyaml
---
apiVersion: infrahub.app/v1
kind: Menu
spec:
data:
- namespace: Dcim
name: DeviceMenu
label: "Devices"
icon: "mdi:server"
kind: DcimDevice # Links to schema node list viewapiVersionkind: Menuspec.datanamenamespaceWorkflow
工作流
Follow these steps when creating a menu:
-
Gather requirements — Ask what schema nodes exist, how they should be grouped, and whether the user wants flat or hierarchical navigation.
-
Read relevant rules — Readfor the required YAML structure,
rules/format-structure.mdfor item fields, andrules/item-properties.mdif nesting is needed. Readrules/hierarchy-nesting.mdto pick appropriate MDI icons.rules/icons-reference.md -
Generate the menu YAML — Start with thecomment and
$schema/apiVersion/kindstructure. Apply rules from step 2.spec -
Add registration and schema guidance — Every menu file output must include:
- A YAML comment block showing how to register
the file in under the
.infrahub.ymlkey (seemenus:)rules/format-structure.md - A YAML comment block advising to set
on every schema node that appears in the custom menu, to prevent duplicate sidebar entries (see
include_in_menu: false)rules/schema-integration.md
Include these as comments at the top of the file, before thedocument separator. This ensures the user sees the guidance alongside the menu definition.--- - A YAML comment block showing how to register
the file in
创建菜单时请遵循以下步骤:
-
收集需求 — 询问现有schema节点有哪些、如何分组,以及用户需要扁平还是层级导航。
-
阅读相关规则 — 如需了解必填YAML结构,请阅读;如需了解项字段,请阅读
rules/format-structure.md;如果需要嵌套结构,请阅读rules/item-properties.md。如需选择合适的MDI图标,请阅读rules/hierarchy-nesting.md。rules/icons-reference.md -
生成菜单YAML — 从注释和
$schema/apiVersion/kind结构开始编写,应用第2步中对应的规则。spec -
添加注册和schema指引 — 所有输出的菜单文件都必须包含:
- 一段YAML注释块,说明如何在的
.infrahub.yml键下注册该文件(参见menus:)rules/format-structure.md - 一段YAML注释块,建议为所有出现在自定义菜单中的schema节点设置,避免侧边栏出现重复条目(参见
include_in_menu: false)rules/schema-integration.md
请将这些内容作为注释放在文件顶部、文档分隔符之前,确保用户在查看菜单定义的同时能看到相关指引。--- - 一段YAML注释块,说明如何在
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/ -- 按分类前缀整理的各规则详情