Skip to content

Commit

Permalink
Add integration action components and update integration JSON files
Browse files Browse the repository at this point in the history
- Introduced new action components for Email, Slack, Discord, Webhook, and Google Sheets integrations, enhancing the user interface for managing these integrations.
- Updated the `integrations.json` files to include `actions_file_name` for each integration, linking them to their respective action components.
- Improved the `GoogleSheetsIntegrationActions.vue` component by replacing direct provider information display with a badge for better UI consistency.

These changes aim to streamline integration management and improve the overall user experience.
  • Loading branch information
chiragchhatrala committed Dec 12, 2024
1 parent ea4cd85 commit 1352618
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 9 deletions.
4 changes: 4 additions & 0 deletions api/resources/data/forms/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"icon": "heroicons:envelope-20-solid",
"section_name": "Notifications",
"file_name": "EmailIntegration",
"actions_file_name": "EmailIntegrationActions",
"is_pro": false,
"crisp_help_page_slug": "can-i-receive-notifications-on-form-submissions-134svqv"
},
Expand All @@ -12,20 +13,23 @@
"icon": "mdi:slack",
"section_name": "Notifications",
"file_name": "SlackIntegration",
"actions_file_name": "SlackIntegrationActions",
"is_pro": true
},
"discord": {
"name": "Discord Notification",
"icon": "ic:baseline-discord",
"section_name": "Notifications",
"file_name": "DiscordIntegration",
"actions_file_name": "DiscordIntegrationActions",
"is_pro": true
},
"webhook": {
"name": "Webhook Notification",
"icon": "material-symbols:webhook",
"section_name": "Automation",
"file_name": "WebhookIntegration",
"actions_file_name": "WebhookIntegrationActions",
"is_pro": false
},
"zapier": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div class="flex flex-1 items-center">
<div
v-if="integration"
class="hidden md:block space-y-1"
>
<UBadge
:label="mentionAsText(integration.data.message)"
color="gray"
size="xs"
class="max-w-[300px] truncate"
/>
</div>
</div>
</template>

<script setup>
import { mentionAsText } from '~/lib/utils.js'
const props = defineProps({
integration: {
type: Object,
required: true,
},
form: {
type: Object,
required: true,
}
})
const formIntegrationsStore = useFormIntegrationsStore()
let interval = null
onMounted(() => {
if (!props.integration.data || props.integration.data.length === 0) {
interval = setInterval(() => formIntegrationsStore.fetchFormIntegrations(props.form.id), 3000)
setTimeout(() => { clearInterval(interval) }, 30000)
}
})
onBeforeUnmount(() => {
if (interval) {
clearInterval(interval)
}
})
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<template>
<div class="flex flex-1 items-center">
<div
v-if="integration"
class="hidden md:block space-y-1"
>
<UBadge
:label="mentionAsText(integration.data.subject)"
color="gray"
size="xs"
class="max-w-[300px] truncate"
/>
<div class="flex items-center gap-1">
<UBadge
:label="firstEmail(integration.data.send_to)"
color="white"
size="xs"
class="max-w-[300px] truncate"
/>
<UBadge
v-if="additionalEmailsCount(integration.data.send_to) > 0"
:label="`+${additionalEmailsCount(integration.data.send_to)}`"
color="white"
size="xs"
/>
</div>
</div>
</div>
</template>

<script setup>
import { mentionAsText } from '~/lib/utils.js'
const props = defineProps({
integration: {
type: Object,
required: true,
},
form: {
type: Object,
required: true,
}
})
const formIntegrationsStore = useFormIntegrationsStore()
let interval = null
onMounted(() => {
if (!props.integration.data || props.integration.data.length === 0) {
interval = setInterval(() => formIntegrationsStore.fetchFormIntegrations(props.form.id), 3000)
setTimeout(() => { clearInterval(interval) }, 30000)
}
})
onBeforeUnmount(() => {
if (interval) {
clearInterval(interval)
}
})
const firstEmail = (sendTo) => {
const emails = mentionAsText(sendTo).split('\n').filter(Boolean)
return emails[0] || ''
}
const additionalEmailsCount = (sendTo) => {
const emails = mentionAsText(sendTo).split('\n').filter(Boolean)
return Math.max(0, emails.length - 1)
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
v-if="integration.provider"
class="hidden md:block space-y-1"
>
<div
class="font-medium mr-2"
>
{{ integration.provider.name }}
</div>
<div class="text-sm">
{{ integration.provider.email }}
</div>
<UBadge
:label="mentionAsText(integration.provider.email)"
color="gray"
size="xs"
class="max-w-[300px] truncate"
/>
</div>

<div
Expand Down Expand Up @@ -39,6 +37,8 @@
</template>

<script setup>
import { mentionAsText } from '~/lib/utils.js'
const props = defineProps({
integration: {
type: Object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="text-gray-500 border shadow rounded-md p-5 mt-4 relative flex items-center"
>
<div
class="flex items-center"
class="flex items-center w-full md:w-1/4"
:class="{'flex-grow': !actionsComponent}"
>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div class="flex flex-1 items-center">
<div
v-if="integration"
class="hidden md:block space-y-1"
>
<UBadge
:label="mentionAsText(integration.data.message)"
color="gray"
size="xs"
class="max-w-[300px] truncate"
/>
</div>
</div>
</template>

<script setup>
import { mentionAsText } from '~/lib/utils.js'
const props = defineProps({
integration: {
type: Object,
required: true,
},
form: {
type: Object,
required: true,
}
})
const formIntegrationsStore = useFormIntegrationsStore()
let interval = null
onMounted(() => {
if (!props.integration.data || props.integration.data.length === 0) {
interval = setInterval(() => formIntegrationsStore.fetchFormIntegrations(props.form.id), 3000)
setTimeout(() => { clearInterval(interval) }, 30000)
}
})
onBeforeUnmount(() => {
if (interval) {
clearInterval(interval)
}
})
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<div class="flex flex-1 items-center">
<div
v-if="integration"
class="hidden md:block space-y-1"
>
<UBadge
:label="integration.data.webhook_url"
color="gray"
size="xs"
class="max-w-[300px] truncate"
/>
</div>
</div>
</template>

<script setup>
const props = defineProps({
integration: {
type: Object,
required: true,
},
form: {
type: Object,
required: true,
}
})
const formIntegrationsStore = useFormIntegrationsStore()
let interval = null
onMounted(() => {
if (!props.integration.data || props.integration.data.length === 0) {
interval = setInterval(() => formIntegrationsStore.fetchFormIntegrations(props.form.id), 3000)
setTimeout(() => { clearInterval(interval) }, 30000)
}
})
onBeforeUnmount(() => {
if (interval) {
clearInterval(interval)
}
})
</script>
4 changes: 4 additions & 0 deletions client/data/forms/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"icon": "heroicons:envelope-20-solid",
"section_name": "Notifications",
"file_name": "EmailIntegration",
"actions_file_name": "EmailIntegrationActions",
"is_pro": false,
"crisp_help_page_slug": "can-i-receive-notifications-on-form-submissions-134svqv"
},
Expand All @@ -12,20 +13,23 @@
"icon": "mdi:slack",
"section_name": "Notifications",
"file_name": "SlackIntegration",
"actions_file_name": "SlackIntegrationActions",
"is_pro": true
},
"discord": {
"name": "Discord Notification",
"icon": "ic:baseline-discord",
"section_name": "Notifications",
"file_name": "DiscordIntegration",
"actions_file_name": "DiscordIntegrationActions",
"is_pro": true
},
"webhook": {
"name": "Webhook Notification",
"icon": "material-symbols:webhook",
"section_name": "Automation",
"file_name": "WebhookIntegration",
"actions_file_name": "WebhookIntegrationActions",
"is_pro": false
},
"zapier": {
Expand Down
12 changes: 12 additions & 0 deletions client/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ export const customDomainUsed = function () {

return host !== appDomain && getDomain(host) !== appDomain
}

export const mentionAsText = (content) => {
if (!content) return ''

// Parse the content and style mentions
return content.replace(
/<span\s+mention-field-id="([^"]+)"\s+mention-field-name="([^"]+)"[^>]*>([^<]+)<\/span>/g,
(match, fieldId, fieldName, text) => {
return `${text}`
}
)
}

0 comments on commit 1352618

Please sign in to comment.