Skip to content

Commit

Permalink
fix: missing ui permission condition about users
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <[email protected]>
  • Loading branch information
ruibaby committed Sep 18, 2023
1 parent 4dcced9 commit e346bea
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 77 deletions.
39 changes: 39 additions & 0 deletions console/src/modules/contents/_components/ContributorList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts" setup>
import { usePermission } from "@/utils/permission";
import type { Contributor } from "@halo-dev/api-client";
import { VAvatar } from "@halo-dev/components";
import { useRouter } from "vue-router";
withDefaults(
defineProps<{
contributors: Contributor[];
}>(),
{}
);
const router = useRouter();
const { currentUserHasPermission } = usePermission();
function handleRouteToUserDetail(contributor: Contributor) {
if (!currentUserHasPermission(["system:users:view"])) {
return;
}
router.push({
name: "UserDetail",
params: { name: contributor.name },
});
}
</script>

<template>
<VAvatar
v-for="(contributor, contributorIndex) in contributors"
:key="contributorIndex"
v-tooltip="contributor.displayName"
size="xs"
:src="contributor.avatar"
:alt="contributor.displayName"
circle
@click="handleRouteToUserDetail(contributor)"
></VAvatar>
</template>
5 changes: 5 additions & 0 deletions console/src/modules/contents/attachments/AttachmentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,11 @@ onMounted(() => {
},
}"
class="text-xs text-gray-500"
:class="{
'pointer-events-none': !currentUserHasPermission([
'system:users:view',
]),
}"
>
{{ attachment.spec.ownerName }}
</RouterLink>
Expand Down
23 changes: 2 additions & 21 deletions console/src/modules/contents/pages/DeletedSinglePageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
VSpace,
Dialog,
VEmpty,
VAvatar,
VEntity,
VEntityField,
VPageHeader,
Expand All @@ -22,11 +21,11 @@ import { ref, watch } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { formatDatetime } from "@/utils/date";
import { RouterLink } from "vue-router";
import cloneDeep from "lodash.clonedeep";
import { usePermission } from "@/utils/permission";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
import ContributorList from "../_components/ContributorList.vue";
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
Expand Down Expand Up @@ -338,25 +337,7 @@ watch(
<template #end>
<VEntityField>
<template #description>
<RouterLink
v-for="(
contributor, contributorIndex
) in singlePage.contributors"
:key="contributorIndex"
:to="{
name: 'UserDetail',
params: { name: contributor.name },
}"
class="flex items-center"
>
<VAvatar
v-tooltip="contributor.displayName"
size="xs"
:src="contributor.avatar"
:alt="contributor.displayName"
circle
></VAvatar>
</RouterLink>
<ContributorList :contributors="singlePage.contributors" />
</template>
</VEntityField>
<VEntityField v-if="!singlePage?.page?.spec.deleted">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
IconExternalLinkLine,
VSpace,
Dialog,
VAvatar,
VStatusDot,
VEntity,
VEntityField,
Expand All @@ -25,6 +24,7 @@ import { useMutation, useQueryClient } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
import { inject } from "vue";
import type { Ref } from "vue";
import ContributorList from "../../_components/ContributorList.vue";
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
Expand Down Expand Up @@ -189,23 +189,7 @@ const handleDelete = async () => {
<template #end>
<VEntityField>
<template #description>
<RouterLink
v-for="(contributor, contributorIndex) in singlePage.contributors"
:key="contributorIndex"
:to="{
name: 'UserDetail',
params: { name: contributor.name },
}"
class="flex items-center"
>
<VAvatar
v-tooltip="contributor.displayName"
size="xs"
:src="contributor.avatar"
:alt="contributor.displayName"
circle
></VAvatar>
</RouterLink>
<ContributorList :contributors="singlePage.contributors" />
</template>
</VEntityField>
<VEntityField :description="publishStatus">
Expand Down
22 changes: 2 additions & 20 deletions console/src/modules/contents/posts/DeletedPostList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
VPageHeader,
VPagination,
VSpace,
VAvatar,
VStatusDot,
VEntity,
VEntityField,
Expand All @@ -27,6 +26,7 @@ import { usePermission } from "@/utils/permission";
import cloneDeep from "lodash.clonedeep";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
import ContributorList from "../_components/ContributorList.vue";
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
Expand Down Expand Up @@ -353,25 +353,7 @@ watch(
<template #end>
<VEntityField>
<template #description>
<RouterLink
v-for="(
contributor, contributorIndex
) in post.contributors"
:key="contributorIndex"
:to="{
name: 'UserDetail',
params: { name: contributor.name },
}"
class="flex items-center"
>
<VAvatar
v-tooltip="contributor.displayName"
size="xs"
:src="contributor.avatar"
:alt="contributor.displayName"
circle
></VAvatar>
</RouterLink>
<ContributorList :contributors="post.contributors" />
</template>
</VEntityField>
<VEntityField v-if="!post?.post?.spec.deleted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { VAvatar, VEntityField } from "@halo-dev/components";
import { VEntityField } from "@halo-dev/components";
import type { ListedPost } from "@halo-dev/api-client";
import ContributorList from "@/modules/contents/_components/ContributorList.vue";
withDefaults(
defineProps<{
Expand All @@ -13,23 +14,7 @@ withDefaults(
<template>
<VEntityField>
<template #description>
<RouterLink
v-for="(contributor, contributorIndex) in post.contributors"
:key="contributorIndex"
:to="{
name: 'UserDetail',
params: { name: contributor.name },
}"
class="flex items-center"
>
<VAvatar
v-tooltip="contributor.displayName"
size="xs"
:src="contributor.avatar"
:alt="contributor.displayName"
circle
></VAvatar>
</RouterLink>
<ContributorList :contributors="post.contributors" />
</template>
</VEntityField>
</template>

0 comments on commit e346bea

Please sign in to comment.