TicketSidebar.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useTicketSidebar } from '../composables/useTicketSidebar.ts'
  4. import type { TicketSidebarContext } from '../types/sidebar.ts'
  5. interface Props {
  6. context: TicketSidebarContext
  7. isCollapsed: boolean
  8. toggleCollapse: () => void
  9. }
  10. const props = defineProps<Props>()
  11. const {
  12. activeSidebar,
  13. availableSidebarPlugins,
  14. shownSidebars,
  15. showSidebar,
  16. hideSidebar,
  17. switchSidebar,
  18. } = useTicketSidebar()
  19. const maybeToggleAndSwitchSidebar = (newSidebar: string) => {
  20. if (props.isCollapsed) props.toggleCollapse()
  21. switchSidebar(newSidebar)
  22. }
  23. </script>
  24. <template>
  25. <div class="flex h-full justify-end">
  26. <div v-show="!isCollapsed" id="ticketSidebar" class="flex grow flex-col" />
  27. <div
  28. class="flex max-w-12 flex-col items-center gap-2.5 border-neutral-100 px-2.5 py-3 transition-[border] dark:border-gray-900"
  29. :class="{ 'border-s': !isCollapsed }"
  30. >
  31. <component
  32. :is="sidebarPlugin.component"
  33. v-for="(sidebarPlugin, sidebar) of availableSidebarPlugins"
  34. v-show="shownSidebars[sidebar]"
  35. :key="sidebar"
  36. :selected="activeSidebar === sidebar"
  37. :sidebar="sidebar"
  38. :sidebar-plugin="sidebarPlugin"
  39. :context="context"
  40. @click="maybeToggleAndSwitchSidebar"
  41. @show="showSidebar(sidebar as string)"
  42. @hide="hideSidebar(sidebar as string)"
  43. />
  44. </div>
  45. </div>
  46. </template>