2024-03-28 18:14:30 +01:00
|
|
|
<template>
|
|
|
|
|
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl p-4">
|
|
|
|
|
<div class="mb-20">
|
|
|
|
|
<h1 class="font-semibold mt-4 text-xl">
|
|
|
|
|
Your integrations
|
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
|
|
<div class="text-sm text-gray-500">
|
|
|
|
|
Read, update and create data with dozens of 3rd-party integrations
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-if="integrationsLoading"
|
|
|
|
|
class="my-6"
|
|
|
|
|
>
|
|
|
|
|
<Loader class="h-6 w-6 mx-auto" />
|
2024-03-28 18:14:30 +01:00
|
|
|
</div>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-else-if="formIntegrationsList.length"
|
|
|
|
|
class="my-6"
|
|
|
|
|
>
|
|
|
|
|
<IntegrationCard
|
|
|
|
|
v-for="row in formIntegrationsList"
|
|
|
|
|
:key="row.id"
|
|
|
|
|
:integration="row"
|
|
|
|
|
:form="form"
|
|
|
|
|
/>
|
2024-03-28 18:14:30 +01:00
|
|
|
</div>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-else
|
|
|
|
|
class="text-gray-500 border shadow rounded-md p-5 mt-4"
|
|
|
|
|
>
|
2024-03-28 18:14:30 +01:00
|
|
|
No integration yet form this form.
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h1 class="font-semibold mt-8 text-xl">
|
|
|
|
|
Add a new integration
|
|
|
|
|
</h1>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-for="(section, sectionName) in sectionsList"
|
|
|
|
|
:key="sectionName"
|
|
|
|
|
class="mb-8"
|
|
|
|
|
>
|
2024-03-28 18:14:30 +01:00
|
|
|
<h3 class="text-gray-500">
|
|
|
|
|
{{ sectionName }}
|
|
|
|
|
</h3>
|
|
|
|
|
<div class="flex flex-wrap mt-2 gap-4">
|
2024-04-15 19:39:03 +02:00
|
|
|
<IntegrationListOption
|
|
|
|
|
v-for="(sectionItem, sectionItemKey) in section"
|
|
|
|
|
:key="sectionItemKey"
|
|
|
|
|
:integration="sectionItem"
|
|
|
|
|
@select="openIntegrationModal"
|
|
|
|
|
/>
|
2024-03-28 18:14:30 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-15 19:39:03 +02:00
|
|
|
<IntegrationModal
|
|
|
|
|
v-if="form && selectedIntegrationKey && selectedIntegration"
|
|
|
|
|
:form="form"
|
|
|
|
|
:integration="selectedIntegration"
|
|
|
|
|
:integration-key="selectedIntegrationKey"
|
|
|
|
|
:show="showIntegrationModal"
|
|
|
|
|
@close="closeIntegrationModal"
|
|
|
|
|
/>
|
2024-03-28 18:14:30 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-04-15 19:39:03 +02:00
|
|
|
import { computed } from "vue"
|
|
|
|
|
import IntegrationModal from "~/components/open/integrations/components/IntegrationModal.vue"
|
2024-03-28 18:14:30 +01:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
2024-04-15 19:39:03 +02:00
|
|
|
form: { type: Object, required: true },
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
definePageMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
middleware: "auth",
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
useOpnSeoMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: props.form
|
|
|
|
|
? "Form Integrations - " + props.form.title
|
|
|
|
|
: "Form Integrations",
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const alert = useAlert()
|
|
|
|
|
|
2024-06-05 15:35:46 +02:00
|
|
|
const oAuthProvidersStore = useOAuthProvidersStore()
|
|
|
|
|
|
2024-03-28 18:14:30 +01:00
|
|
|
const formIntegrationsStore = useFormIntegrationsStore()
|
|
|
|
|
const integrationsLoading = computed(() => formIntegrationsStore.loading)
|
2024-04-15 19:39:03 +02:00
|
|
|
const integrations = computed(
|
|
|
|
|
() => formIntegrationsStore.availableIntegrations,
|
|
|
|
|
)
|
|
|
|
|
const sectionsList = computed(
|
|
|
|
|
() => formIntegrationsStore.integrationsBySection,
|
|
|
|
|
)
|
|
|
|
|
const formIntegrationsList = computed(() =>
|
|
|
|
|
formIntegrationsStore.getAllByFormId(props.form.id),
|
|
|
|
|
)
|
2024-03-28 18:14:30 +01:00
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
const showIntegrationModal = ref(false)
|
|
|
|
|
const selectedIntegrationKey = ref(null)
|
|
|
|
|
const selectedIntegration = ref(null)
|
2024-03-28 18:14:30 +01:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
formIntegrationsStore.fetchFormIntegrations(props.form.id)
|
2024-06-05 15:35:46 +02:00
|
|
|
oAuthProvidersStore.fetchOAuthProviders(props.form.workspace_id)
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const openIntegrationModal = (itemKey) => {
|
2024-04-15 19:39:03 +02:00
|
|
|
if (!itemKey || !integrations.value.has(itemKey))
|
|
|
|
|
return alert.error("Integration not found")
|
|
|
|
|
if (integrations.value.get(itemKey).coming_soon)
|
|
|
|
|
return alert.warning("This integration is not available yet")
|
2024-03-28 18:14:30 +01:00
|
|
|
selectedIntegrationKey.value = itemKey
|
2024-04-15 19:39:03 +02:00
|
|
|
selectedIntegration.value = integrations.value.get(
|
|
|
|
|
selectedIntegrationKey.value,
|
|
|
|
|
)
|
2024-03-28 18:14:30 +01:00
|
|
|
showIntegrationModal.value = true
|
|
|
|
|
}
|
|
|
|
|
const closeIntegrationModal = () => {
|
|
|
|
|
showIntegrationModal.value = false
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
selectedIntegrationKey.value = null
|
|
|
|
|
selectedIntegration.value = null
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</script>
|