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

refactor: transition behavior of post state after category updated #1785

Merged
merged 5 commits into from
Mar 29, 2022

Conversation

guqing
Copy link
Member

@guqing guqing commented Mar 29, 2022

What this PR does?

更改分类更新后的文章状态过渡行为,由于情况复杂该PR并没有提供单元测试,目前只是在相对合理的情况下解决它有些场景不完善,等待2.0重新设计加密功能。

要考虑以下情况:

  • 分类被更新: 判断密码,If 从空到非空(转私密),Else 从非空到空(公开)

  • 分类被删除:判断被删除分类的密码,1.非空,检查所属该分类及其子分类的文章综合文章私密性来决定最终是私密还是公开,2.空则不用管

针对父分类的私密性对当前分类的影响分析:

  • 父分类有密码:
    • 当前有密码:私密状态,密码变更 非空 -> 空,为私密
      ​ - 当前分类没密码:私密状态,密码状态变更也为私密
  • 父分类没有密码:
    • 当前有密码:私密状态,如果当前变更为 密码 从非空 -> 空,则转为公开
    • 当前没密码:公开状态,如果密码从 空->非空 则为私密,否则为公开

Why we need it?

之前更新了分类会将所属分类的文章转草稿不合理,现更改它的行为

Fix #1779

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 29, 2022
@guqing guqing marked this pull request as draft March 29, 2022 06:51
@ruibaby
Copy link
Member

ruibaby commented Mar 29, 2022

/kind bug

@f2c-ci-robot f2c-ci-robot bot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 29, 2022
@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2022
@ruibaby
Copy link
Member

ruibaby commented Mar 29, 2022

测试用例:

  • 更新没有密码的分类,不影响文章的状态。
  • 给分类加密,文章状态改为私密。
  • 修改分类加密过的文章,不影响文章状态。
  • 移除分类的密码,其下文章改为发布状态。
  • 父级分类修改为加密,子分类其下文章改为私密状态。
  • 父级分类取消加密,子分类其下文章改为发布状态。
  • 访问分类地址,输入正确密码,进入文章列表。
  • 访问子分类地址,父分类有密码,进入密码输入页面,输入正确密码,进入文章列表。
  • 子分类取消放在一个加密分类的下面,文章更新为发布状态。

@ruibaby
Copy link
Member

ruibaby commented Mar 29, 2022

/cc @halo-dev/sig-halo

@ruibaby
Copy link
Member

ruibaby commented Mar 29, 2022

/cc @halo-dev/sig-halo 大家好,建议大家尽可能的测试此 PR。

@ruibaby
Copy link
Member

ruibaby commented Mar 29, 2022

/retitle refactor: transition behavior of post state after category updated

@f2c-ci-robot f2c-ci-robot bot changed the title [WIP] refactor: transition behavior of post state after category updated refactor: transition behavior of post state after category updated Mar 29, 2022
@ruibaby ruibaby marked this pull request as ready for review March 29, 2022 13:20
@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 29, 2022
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2022
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 29, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing, ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot merged commit 2bccfb1 into halo-dev:master Mar 29, 2022
@guqing guqing deleted the bugfix/post-status branch March 30, 2022 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

文章状态无法由私密变为已发布
2 participants