Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

feat: add delete attachment group and policy support #695

Conversation

ruibaby
Copy link
Member

@ruibaby ruibaby commented Nov 15, 2022

What type of PR is this?

/kind feature
/milestone 2.0

What this PR does / why we need it:

支持删除附件分组和存储策略。

删除策略的逻辑为:删除前会根据策略查询附件,如果有附件,则无法删除,否则可以删除。

删除附件的逻辑为:

  1. 选择删除并将附件移动至未分组时,会在前端批量调用更新附件的接口,将所有附件的 groupRef 置空。
  2. 选择删除并同时删除附件时,会在前端批量调用删除附件接口。

Which issue(s) this PR fixes:

Fixes halo-dev/halo#2706

Special notes for your reviewer:

/cc @halo-dev/sig-halo-console

测试方式:

  1. 需要执行 pnpm build:packages
  2. 创建若干存储策略,并在部分存储策略中上传附件,再对存储策略做删除处理,需要满足以下情况:
    1. 已包含附件的策略会提示不允许删除。
    2. 未包含附件的策略可以删除
  3. 创建若干分组,并在部分分组中上传附件,再对分组做删除处理,需要满足以下情况:
    1. 选择删除并将附件移动至未分组时,检查分组是否被删除,且里面的附件是否已经被移动到未分组。
    2. 选择删除并同时删除附件时,检查分组是否被删除,且里面的附件是否被删除。

Does this PR introduce a user-facing change?

支持删除附件分组和存储策略。

@f2c-ci-robot f2c-ci-robot bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 15, 2022
@f2c-ci-robot f2c-ci-robot bot added this to the 2.0 milestone Nov 15, 2022
@vercel
Copy link

vercel bot commented Nov 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
ui ✅ Ready (Inspect) Visit Preview Nov 18, 2022 at 6:38AM (UTC)

Copy link
Member

@guqing guqing 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 Nov 17, 2022
@guqing
Copy link
Member

guqing commented Nov 17, 2022

我认为删除分组时通过 reconciler 去删除分组下的附件可能会更可靠些,如果调用API去删除分组下面的附件,多时删除分组时将会导致页面卡死或崩溃。不过目前没有提供 Reconciler

@JohnNiang
Copy link
Member

我认为删除分组时通过 reconciler 去删除分组下的附件可能会更可靠些,如果调用API去删除分组下面的附件,多时删除分组时将会导致页面卡死或崩溃。不过目前没有提供 Reconciler

可以考虑在 Group 中加上 finalizer,如果删除 Group 则在 reconciler 中先删除其下的所有附件,再移除 finalizer。

如果需要让用户决定是否级联删除附件,可以在 Group 中加上 spec.cascadeDelete=false 字段。

@guqing
Copy link
Member

guqing commented Nov 17, 2022

我认为删除分组时通过 reconciler 去删除分组下的附件可能会更可靠些,如果调用API去删除分组下面的附件,多时删除分组时将会导致页面卡死或崩溃。不过目前没有提供 Reconciler

可以考虑在 Group 中加上 finalizer,如果删除 Group 则在 reconciler 中先删除其下的所有附件,再移除 finalizer。

如果需要让用户决定是否级联删除附件,可以在 Group 中加上 spec.cascadeDelete=false 字段。

赞同

@f2c-ci-robot f2c-ci-robot bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2022
Copy link
Member

@guqing guqing 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 Nov 17, 2022
@f2c-ci-robot f2c-ci-robot bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 18, 2022
Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/approve

It works very well.

image
image

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 18, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 18, 2022
@guqing
Copy link
Member

guqing commented Nov 18, 2022

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Nov 18, 2022
@f2c-ci-robot f2c-ci-robot bot merged commit eef8dc3 into halo-dev:main Nov 18, 2022
@ruibaby ruibaby deleted the feat/support-for-delete-attachment-group-and-policy branch November 19, 2022 16:10
JohnNiang pushed a commit to JohnNiang/halo that referenced this pull request Mar 2, 2023
…e#695)

#### What type of PR is this?

/kind feature
/milestone 2.0

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

支持删除附件分组和存储策略。

删除策略的逻辑为:删除前会根据策略查询附件,如果有附件,则无法删除,否则可以删除。

删除附件的逻辑为:

1. 选择`删除并将附件移动至未分组`时,会在前端批量调用更新附件的接口,将所有附件的 `groupRef` 置空。
2. 选择`删除并同时删除附件`时,会在前端批量调用删除附件接口。

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

Fixes halo-dev#2706

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-console 

测试方式:

1. 需要执行 `pnpm build:packages`
2. 创建若干存储策略,并在部分存储策略中上传附件,再对存储策略做删除处理,需要满足以下情况:
    1. 已包含附件的策略会提示不允许删除。
    2. 未包含附件的策略可以删除
3. 创建若干分组,并在部分分组中上传附件,再对分组做删除处理,需要满足以下情况:
    1. 选择`删除并将附件移动至未分组`时,检查分组是否被删除,且里面的附件是否已经被移动到未分组。
    2. 选择`删除并同时删除附件`时,检查分组是否被删除,且里面的附件是否被删除。


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

<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->

```release-note
支持删除附件分组和存储策略。
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
4 participants