TicketCreate.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useTicketCreateView } from '#shared/entities/ticket/composables/useTicketCreateView.ts'
  4. import { ErrorRouteType, redirectErrorRoute } from '#shared/router/error.ts'
  5. import { ErrorStatusCodes } from '#shared/types/error.ts'
  6. import LayoutTaskbarTabContent from '#desktop/components/layout/LayoutTaskbarTabContent.vue'
  7. import TicketCreateContent from '../components/TicketCreate/TicketCreateContent.vue'
  8. interface Props {
  9. tabId: string
  10. }
  11. defineOptions({
  12. beforeRouteEnter(to) {
  13. const { ticketCreateEnabled, checkUniqueTicketCreateRoute } =
  14. useTicketCreateView()
  15. if (!ticketCreateEnabled.value)
  16. return redirectErrorRoute({
  17. type: ErrorRouteType.AuthenticatedError,
  18. title: __('Forbidden'),
  19. message: __('Creating new tickets via web is disabled.'),
  20. statusCode: ErrorStatusCodes.Forbidden,
  21. })
  22. return checkUniqueTicketCreateRoute(to)
  23. },
  24. beforeRouteUpdate(to) {
  25. // When route is updated we need to check again of the unique identifier.
  26. const { checkUniqueTicketCreateRoute } = useTicketCreateView()
  27. return checkUniqueTicketCreateRoute(to)
  28. },
  29. })
  30. defineProps<Props>()
  31. </script>
  32. <template>
  33. <LayoutTaskbarTabContent>
  34. <TicketCreateContent :tab-id="tabId" />
  35. </LayoutTaskbarTabContent>
  36. </template>