Skip to content

Commit

Permalink
fix: operation items render issue in theme list
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 6, 2023
1 parent 283962e commit efbac81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
23 changes: 7 additions & 16 deletions console/src/modules/interface/themes/components/ThemeListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
VDropdownDivider,
VButton,
VSpace,
IconMore,
} from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
Expand All @@ -19,10 +18,10 @@ import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query";
import { useOperationItemExtensionPoint } from "@/composables/use-operation-extension-points";
import { markRaw } from "vue";
import { defineComponent } from "vue";
import UninstallOperationItem from "./operation/UninstallOperationItem.vue";
import { computed } from "vue";
import type { OperationItem } from "@halo-dev/console-shared";
import MoreOperationItem from "./operation/MoreOperationItem.vue";
const { currentUserHasPermission } = usePermission();
const { t } = useI18n();
Expand Down Expand Up @@ -112,15 +111,7 @@ const { operationItems } = useOperationItemExtensionPoint<Theme>(
},
{
priority: 30,
component: markRaw(
defineComponent({
components: {
VButton,
IconMore,
},
template: `<VButton size="sm"><IconMore /></VButton>`,
})
),
component: markRaw(MoreOperationItem),
permissions: ["system:themes:manage"],
children: [
{
Expand Down Expand Up @@ -238,13 +229,14 @@ const { operationItems } = useOperationItemExtensionPoint<Theme>(
</div>
<div>
<VSpace v-if="installed">
<template v-for="(item, index) in operationItems" :key="index">
<template v-for="item in operationItems">
<template v-if="!item.children?.length">
<component
:is="item.component"
v-if="
!item.hidden && currentUserHasPermission(item.permissions)
"
:key="`${theme.metadata.name}-${item.label}-${item.priority}`"
v-bind="item.props"
@click="item.action?.(theme)"
>
Expand All @@ -256,6 +248,7 @@ const { operationItems } = useOperationItemExtensionPoint<Theme>(
v-if="
!item.hidden && currentUserHasPermission(item.permissions)
"
:key="`${theme.metadata.name}-${item.label}-${item.priority}`"
>
<component
:is="item.component"
Expand All @@ -265,16 +258,14 @@ const { operationItems } = useOperationItemExtensionPoint<Theme>(
{{ item.label }}
</component>
<template #popper>
<template
v-for="(childItem, childIndex) in item.children"
:key="`child-${childIndex}`"
>
<template v-for="childItem in item.children">
<component
:is="childItem.component"
v-if="
!childItem.hidden &&
currentUserHasPermission(childItem.permissions)
"
:key="`${theme.metadata.name}-${childItem.label}-${childItem.priority}`"
v-bind="childItem.props"
@click="childItem.action?.(theme)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const handleOpenPreview = (theme: Theme) => {
</Transition>
<Transition v-else appear name="fade">
<ul class="box-border h-full w-full space-y-3" role="list">
<li v-for="(theme, index) in themes" :key="index">
<li v-for="theme in themes" :key="theme.metadata.name">
<ThemeListItem
:theme="theme"
:is-selected="theme.metadata.name === selectedTheme?.metadata?.name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts" setup>
import { VButton, IconMore } from "@halo-dev/components";
</script>

<template>
<VButton size="sm"><IconMore /></VButton>
</template>

0 comments on commit efbac81

Please sign in to comment.