Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

扩展自定义元数据设置表单的设计 #3005

Closed
JohnNiang opened this issue Dec 19, 2022 · 2 comments · Fixed by #3028
Closed

扩展自定义元数据设置表单的设计 #3005

JohnNiang opened this issue Dec 19, 2022 · 2 comments · Fixed by #3028
Labels
area/core Issues or PRs related to the Halo Core kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@JohnNiang
Copy link
Member

JohnNiang commented Dec 19, 2022

增加 AnnotationSetting 自定义模型用于保存模型 annotations 的 form schema,可以在使用时通过 targetRef 查询到一系列 formSchemas 进行特定资源扩展设置的表单渲染。

apiVersion: v1alpha1
kind: AnnotationSetting
metadata:
  name: a-name
  labels: 
    # plugin.halo.run/plugin-name: fake-plugin
    theme.halo.run/theme-name: fake-theme
    halo.run/target-ref: posts.content.halo.run
spec:
  targetRef:
    group: content.halo.run
    kind: Post
  formSchema:
    - $formkit: text
      name: fancy.halo.run/download_url
      label: 下载链接
    - $formkit: select
      name: fancy.halo.run/version
      label: 支持的版本
      options:
        - value: "1.5"
          label: "1.5"
        - value: "2.0"
          label: "2.0"

如果为主题创建的用于文章使用的 annotations setting,文章使用时最终通过以上 setting 渲染的表单填写值后存储在 annotations 示例如下:

apiVersion: content.halo.run/v1alpha1
kind: Post
metadata:
  annotations:
    fancy.halo.run/download_url: https://example.com/fake
    fancy.halo.run/version: "[\"1.5\", \"2.0\"]"
  creationTimestamp: '2022-12-15T09:45:36.089125Z'
  name: fake-post
spec:
  slug: hello-halo
  title: Hello Halo
  visible: PUBLIC

/cc @halo-dev/sig-halo

Originally posted by @guqing in #2858 (comment)

@JohnNiang
Copy link
Member Author

/milestone 2.1.x

@f2c-ci-robot f2c-ci-robot bot added this to the 2.1.x milestone Dec 19, 2022
@JohnNiang JohnNiang added kind/feature Categorizes issue or PR as related to a new feature. area/core Issues or PRs related to the Halo Core labels Dec 19, 2022
@guqing
Copy link
Member

guqing commented Dec 21, 2022

这个 label halo.run/target-ref 如果使用 plural 的话,根据 targetRef 的 group kind 貌似是无法获取到 plural

f2c-ci-robot bot pushed a commit that referenced this issue Dec 26, 2022
#### What type of PR is this?
/kind feature
/milestone 2.1.x
/area core

#### What this PR does / why we need it:
新增 AnnotationSetting 自定义模型以扩展自定义元数据设置表单

主题安装/更新/重载时都会重新加载与 theme.yaml 同层级的其他 yaml,但只会保存 kind 为 Setting 和 AnnotationSetting的,主题卸载时会删除这些 yaml 资源

#### Which issue(s) this PR fixes:

Fixes #3005

#### Special notes for your reviewer:
how to test it?
- 修改影响到了主题安装、更新、重载和删除,需要检查这些功能是否正确加载了 Setting 和 AnnotationSetting
- 插件启动时初始化的 AnnotationSetting 在插件停止时会被删除
- 主题添加了 annotation setting 资源,使用非超级管理员也可以获取

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
新增 AnnotationSetting 以扩展自定义元数据设置表单
```
@ruibaby ruibaby modified the milestones: 2.1.x, 2.1.0 Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Issues or PRs related to the Halo Core kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants