feat: set the approvedTime field during approve (#713)

#### What type of PR is this?

/kind improvement
/milestone 2.0

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

评论或者回复审核时设置审核时间。适配:https://github.com/halo-dev/halo/pull/2746

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

Fixes https://github.com/halo-dev/halo/issues/2738

#### Special notes for your reviewer:

测试方式:

1. Halo 需要切换到 https://github.com/halo-dev/halo/issues/2738 分支。
2. Console 需要 `pnpm install`
3. 在主题端创建若干评论,然后去 Console 端审核通过,检查是否正常设置了审核时间。

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

```release-note
Console 端在评论或者回复审核时设置审核时间。
```
pull/712/head^2
Ryan Wang 2022-11-28 21:28:18 +08:00 committed by GitHub
parent 189573e70b
commit 8fbef715ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 9 deletions

View File

@ -32,7 +32,7 @@
"@formkit/themes": "^1.0.0-beta.12",
"@formkit/utils": "^1.0.0-beta.12",
"@formkit/vue": "^1.0.0-beta.12",
"@halo-dev/api-client": "^0.0.53",
"@halo-dev/api-client": "^0.0.55",
"@halo-dev/components": "workspace:*",
"@halo-dev/console-shared": "workspace:*",
"@halo-dev/richtext-editor": "^0.0.0-alpha.16",

View File

@ -12,7 +12,7 @@ importers:
'@formkit/themes': ^1.0.0-beta.12
'@formkit/utils': ^1.0.0-beta.12
'@formkit/vue': ^1.0.0-beta.12
'@halo-dev/api-client': ^0.0.53
'@halo-dev/api-client': ^0.0.55
'@halo-dev/components': workspace:*
'@halo-dev/console-shared': workspace:*
'@halo-dev/richtext-editor': ^0.0.0-alpha.16
@ -104,7 +104,7 @@ importers:
'@formkit/themes': 1.0.0-beta.12-e579559_tailwindcss@3.2.4
'@formkit/utils': 1.0.0-beta.12-e579559
'@formkit/vue': 1.0.0-beta.12-e579559_ior6jr3fpijijuwpr34w2i25va
'@halo-dev/api-client': 0.0.53
'@halo-dev/api-client': 0.0.55
'@halo-dev/components': link:packages/components
'@halo-dev/console-shared': link:packages/shared
'@halo-dev/richtext-editor': 0.0.0-alpha.16_vue@3.2.45
@ -1962,8 +1962,8 @@ packages:
- windicss
dev: false
/@halo-dev/api-client/0.0.53:
resolution: {integrity: sha512-B3njjXFqTi28FfDhZ9VAVlv6mMQxLgIsBUqTPmMQF/IxWWtfN6cxYi7is+zmw+chFFe38UVaEAPSHORLMxnJ6A==}
/@halo-dev/api-client/0.0.55:
resolution: {integrity: sha512-n/XjFhCgUYYo3mrVsuCa11iyXkbBgcRGIT8fDfdkuLjzfXamxt0eJMFbz8lpH85pTh7O7xTQzCxvi5YIi7zBLw==}
dev: false
/@halo-dev/richtext-editor/0.0.0-alpha.16_vue@3.2.45:

View File

@ -170,6 +170,8 @@ const handleApproveInBatch = async () => {
const promises = commentsToUpdate.map((comment) => {
const commentToUpdate = comment.comment;
commentToUpdate.spec.approved = true;
// TODO: see https://github.com/halo-dev/halo/pull/2746
commentToUpdate.spec.approvedTime = new Date().toISOString();
return apiClient.extension.comment.updatecontentHaloRunV1alpha1Comment(
{
name: commentToUpdate.metadata.name,

View File

@ -85,6 +85,8 @@ const handleApproveReplyInBatch = async () => {
const promises = repliesToUpdate.map((reply) => {
const replyToUpdate = reply.reply;
replyToUpdate.spec.approved = true;
// TODO: see https://github.com/halo-dev/halo/pull/2746
replyToUpdate.spec.approvedTime = new Date().toISOString();
return apiClient.extension.reply.updatecontentHaloRunV1alpha1Reply({
name: replyToUpdate.metadata.name,
reply: replyToUpdate,
@ -104,6 +106,8 @@ const handleApprove = async () => {
try {
const commentToUpdate = cloneDeep(props.comment.comment);
commentToUpdate.spec.approved = true;
// TODO: see https://github.com/halo-dev/halo/pull/2746
commentToUpdate.spec.approvedTime = new Date().toISOString();
await apiClient.extension.comment.updatecontentHaloRunV1alpha1Comment({
name: commentToUpdate.metadata.name,
comment: commentToUpdate,
@ -358,10 +362,10 @@ const subjectRefResult = computed(() => {
<VStatusDot v-tooltip="``" state="warning" animate />
</template>
</VEntityField>
<VEntityField>
<VEntityField v-if="comment?.comment?.spec.approvedTime">
<template #description>
<span class="truncate text-xs tabular-nums text-gray-500">
{{ formatDatetime(comment?.comment?.metadata.creationTimestamp) }}
{{ formatDatetime(comment?.comment?.spec.approvedTime) }}
</span>
</template>
</VEntityField>

View File

@ -66,6 +66,8 @@ const handleApprove = async () => {
try {
const replyToUpdate = cloneDeep(props.reply.reply);
replyToUpdate.spec.approved = true;
// TODO: see https://github.com/halo-dev/halo/pull/2746
replyToUpdate.spec.approvedTime = new Date().toISOString();
await apiClient.extension.reply.updatecontentHaloRunV1alpha1Reply({
name: replyToUpdate.metadata.name,
reply: replyToUpdate,
@ -164,10 +166,10 @@ const isHoveredReply = computed(() => {
<VStatusDot v-tooltip="``" state="warning" animate />
</template>
</VEntityField>
<VEntityField>
<VEntityField v-if="reply?.reply?.spec.approvedTime">
<template #description>
<span class="truncate text-xs tabular-nums text-gray-500">
{{ formatDatetime(reply?.reply?.metadata.creationTimestamp) }}
{{ formatDatetime(reply?.reply?.spec.approvedTime) }}
</span>
</template>
</VEntityField>