| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <div>
- <div
- class="
- bg-primary
- border-b border-dividerLight
- flex flex-1
- top-lowerSecondaryStickyFold
- pl-4
- z-10
- sticky
- items-center
- justify-between
- "
- >
- <label class="font-semibold text-secondaryLight">
- {{ $t("request.header_list") }}
- </label>
- <div class="flex">
- <ButtonSecondary
- v-if="headers"
- ref="copyHeaders"
- v-tippy="{ theme: 'tooltip' }"
- :title="$t('action.copy')"
- :svg="copyIcon"
- @click.native="copyHeaders"
- />
- </div>
- </div>
- <div
- v-for="(header, index) in headers"
- :key="`header-${index}`"
- class="
- divide-x divide-dividerLight
- border-b border-dividerLight
- flex
- group
- "
- >
- <span
- class="
- flex flex-1
- min-w-0
- py-2
- px-4
- transition
- group-hover:text-secondaryDark
- "
- >
- <span class="rounded-sm select-all truncate">
- {{ header.key }}
- </span>
- </span>
- <span
- class="
- flex flex-1
- min-w-0
- py-2
- px-4
- transition
- group-hover:text-secondaryDark
- "
- >
- <span class="rounded-sm select-all truncate">
- {{ header.value }}
- </span>
- </span>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref, useContext } from "@nuxtjs/composition-api"
- import { HoppRESTHeader } from "~/helpers/types/HoppRESTRequest"
- import { copyToClipboard } from "~/helpers/utils/clipboard"
- const {
- $toast,
- app: { i18n },
- } = useContext()
- const t = i18n.t.bind(i18n)
- const props = defineProps<{
- headers: Array<HoppRESTHeader>
- }>()
- const copyIcon = ref("copy")
- const copyHeaders = () => {
- copyToClipboard(JSON.stringify(props.headers))
- copyIcon.value = "check"
- $toast.success(`${t("state.copied_to_clipboard")}`)
- setTimeout(() => (copyIcon.value = "copy"), 1000)
- }
- </script>
|