CommonThirdPartyAuthenticationButton.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { getCSRFToken } from '#shared/server/apollo/utils/csrfToken.ts'
  4. import type { ButtonVariant } from '#shared/types/button.ts'
  5. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  6. import type { ButtonSize } from '#desktop/components/CommonButton/types.ts'
  7. interface Props {
  8. buttonClass?: string
  9. buttonLabel?: string
  10. buttonIcon?: string
  11. buttonPrefixIcon?: string
  12. buttonVariant?: ButtonVariant
  13. buttonSize?: ButtonSize
  14. buttonBlock?: boolean
  15. url: string
  16. disabled?: boolean
  17. }
  18. withDefaults(defineProps<Props>(), {
  19. buttonVariant: 'secondary',
  20. buttonSize: 'small',
  21. })
  22. defineEmits<{
  23. 'button-click': []
  24. }>()
  25. const csrfToken = getCSRFToken()
  26. </script>
  27. <template>
  28. <form role="form" method="post" :action="url">
  29. <input type="hidden" name="authenticity_token" :value="csrfToken" />
  30. <CommonButton
  31. type="submit"
  32. :class="buttonClass"
  33. :aria-label="buttonLabel"
  34. :size="buttonSize"
  35. :variant="buttonVariant"
  36. :disabled="disabled"
  37. :block="buttonBlock"
  38. :prefix-icon="buttonPrefixIcon"
  39. :icon="buttonIcon"
  40. @click="$emit('button-click')"
  41. >
  42. <slot />
  43. </CommonButton>
  44. </form>
  45. </template>