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

feat: add support for user avatar upload #4253

Merged
merged 38 commits into from Jul 24, 2023

Conversation

LIlGG
Copy link
Member

@LIlGG LIlGG commented Jul 18, 2023

What type of PR is this?

/kind improvement
/area console
/area core

What this PR does / why we need it:

此 PR 对用户头像上传的方式进行了重构,移除了原有的头像链接及上传至附件库的方案。允许具有用户管理权限的用户对其他用户的头像进行修改和移除。

Core:
新增了 /apis/api.console.halo.run/v1alpha1/users/-/avatarPOST 以及 DELETE 接口,用来上传用户的头像及删除当前用户的头像。

Console:
新增对用户头像进行裁剪的功能,并调用上传接口保存用户头像。

需等待 #4247 合并

Which issue(s) this PR fixes:

Fixes #2688

See #4251
See #4247

Special notes for your reviewer:

  1. 测试上传、删除头像接口是否能够正常执行。
  2. 查看当前用户的头像是否能够设置成功。
  3. 查看附件库中,当前用户的头像文件是否为 0 或 1 个。

Does this PR introduce a user-facing change?

支持通过上传和剪裁的方式设置用户头像。

@f2c-ci-robot f2c-ci-robot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/improvement Categorizes issue or PR as related to a improvement. area/console Issues or PRs related to the Halo Console area/core Issues or PRs related to the Halo Core labels Jul 18, 2023
@ruibaby
Copy link
Member

ruibaby commented Jul 19, 2023

本地尝试了一下,有几个建议:

  1. cropperjs 似乎有点大,建议将组件异步加载。
  2. 裁剪区域期望添加放大和缩小图片的按钮。
  3. 预览区域建议添加多个尺寸的预览图,包括纯圆形。
  4. 裁剪弹窗建议支持直接换图片。

@LIlGG
Copy link
Member Author

LIlGG commented Jul 20, 2023

/retitle refactor:add support for user avatar upload

@f2c-ci-robot f2c-ci-robot bot changed the title WIP:refactor:add support for user avatar upload refactor:add support for user avatar upload Jul 20, 2023
@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 Jul 20, 2023
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #4253 (a1ea92b) into main (fdfaa53) will increase coverage by 0.02%.
The diff coverage is 63.86%.

@@             Coverage Diff              @@
##               main    #4253      +/-   ##
============================================
+ Coverage     60.13%   60.16%   +0.02%     
- Complexity     2407     2422      +15     
============================================
  Files           364      364              
  Lines         12584    12701     +117     
  Branches        903      915      +12     
============================================
+ Hits           7568     7642      +74     
- Misses         4575     4609      +34     
- Partials        441      450       +9     
Impacted Files Coverage Δ
.../app/core/extension/reconciler/UserReconciler.java 51.37% <33.33%> (-5.95%) ⬇️
...halo/app/core/extension/endpoint/UserEndpoint.java 87.22% <72.82%> (-5.00%) ⬇️

@LIlGG
Copy link
Member Author

LIlGG commented Jul 20, 2023

/hold 缺少修改其他用户头像的方式

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2023
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.

  • 用户头像的文件名建议用 UUID 替代。
  • 删除头像时建议增加确认步骤。
  • 期望拥有用户管理权限的用户能够操作其他用户头像。

@LIlGG LIlGG requested a review from JohnNiang July 20, 2023 10:17
@LIlGG
Copy link
Member Author

LIlGG commented Jul 20, 2023

  • 用户头像的文件名建议用 UUID 替代。
  • 删除头像时建议增加确认步骤。
  • 期望拥有用户管理权限的用户能够操作其他用户头像。

已对功能进行补充,并且完善了移动端样式。

@LIlGG LIlGG requested a review from ruibaby July 21, 2023 08:49
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.

Hi @LIlGG , PTAL

api/src/main/java/run/halo/app/core/extension/User.java Outdated Show resolved Hide resolved
api/src/main/java/run/halo/app/core/extension/User.java Outdated Show resolved Hide resolved
console/src/constants/annotations.ts Outdated Show resolved Hide resolved
console/src/constants/annotations.ts Outdated Show resolved Hide resolved
@LIlGG LIlGG requested a review from JohnNiang July 24, 2023 02:16
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

@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 Jul 24, 2023
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 Jul 24, 2023
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

@JohnNiang JohnNiang requested a review from ruibaby July 24, 2023 08:04
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Jul 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang, 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 84093d8 into halo-dev:main Jul 24, 2023
4 checks passed
@ruibaby ruibaby added this to the 2.8.0 milestone Jul 24, 2023
f2c-ci-robot bot pushed a commit that referenced this pull request Jul 27, 2023
#### What type of PR is this?

/kind bug
/area core

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

解决 #4253  所导致的用户旧头像被删除的问题。

#### Special notes for your reviewer:

1. 使用 2.7.x 之前的 Halo 版本,新建用户并设置其头像。
2. 升级 Halo 至 2.8.0-rc.1 
3. 头像还存在即可。
4. 测试头像上传、移除功能是否正常可用。

#### 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
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/console Issues or PRs related to the Halo Console area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. 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
Development

Successfully merging this pull request may close these issues.

期望设置头像或站点背景图片时支持裁剪及预览
4 participants