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 <i@ryanc.cc>
  • Loading branch information
ruibaby committed Sep 18, 2023
1 parent 83cb088 commit 101da48
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
16 changes: 16 additions & 0 deletions console/src/components/permission/HasPermission.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script lang="ts" setup>
import { usePermission } from "@/utils/permission";
withDefaults(
defineProps<{
permissions: string[];
}>(),
{}
);
const { currentUserHasPermission } = usePermission();
</script>

<template>
<slot v-if="currentUserHasPermission(permissions)" />
</template>
10 changes: 6 additions & 4 deletions console/src/modules/contents/attachments/AttachmentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@ onMounted(() => {
}) || []),
]"
/>
<UserFilterDropdown
v-model="selectedUser"
:label="$t('core.attachment.filters.owner.label')"
/>
<HasPermission :permissions="['system:users:view']">
<UserFilterDropdown
v-model="selectedUser"
:label="$t('core.attachment.filters.owner.label')"
/>
</HasPermission>
<FilterDropdown
v-model="selectedSort"
:label="$t('core.common.filters.labels.sort')"
Expand Down
10 changes: 6 additions & 4 deletions console/src/modules/contents/comments/CommentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ const handleApproveInBatch = async () => {
},
]"
/>
<UserFilterDropdown
v-model="selectedUser"
:label="$t('core.comment.filters.owner.label')"
/>
<HasPermission :permissions="['system:users:view']">
<UserFilterDropdown
v-model="selectedUser"
:label="$t('core.comment.filters.owner.label')"
/>
</HasPermission>
<FilterDropdown
v-model="selectedSort"
:label="$t('core.common.filters.labels.sort')"
Expand Down
10 changes: 6 additions & 4 deletions console/src/modules/contents/pages/SinglePageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,12 @@ watch(selectedPageNames, (newValue) => {
},
]"
/>
<UserFilterDropdown
v-model="selectedContributor"
:label="$t('core.page.filters.author.label')"
/>
<HasPermission :permissions="['system:users:view']">
<UserFilterDropdown
v-model="selectedContributor"
:label="$t('core.page.filters.author.label')"
/>
</HasPermission>
<FilterDropdown
v-model="selectedSort"
:label="$t('core.common.filters.labels.sort')"
Expand Down
10 changes: 6 additions & 4 deletions console/src/modules/contents/posts/PostList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,12 @@ watch(selectedPostNames, (newValue) => {
v-model="selectedTag"
:label="$t('core.post.filters.tag.label')"
/>
<UserFilterDropdown
v-model="selectedContributor"
:label="$t('core.post.filters.author.label')"
/>
<HasPermission :permissions="['system:users:view']">
<UserFilterDropdown
v-model="selectedContributor"
:label="$t('core.post.filters.author.label')"
/>
</HasPermission>
<FilterDropdown
v-model="selectedSort"
:label="$t('core.common.filters.labels.sort')"
Expand Down
2 changes: 2 additions & 0 deletions console/src/setup/setupComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import FilterCleanButton from "@/components/filter/FilterCleanButton.vue";
import SearchInput from "@/components/input/SearchInput.vue";
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import AttachmentFileTypeIcon from "@/components/icon/AttachmentFileTypeIcon.vue";
import HasPermission from "@/components/permission/HasPermission.vue";

export function setupComponents(app: App) {
app.use(VueGridLayout);
Expand All @@ -37,4 +38,5 @@ export function setupComponents(app: App) {
app.component("SearchInput", SearchInput);
app.component("AnnotationsForm", AnnotationsForm);
app.component("AttachmentFileTypeIcon", AttachmentFileTypeIcon);
app.component("HasPermission", HasPermission);
}

0 comments on commit 101da48

Please sign in to comment.