Beautiful Open-Source Form Builder
Refactor FormUrlPrefill component to use CopyContent for improved URL copying functionality
Julien Nahum9386a8c47051
diff --git a/client/components/open/forms/components/FormUrlPrefill.vue b/client/components/open/forms/components/FormUrlPrefill.vueindex e9a28e06c..61919e95a 100644--- a/client/components/open/forms/components/FormUrlPrefill.vue+++ b/client/components/open/forms/components/FormUrlPrefill.vue@@ -1,39 +1,19 @@<template>- <div- class="border border-blue-300 bg-blue-50 dark:bg-notion-dark-light shadow-sm rounded-sm p-4 mb-5 w-full mx-auto mt-4 select-all"- >- <div class="flex items-center">- <p- class="select-all flex-grow break-all"- v-html="preFillUrl"- />- <div- class="hover:bg-blue-100 rounded-sm transition-colors cursor-pointer"- @click="copyToClipboard"- >- <svg- xmlns="http://www.w3.org/2000/svg"- class="h-6 w-6 text-blue-500"- fill="none"- viewBox="0 0 24 24"- stroke="currentColor"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"- />- </svg>- </div>- </div>- </div>+ <CopyContent+ :content="preFillUrl"+ label="Copy URL"+ tracking-event="url_form_prefill_copy"+ :tracking-properties="{+ form_id: form.id,+ form_slug: form.slug,+ }"+ /></template><script setup>import { defineProps, computed } from "vue"import { default as _has } from "lodash/has"-const { copy } = useClipboard()+import CopyContent from "~/components/open/forms/components/CopyContent.vue"const props = defineProps({form: {@@ -80,10 +60,4 @@ const preFillUrl = computed(() => {return props.extraQueryParam ? url + "?" + props.extraQueryParam : url}})--const copyToClipboard = () => {- if (import.meta.server) return- copy(preFillUrl.value)- useAlert().success("Copied!")-}</script>diff --git a/client/components/pages/forms/show/UrlFormPrefill.vue b/client/components/pages/forms/show/UrlFormPrefill.vueindex 096af78fb..f6339b349 100644--- a/client/components/pages/forms/show/UrlFormPrefill.vue+++ b/client/components/pages/forms/show/UrlFormPrefill.vue@@ -73,16 +73,14 @@</OpenForm></div>- <template v-if="prefillFormData">- <h3 class="mt-6 text-xl font-semibold mb-4 pt-6">- Your Prefill url- </h3>- <FormUrlPrefill- :form="form"- :form-data="prefillFormData"- :extra-query-param="extraQueryParam"- />- </template>+ <h3 class="mt-6 text-xl font-semibold mb-4 pt-6">+ Your Prefill url+ </h3>+ <FormUrlPrefill+ :form="form"+ :form-data="prefillFormData || {}"+ :extra-query-param="extraQueryParam"+ /></div></template></UModal>