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

关于主题配置项默认值问题 #2414

Closed
guqing opened this issue Sep 16, 2022 · 4 comments
Closed

关于主题配置项默认值问题 #2414

guqing opened this issue Sep 16, 2022 · 4 comments
Labels
area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement.
Milestone

Comments

@guqing
Copy link
Member

guqing commented Sep 16, 2022

Your current Halo version

2.0.0

Describe this feature

目前主题安装后基本都有 settings.yaml 并且其中配置了设置的默认值

apiVersion: v1alpha1
kind: Setting
metadata:
  name: theme-anatole-setting
spec:
  - group: basic
    label: 基本设置
    formSchema:
      - $formkit: select
        name: sidebar_width
        label: 侧边栏宽度
        options:
          "20%": 20%
          "30%": 30%
          "40%": 40%
          "50%": 50%
        value: "40%"

如上所示,group=basic的 item 的 formSchema 是表单 schema,如果有默认值会在其中又一个 value 属性,例如 40%
但是主题首次安装需要在主题设置点击保存才能将默认值同步到 ConfigMap 中。
这显得很繁琐,而且不开箱即用,需要对此进行优化:
实现方式:

  1. 主题安装时,console 端模拟保存动作,虽然能行但不建议
  2. 安装主题时,后端处理默认值,读取 settings.yaml,formSchema[index].value 即为默认值根据

[group].formSchema[idnex].name=formSchema[index].value的方式即可创建 configMap,其中 [group] 表示组名占位符,[index]表示数组索引占位符

@halo-dev/sig-halo 你们怎么看

Additional information

/kind improvement
/area core
/milestone 2.0

@f2c-ci-robot f2c-ci-robot bot added the kind/improvement Categorizes issue or PR as related to a improvement. label Sep 16, 2022
@f2c-ci-robot f2c-ci-robot bot added this to the 2.0 milestone Sep 16, 2022
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Sep 16, 2022
@JohnNiang
Copy link
Member

FormKit 中定义的默认值和系统(default ConfigMap)提供的默认配置是两种不同维度的默认值。一个是面向表单,一个是面向系统。各自有各自的默认值即可。当然系统提供的默认值优先级更高。

@guqing
Copy link
Member Author

guqing commented Sep 19, 2022

FormKit 中定义的默认值和系统(default ConfigMap)提供的默认配置是两种不同维度的默认值。一个是面向表单,一个是面向系统。各自有各自的默认值即可。当然系统提供的默认值优先级更高。

主题刚安装的时候 formkit中定义的默认值是没有同步到 ConfigMap 的,而 ConfigMap 也没有关于此主题的默认值

f2c-ci-robot bot pushed a commit to halo-dev/console that referenced this issue Sep 22, 2022
#### What type of PR is this?

/kind improvement
/milestone 2.0
/kind api-change

#### What this PR does / why we need it:

重构 Setting 模型的结构,适配 halo-dev/halo#2440

todo list:

- [x] 更新 `@halo-dev/api-client`

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

Fixes halo-dev/halo#2414

#### Special notes for your reviewer:

测试方式:

1. 本地 admin 仓库切换到当前 PR 的分支,halo 仓库切换到 halo-dev/halo#2440 PR 的分支。
2. 测试后台各个表单功能是否正常。
3. 主题设置表单可使用 halo-sigs/theme-anatole#2 PR 的分支进行测试。

#### Does this PR introduce a user-facing change?

```release-note
None
```
f2c-ci-robot bot pushed a commit that referenced this issue Sep 22, 2022
…ing a theme (#2440)

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
- 安装主题后通过读取主题 Setting 模型中的默认值初始化一个 ConfigMap
- 修改了 Setting 模型的 spec  结构(多了一层 forms 嵌套),配置示例如下:
```yaml
apiVersion: v1alpha1
kind: Setting
metadata:
  name: theme-anatole-setting
spec:
  forms:
    - group: basic
      label: 基本设置
      formSchema:
        - $formkit: select
          name: sidebar_width
          label: 侧边栏宽度
          options:
            "20%": 20%
            "30%": 30%
            "40%": 40%
            "50%": 50%
          value: "40%"
```

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

Fixes #2414

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
@f2c-ci-robot f2c-ci-robot bot closed this as completed Sep 23, 2022
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Sep 23, 2022

@ruibaby: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

JohnNiang pushed a commit to JohnNiang/halo that referenced this issue Mar 2, 2023
#### What type of PR is this?

/kind improvement
/milestone 2.0
/kind api-change

#### What this PR does / why we need it:

重构 Setting 模型的结构,适配 halo-dev#2440

todo list:

- [x] 更新 `@halo-dev/api-client`

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

Fixes halo-dev#2414

#### Special notes for your reviewer:

测试方式:

1. 本地 admin 仓库切换到当前 PR 的分支,halo 仓库切换到 halo-dev#2440 PR 的分支。
2. 测试后台各个表单功能是否正常。
3. 主题设置表单可使用 halo-sigs/theme-anatole#2 PR 的分支进行测试。

#### Does this PR introduce a user-facing change?

```release-note
None
```
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/improvement Categorizes issue or PR as related to a improvement.
Projects
None yet
Development

No branches or pull requests

3 participants