mirror of https://github.com/halo-dev/halo
feat: improve permission control for comment management (#7521)
#### What type of PR is this? /area ui /kind improvement /milestone 2.21.x #### What this PR does / why we need it: Improve permission control for comment management. #### Does this PR introduce a user-facing change? ```release-note None ```pull/7516/head^2
parent
4093435b0e
commit
392d851353
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import HasPermission from "@/components/permission/HasPermission.vue";
|
||||||
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
||||||
import {
|
import {
|
||||||
consoleApiClient,
|
consoleApiClient,
|
||||||
|
@ -168,6 +169,7 @@ const websiteOfAnonymous = computed(() => {
|
||||||
comment.comment.spec.content
|
comment.comment.spec.content
|
||||||
}}</pre>
|
}}</pre>
|
||||||
</VDescriptionItem>
|
</VDescriptionItem>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<VDescriptionItem
|
<VDescriptionItem
|
||||||
v-if="!comment.comment.spec.approved"
|
v-if="!comment.comment.spec.approved"
|
||||||
:label="$t('core.comment.detail_modal.fields.new_reply')"
|
:label="$t('core.comment.detail_modal.fields.new_reply')"
|
||||||
|
@ -178,10 +180,12 @@ const websiteOfAnonymous = computed(() => {
|
||||||
@update="newReply = $event"
|
@update="newReply = $event"
|
||||||
/>
|
/>
|
||||||
</VDescriptionItem>
|
</VDescriptionItem>
|
||||||
|
</HasPermission>
|
||||||
</VDescription>
|
</VDescription>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<VSpace>
|
<VSpace>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<VButton
|
<VButton
|
||||||
v-if="!comment.comment.spec.approved"
|
v-if="!comment.comment.spec.approved"
|
||||||
type="secondary"
|
type="secondary"
|
||||||
|
@ -193,6 +197,7 @@ const websiteOfAnonymous = computed(() => {
|
||||||
: $t("core.comment.operations.approve.button")
|
: $t("core.comment.operations.approve.button")
|
||||||
}}
|
}}
|
||||||
</VButton>
|
</VButton>
|
||||||
|
</HasPermission>
|
||||||
<VButton @click="modal?.close()">
|
<VButton @click="modal?.close()">
|
||||||
{{ $t("core.common.buttons.close") }}
|
{{ $t("core.common.buttons.close") }}
|
||||||
</VButton>
|
</VButton>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue";
|
import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue";
|
||||||
|
import HasPermission from "@/components/permission/HasPermission.vue";
|
||||||
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
||||||
import { usePermission } from "@/utils/permission";
|
import { usePermission } from "@/utils/permission";
|
||||||
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
|
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
|
||||||
|
@ -325,12 +326,14 @@ const { operationItems } = useOperationItemExtensionPoint<ListedComment>(
|
||||||
state="success"
|
state="success"
|
||||||
animate
|
animate
|
||||||
/>
|
/>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<span
|
<span
|
||||||
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
||||||
@click="replyModal = true"
|
@click="replyModal = true"
|
||||||
>
|
>
|
||||||
{{ $t("core.comment.operations.reply.button") }}
|
{{ $t("core.comment.operations.reply.button") }}
|
||||||
</span>
|
</span>
|
||||||
|
</HasPermission>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -380,12 +383,14 @@ const { operationItems } = useOperationItemExtensionPoint<ListedComment>(
|
||||||
<VButton @click="refetch()">
|
<VButton @click="refetch()">
|
||||||
{{ $t("core.common.buttons.refresh") }}
|
{{ $t("core.common.buttons.refresh") }}
|
||||||
</VButton>
|
</VButton>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<VButton type="secondary" @click="replyModal = true">
|
<VButton type="secondary" @click="replyModal = true">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<IconAddCircle />
|
<IconAddCircle />
|
||||||
</template>
|
</template>
|
||||||
{{ $t("core.comment.reply_empty.new") }}
|
{{ $t("core.comment.reply_empty.new") }}
|
||||||
</VButton>
|
</VButton>
|
||||||
|
</HasPermission>
|
||||||
</VSpace>
|
</VSpace>
|
||||||
</template>
|
</template>
|
||||||
</VEmpty>
|
</VEmpty>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue";
|
import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue";
|
||||||
|
import HasPermission from "@/components/permission/HasPermission.vue";
|
||||||
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
||||||
import { usePermission } from "@/utils/permission";
|
import { usePermission } from "@/utils/permission";
|
||||||
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
|
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
|
||||||
|
@ -238,6 +239,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedReply>(
|
||||||
<IconReplyLine />
|
<IconReplyLine />
|
||||||
<span>{{ quoteReply.owner.displayName }}</span>
|
<span>{{ quoteReply.owner.displayName }}</span>
|
||||||
</a><br v-if="quoteReply" />{{ reply?.reply.spec.content }}</pre>
|
</a><br v-if="quoteReply" />{{ reply?.reply.spec.content }}</pre>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<div class="flex items-center gap-3 text-xs">
|
<div class="flex items-center gap-3 text-xs">
|
||||||
<span
|
<span
|
||||||
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
||||||
|
@ -246,6 +248,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedReply>(
|
||||||
{{ $t("core.comment.operations.reply.button") }}
|
{{ $t("core.comment.operations.reply.button") }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</HasPermission>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VEntityField>
|
</VEntityField>
|
||||||
|
|
|
@ -108,6 +108,7 @@ export const internalWidgetDefinitions: DashboardWidgetDefinition[] = [
|
||||||
minH: 6,
|
minH: 6,
|
||||||
minW: 3,
|
minW: 3,
|
||||||
},
|
},
|
||||||
|
permissions: ["system:comments:view"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "core:user:stats",
|
id: "core:user:stats",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import HasPermission from "@/components/permission/HasPermission.vue";
|
||||||
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
import { formatDatetime, relativeTimeTo } from "@/utils/date";
|
||||||
import CommentDetailModal from "@console/modules/contents/comments/components/CommentDetailModal.vue";
|
import CommentDetailModal from "@console/modules/contents/comments/components/CommentDetailModal.vue";
|
||||||
import OwnerButton from "@console/modules/contents/comments/components/OwnerButton.vue";
|
import OwnerButton from "@console/modules/contents/comments/components/OwnerButton.vue";
|
||||||
|
@ -103,6 +104,7 @@ const handleDelete = async () => {
|
||||||
class="whitespace-pre-wrap break-words text-sm text-gray-900 line-clamp-4"
|
class="whitespace-pre-wrap break-words text-sm text-gray-900 line-clamp-4"
|
||||||
>{{ comment?.comment?.spec.content }}</pre
|
>{{ comment?.comment?.spec.content }}</pre
|
||||||
>
|
>
|
||||||
|
<HasPermission :permissions="['system:comments:manage']">
|
||||||
<div class="flex items-center gap-3 text-xs">
|
<div class="flex items-center gap-3 text-xs">
|
||||||
<span
|
<span
|
||||||
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
class="select-none cursor-pointer text-gray-700 hover:text-gray-900"
|
||||||
|
@ -117,6 +119,7 @@ const handleDelete = async () => {
|
||||||
{{ $t("core.common.buttons.delete") }}
|
{{ $t("core.common.buttons.delete") }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</HasPermission>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VEntityField>
|
</VEntityField>
|
||||||
|
|
Loading…
Reference in New Issue