Beautiful Open-Source Form Builder
Remove old code related to notifications (#363)
Chirag Chhatrala35efd6711dcc
diff --git a/app/Http/Requests/Templates/FormTemplateRequest.php b/app/Http/Requests/Templates/FormTemplateRequest.phpindex 052f92dda..9d3f5b67b 100644--- a/app/Http/Requests/Templates/FormTemplateRequest.php+++ b/app/Http/Requests/Templates/FormTemplateRequest.php@@ -20,14 +20,6 @@ class FormTemplateRequest extends FormRequest'is_password_protected','last_edited_human','max_number_of_submissions_reached',- 'notifies',- 'notification_body',- 'notification_emails',- 'notification_sender',- 'notification_subject',- 'notifications_include_submission',- 'notifies_slack',- 'slack_webhook_url','removed_properties','creator_id','extra',@@ -50,14 +42,14 @@ class FormTemplateRequest extends FormRequest{$slugRule = '';if ($this->id) {- $slugRule = ','.$this->id;+ $slugRule = ',' . $this->id;}return ['form' => 'required|array','publicly_listed' => 'boolean','name' => 'required|string|max:60',- 'slug' => 'required|string|alpha_dash|unique:templates,slug'.$slugRule,+ 'slug' => 'required|string|alpha_dash|unique:templates,slug' . $slugRule,'short_description' => 'required|string|max:1000','description' => 'required|string','image_url' => 'required|string',diff --git a/app/Http/Requests/UserFormRequest.php b/app/Http/Requests/UserFormRequest.phpindex e75796a92..ee2bcac1b 100644--- a/app/Http/Requests/UserFormRequest.php+++ b/app/Http/Requests/UserFormRequest.php@@ -5,7 +5,6 @@ namespace App\Http\Requests;use App\Http\Requests\Workspace\CustomDomainRequest;use App\Models\Forms\Form;use App\Rules\FormPropertyLogicRule;-use App\Rules\OneEmailPerLine;use Illuminate\Validation\Rule;/**@@ -29,20 +28,6 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest'tags' => 'nullable|array','visibility' => ['required', Rule::in(Form::VISIBILITY)],- // Notifications- 'notifies' => 'boolean',- 'notification_emails' => ['required_if:notifies,1', new OneEmailPerLine()],- 'send_submission_confirmation' => 'boolean',- 'notification_sender' => 'string|max:64',- 'notification_subject' => 'string|max:200',- 'notification_body' => 'string|nullable',- 'notifications_include_submission' => 'boolean',- 'webhook_url' => 'url|nullable',- 'use_captcha' => 'boolean',- 'slack_webhook_url' => 'url|nullable',- 'discord_webhook_url' => 'url|nullable',- 'notification_settings' => 'nullable',-// Customization'theme' => ['required', Rule::in(Form::THEMES)],'width' => ['required', Rule::in(Form::WIDTHS)],@@ -125,10 +110,11 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest// Security & Privacy'can_be_indexed' => 'boolean','password' => 'sometimes|nullable',+ 'use_captcha' => 'boolean',// Custom SEO'seo_meta' => 'nullable|array',- 'custom_domain' => 'sometimes|nullable|regex:'.CustomDomainRequest::CUSTOM_DOMAINS_REGEX,+ 'custom_domain' => 'sometimes|nullable|regex:' . CustomDomainRequest::CUSTOM_DOMAINS_REGEX,];}diff --git a/app/Http/Resources/FormResource.php b/app/Http/Resources/FormResource.phpindex bec5b2baa..5c453af66 100644--- a/app/Http/Resources/FormResource.php+++ b/app/Http/Resources/FormResource.php@@ -18,34 +18,21 @@ class FormResource extends JsonResource*/public function toArray($request){- if (! $this->userIsFormOwner() && ProtectedForm::isProtected($request, $this->resource)) {+ if (!$this->userIsFormOwner() && ProtectedForm::isProtected($request, $this->resource)) {return $this->getProtectedForm();}$ownerData = $this->userIsFormOwner() ? ['views_count' => $this->views_count,'submissions_count' => $this->submissions_count,- 'notifies' => $this->notifies,- 'notifies_webhook' => $this->notifies_webhook,- 'notifies_slack' => $this->notifies_slack,- 'notifies_discord' => $this->notifies_discord,'send_submission_confirmation' => $this->send_submission_confirmation,- 'webhook_url' => $this->webhook_url,'redirect_url' => $this->redirect_url,'database_fields_update' => $this->database_fields_update,'cleanings' => $this->getCleanigns(),- 'notification_sender' => $this->notification_sender,- 'notification_subject' => $this->notification_subject,- 'notification_body' => $this->notification_body,- 'notifications_include_submission' => $this->notifications_include_submission,'can_be_indexed' => $this->can_be_indexed,'password' => $this->password,'tags' => $this->tags,'visibility' => $this->visibility,- 'notification_emails' => $this->notification_emails,- 'slack_webhook_url' => $this->slack_webhook_url,- 'discord_webhook_url' => $this->discord_webhook_url,- 'notification_settings' => $this->notification_settings,'removed_properties' => $this->removed_properties,'last_edited_human' => $this->updated_at?->diffForHumans(),'seo_meta' => $this->seo_meta,diff --git a/app/Listeners/Forms/NotifyFormSubmission.php b/app/Listeners/Forms/NotifyFormSubmission.phpindex ca362a3a3..a88fb8598 100644--- a/app/Listeners/Forms/NotifyFormSubmission.php+++ b/app/Listeners/Forms/NotifyFormSubmission.php@@ -15,34 +15,28 @@ class NotifyFormSubmission implements ShouldQueue/*** Sends notification to pre-defined emails on form submissions*- * @param object $event+ * @param object $event* @return void*/public function handle(FormSubmitted $event){- $formIntegrations = FormIntegration::where([['form_id', $event->form->id], ['status', FormIntegration::STATUS_ACTIVE]])->get();+ $formIntegrations = $event->form->integrations()->where('status', FormIntegration::STATUS_ACTIVE)->get();foreach ($formIntegrations as $formIntegration) {- ray($formIntegration, $formIntegration->integration_id);$this->getIntegrationHandler($event,$formIntegration)->run();}-- /* $this->sendEmailNotifications($event);- $this->sendWebhookNotification($event, WebhookHandlerProvider::SIMPLE_WEBHOOK_PROVIDER);- $this->sendWebhookNotification($event, WebhookHandlerProvider::SLACK_PROVIDER);- $this->sendWebhookNotification($event, WebhookHandlerProvider::DISCORD_PROVIDER);- foreach ($event->form->zappierHooks as $hook) {- $hook->triggerHook($event->data);- }- */}- public static function getIntegrationHandler(FormSubmitted $event, FormIntegration $formIntegration): AbstractIntegrationHandler- {+ public static function getIntegrationHandler(+ FormSubmitted $event,+ FormIntegration $formIntegration+ ): AbstractIntegrationHandler {$integration = FormIntegration::getIntegration($formIntegration->integration_id);- if ($integration && isset($integration['file_name']) && class_exists('App\Service\Forms\Integrations\\' . $integration['file_name'])) {+ if ($integration && isset($integration['file_name']) && class_exists(+ 'App\Service\Forms\Integrations\\' . $integration['file_name']+ )) {$className = 'App\Service\Forms\Integrations\\' . $integration['file_name'];return new $className($event, $formIntegration, $integration);}diff --git a/app/Models/Forms/Form.php b/app/Models/Forms/Form.phpindex a1fcc22f7..9b773d75c 100644--- a/app/Models/Forms/Form.php+++ b/app/Models/Forms/Form.php@@ -3,6 +3,7 @@namespace App\Models\Forms;use App\Events\Models\FormCreated;+use App\Models\Integration\FormIntegration;use App\Models\Integration\FormZapierWebhook;use App\Models\Traits\CachableAttributes;use App\Models\Traits\CachesAttributes;@@ -41,21 +42,6 @@ class Form extends Model implements CachableAttributes'properties','removed_properties',- // Notifications- 'notifies',- 'notification_emails',- 'send_submission_confirmation',- 'notification_sender',- 'notification_subject',- 'notification_body',- 'notifications_include_submission',- 'slack_webhook_url',- 'discord_webhook_url',- 'notification_settings',-- // integrations- 'webhook_url',-'title','description','tags',@@ -109,8 +95,7 @@ class Form extends Model implements CachableAttributes'closes_at' => 'datetime','tags' => 'array','removed_properties' => 'array',- 'seo_meta' => 'object',- 'notification_settings' => 'object',+ 'seo_meta' => 'object'];protected $appends = [@@ -119,20 +104,10 @@ class Form extends Model implements CachableAttributesprotected $hidden = ['workspace_id',- 'notifies',- 'slack_webhook_url',- 'discord_webhook_url',- 'webhook_url',- 'send_submission_confirmation','redirect_url','database_fields_update',- 'notification_sender',- 'notification_subject',- 'notification_body',- 'notifications_include_submission','password','tags',- 'notification_emails','removed_properties',];@@ -161,15 +136,15 @@ class Form extends Model implements CachableAttributespublic function getShareUrlAttribute(){if ($this->custom_domain) {- return 'https://'.$this->custom_domain.'/forms/'.$this->slug;+ return 'https://' . $this->custom_domain . '/forms/' . $this->slug;}- return front_url('/forms/'.$this->slug);+ return front_url('/forms/' . $this->slug);}public function getEditUrlAttribute(){- return front_url('/forms/'.$this->slug.'/show');+ return front_url('/forms/' . $this->slug . '/show');}public function getSubmissionsCountAttribute()@@ -218,7 +193,7 @@ class Form extends Model implements CachableAttributespublic function getFormPendingSubmissionKeyAttribute(){if ($this->updated_at?->timestamp) {- return 'openform-'.$this->id.'-pending-submission-'.substr($this->updated_at?->timestamp, -6);+ return 'openform-' . $this->id . '-pending-submission-' . substr($this->updated_at?->timestamp, -6);}return null;@@ -241,7 +216,7 @@ class Form extends Model implements CachableAttributespublic function getHasPasswordAttribute(){- return ! empty($this->password);+ return !empty($this->password);}public function getMaxFileSizeAttribute()@@ -293,6 +268,11 @@ class Form extends Model implements CachableAttributesreturn $this->hasMany(FormZapierWebhook::class);}+ public function integrations()+ {+ return $this->hasMany(FormIntegration::class);+ }+/*** Config/options*/@@ -301,7 +281,7 @@ class Form extends Model implements CachableAttributesreturn SlugOptions::create()->doNotGenerateSlugsOnUpdate()->generateSlugsFrom(function (Form $form) {- return $form->title.' '.Str::random(6);+ return $form->title . ' ' . Str::random(6);})->saveSlugsTo('slug');}@@ -310,19 +290,4 @@ class Form extends Model implements CachableAttributes{return FormFactory::new();}-- public function getNotifiesWebhookAttribute()- {- return ! empty($this->webhook_url);- }-- public function getNotifiesDiscordAttribute()- {- return ! empty($this->discord_webhook_url);- }-- public function getNotifiesSlackAttribute()- {- return ! empty($this->slack_webhook_url);- }}diff --git a/app/Models/Integration/FormZapierWebhook.php b/app/Models/Integration/FormZapierWebhook.phpindex ec84a8c84..77c579066 100644--- a/app/Models/Integration/FormZapierWebhook.php+++ b/app/Models/Integration/FormZapierWebhook.php@@ -3,7 +3,7 @@namespace App\Models\Integration;use App\Models\Forms\Form;-use App\Service\Forms\Integrations\WebhookHandlerProvider;+use App\Service\Forms\Webhooks\WebhookHandlerProvider;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\SoftDeletes;diff --git a/app/Service/Forms/Integrations/AbstractWebhookHandler.php b/app/Service/Forms/Integrations/AbstractWebhookHandler.phpdeleted file mode 100644index bee7f1fdd..000000000--- a/app/Service/Forms/Integrations/AbstractWebhookHandler.php+++ /dev/null@@ -1,67 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--use App\Models\Forms\Form;-use App\Service\Forms\FormSubmissionFormatter;-use Spatie\WebhookServer\WebhookCall;-use Vinkla\Hashids\Facades\Hashids;--abstract class AbstractWebhookHandler-{- public function __construct(protected Form $form, protected array $data)- {- }-- abstract protected function getProviderName(): ?string;-- abstract protected function getWebhookUrl(): ?string;-- /**- * Default webhook payload. Can be changed in child classes.- */- protected function getWebhookData(): array- {- $formatter = (new FormSubmissionFormatter($this->form, $this->data))- ->useSignedUrlForFiles()- ->showHiddenFields();-- $formattedData = [];- foreach ($formatter->getFieldsWithValue() as $field) {- $formattedData[$field['name']] = $field['value'];- }-- $data = [- 'form_title' => $this->form->title,- 'form_slug' => $this->form->slug,- 'submission' => $formattedData,- ];- if ($this->form->is_pro && $this->form->editable_submissions) {- $data['edit_link'] = $this->form->share_url.'?submission_id='.Hashids::encode($this->data['submission_id']);- }-- return $data;- }-- abstract protected function shouldRun(): bool;-- public function handle()- {- if (! $this->shouldRun()) {- return;- }-- WebhookCall::create()- // Add context on error, used to notify form owner- ->meta([- 'type' => 'form_submission',- 'data' => $this->data,- 'form' => $this->form,- 'provider' => $this->getProviderName(),- ])- ->url($this->getWebhookUrl())- ->doNotSign()- ->payload($this->getWebhookData())- ->dispatchSync();- }-}diff --git a/app/Service/Forms/Integrations/DiscordHandler.php b/app/Service/Forms/Integrations/DiscordHandler.phpdeleted file mode 100644index 30bbbabb5..000000000--- a/app/Service/Forms/Integrations/DiscordHandler.php+++ /dev/null@@ -1,86 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--use App\Service\Forms\FormSubmissionFormatter;-use Illuminate\Support\Arr;-use Vinkla\Hashids\Facades\Hashids;--class DiscordHandler extends AbstractWebhookHandler-{- protected function getProviderName(): string- {- return 'Discord';- }-- protected function getWebhookUrl(): ?string- {- return $this->form->discord_webhook_url;- }-- protected function getWebhookData(): array- {- $settings = (array) Arr::get((array) $this->form->notification_settings, 'discord', []);- $externalLinks = [];- if (Arr::get($settings, 'link_open_form', true)) {- $externalLinks[] = '[**π Open Form**]('.$this->form->share_url.')';- }- if (Arr::get($settings, 'link_edit_form', true)) {- $editFormURL = front_url('forms/'.$this->form->slug.'/show');- $externalLinks[] = '[**βοΈ Edit Form**]('.$editFormURL.')';- }- if (Arr::get($settings, 'link_edit_submission', true) && $this->form->editable_submissions) {- $submissionId = Hashids::encode($this->data['submission_id']);- $externalLinks[] = '[**βοΈ '.$this->form->editable_submissions_button_text.'**]('.$this->form->share_url.'?submission_id='.$submissionId.')';- }-- $color = hexdec(str_replace('#', '', $this->form->color));- $blocks = [];- if (Arr::get($settings, 'include_submission_data', true)) {- $submissionString = '';- $formatter = (new FormSubmissionFormatter($this->form, $this->data))->outputStringsOnly();- foreach ($formatter->getFieldsWithValue() as $field) {- $tmpVal = is_array($field['value']) ? implode(',', $field['value']) : $field['value'];- $submissionString .= '**'.ucfirst($field['name']).'**: '.$tmpVal."\n";- }- $blocks[] = [- 'type' => 'rich',- 'color' => $color,- 'description' => $submissionString,- ];- }-- if (Arr::get($settings, 'views_submissions_count', true)) {- $countString = '**π Views**: '.(string) $this->form->views_count." \n";- $countString .= '**ποΈ Submissions**: '.(string) $this->form->submissions_count;- $blocks[] = [- 'type' => 'rich',- 'color' => $color,- 'description' => $countString,- ];- }-- if (count($externalLinks) > 0) {- $blocks[] = [- 'type' => 'rich',- 'color' => $color,- 'description' => implode(' - ', $externalLinks),- ];- }-- return [- 'content' => 'New submission for your form **'.$this->form->title.'**',- 'tts' => false,- 'username' => config('app.name'),- 'avatar_url' => asset('img/logo.png'),- 'embeds' => $blocks,- ];- }-- protected function shouldRun(): bool- {- return ! is_null($this->getWebhookUrl())- && str_contains($this->getWebhookUrl(), 'https://discord.com/api/webhooks')- && $this->form->is_pro;- }-}diff --git a/app/Service/Forms/Integrations/SimpleWebhookHandler.php b/app/Service/Forms/Integrations/SimpleWebhookHandler.phpdeleted file mode 100644index 1d2b9cea2..000000000--- a/app/Service/Forms/Integrations/SimpleWebhookHandler.php+++ /dev/null@@ -1,21 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--class SimpleWebhookHandler extends AbstractWebhookHandler-{- protected function getProviderName(): string- {- return 'webhook';- }-- protected function getWebhookUrl(): ?string- {- return $this->form->webhook_url;- }-- protected function shouldRun(): bool- {- return ! is_null($this->getWebhookUrl()) && $this->form->is_pro;- }-}diff --git a/app/Service/Forms/Integrations/SlackHandler.php b/app/Service/Forms/Integrations/SlackHandler.phpdeleted file mode 100644index 97d5dce72..000000000--- a/app/Service/Forms/Integrations/SlackHandler.php+++ /dev/null@@ -1,96 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--use App\Service\Forms\FormSubmissionFormatter;-use Illuminate\Support\Arr;-use Vinkla\Hashids\Facades\Hashids;--class SlackHandler extends AbstractWebhookHandler-{- protected function getProviderName(): string- {- return 'Slack';- }-- protected function getWebhookUrl(): ?string- {- return $this->form->slack_webhook_url;- }-- protected function getWebhookData(): array- {- $settings = (array) Arr::get((array) $this->form->notification_settings, 'slack', []);- $externalLinks = [];- if (Arr::get($settings, 'link_open_form', true)) {- $externalLinks[] = '*<'.$this->form->share_url.'|π Open Form>*';- }- if (Arr::get($settings, 'link_edit_form', true)) {- $editFormURL = front_url('forms/'.$this->form->slug.'/show');- $externalLinks[] = '*<'.$editFormURL.'|βοΈ Edit Form>*';- }- if (Arr::get($settings, 'link_edit_submission', true) && $this->form->editable_submissions) {- $submissionId = Hashids::encode($this->data['submission_id']);- $externalLinks[] = '*<'.$this->form->share_url.'?submission_id='.$submissionId.'|βοΈ '.$this->form->editable_submissions_button_text.'>*';- }-- $blocks = [- [- 'type' => 'section',- 'text' => [- 'type' => 'mrkdwn',- 'text' => 'New submission for your form *'.$this->form->title.'*',- ],- ],- ];-- if (Arr::get($settings, 'include_submission_data', true)) {- $submissionString = '';- $formatter = (new FormSubmissionFormatter($this->form, $this->data))->outputStringsOnly();- foreach ($formatter->getFieldsWithValue() as $field) {- $tmpVal = is_array($field['value']) ? implode(',', $field['value']) : $field['value'];- $submissionString .= '>*'.ucfirst($field['name']).'*: '.$tmpVal." \n";- }- $blocks[] = [- 'type' => 'section',- 'text' => [- 'type' => 'mrkdwn',- 'text' => $submissionString,- ],- ];- }-- if (Arr::get($settings, 'views_submissions_count', true)) {- $countString = '*π Views*: '.(string) $this->form->views_count." \n";- $countString .= '*ποΈ Submissions*: '.(string) $this->form->submissions_count;- $blocks[] = [- 'type' => 'section',- 'text' => [- 'type' => 'mrkdwn',- 'text' => $countString,- ],- ];- }-- if (count($externalLinks) > 0) {- $blocks[] = [- 'type' => 'section',- 'text' => [- 'type' => 'mrkdwn',- 'text' => implode(' ', $externalLinks),- ],- ];- }-- return [- 'blocks' => $blocks,- ];- }-- protected function shouldRun(): bool- {- return ! is_null($this->getWebhookUrl())- && str_contains($this->getWebhookUrl(), 'https://hooks.slack.com/')- && $this->form->is_pro;- }-}diff --git a/app/Service/Forms/Integrations/WebhookHandlerProvider.php b/app/Service/Forms/Integrations/WebhookHandlerProvider.phpdeleted file mode 100644index 1c2efd9c4..000000000--- a/app/Service/Forms/Integrations/WebhookHandlerProvider.php+++ /dev/null@@ -1,36 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--use App\Models\Forms\Form;--class WebhookHandlerProvider-{- public const SLACK_PROVIDER = 'slack';-- public const DISCORD_PROVIDER = 'discord';-- public const SIMPLE_WEBHOOK_PROVIDER = 'webhook';-- public const ZAPIER_PROVIDER = 'zapier';-- public static function getProvider(Form $form, array $data, string $provider, ?string $webhookUrl = null)- {- switch ($provider) {- case self::SLACK_PROVIDER:- return new SlackHandler($form, $data);- case self::DISCORD_PROVIDER:- return new DiscordHandler($form, $data);- case self::SIMPLE_WEBHOOK_PROVIDER:- return new SimpleWebhookHandler($form, $data);- case self::ZAPIER_PROVIDER:- if (is_null($webhookUrl)) {- throw new \Exception('Zapier webhook url is required');- }-- return new ZapierHandler($form, $data, $webhookUrl);- default:- throw new \Exception('Unknown webhook provider');- }- }-}diff --git a/app/Service/Forms/Integrations/ZapierHandler.php b/app/Service/Forms/Integrations/ZapierHandler.phpdeleted file mode 100644index 4d3c80138..000000000--- a/app/Service/Forms/Integrations/ZapierHandler.php+++ /dev/null@@ -1,27 +0,0 @@-<?php--namespace App\Service\Forms\Integrations;--use App\Models\Forms\Form;--class ZapierHandler extends AbstractWebhookHandler-{- public function __construct(protected Form $form, protected array $data, protected string $webhookUrl)- {- }-- protected function getProviderName(): ?string- {- return 'zapier';- }-- protected function getWebhookUrl(): string- {- return $this->webhookUrl;- }-- protected function shouldRun(): bool- {- return ! is_null($this->getWebhookUrl());- }-}diff --git a/client/components/open/forms/components/FormEditor.vue b/client/components/open/forms/components/FormEditor.vueindex 1500074a1..61de07966 100644--- a/client/components/open/forms/components/FormEditor.vue+++ b/client/components/open/forms/components/FormEditor.vue@@ -58,7 +58,6 @@<form-information /><form-structure /><form-customization />- <form-notifications /><form-about-submission /><form-access /><form-security-privacy />@@ -90,7 +89,6 @@ import FormStructure from './form-components/FormStructure.vue'import FormCustomization from './form-components/FormCustomization.vue'import FormCustomCode from './form-components/FormCustomCode.vue'import FormAboutSubmission from './form-components/FormAboutSubmission.vue'-import FormNotifications from './form-components/FormNotifications.vue'import FormEditorPreview from './form-components/FormEditorPreview.vue'import FormSecurityPrivacy from './form-components/FormSecurityPrivacy.vue'import FormCustomSeo from './form-components/FormCustomSeo.vue'@@ -104,7 +102,6 @@ export default {components: {FormEditorSidebar,FormEditorPreview,- FormNotifications,FormAboutSubmission,FormCustomCode,FormCustomization,diff --git a/client/components/open/forms/components/form-components/FormNotifications.vue b/client/components/open/forms/components/form-components/FormNotifications.vuedeleted file mode 100644index 32fd16e4b..000000000--- a/client/components/open/forms/components/form-components/FormNotifications.vue+++ /dev/null@@ -1,61 +0,0 @@-<template>- <editor-options-panel name="Notifications & Integrations" :already-opened="true" :has-pro-tag="true">- <template #icon>- <svg class="h-5 w-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">- <path d="M22 6C22 4.9 21.1 4 20 4H4C2.9 4 2 4.9 2 6M22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6M22 6L12 13L2 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>- </svg>- </template>-- <form-notifications-option class="mt-2" />- <form-notifications-submission-confirmation />- <form-notifications-slack />- <form-notifications-discord />- <form-notifications-webhook />- <v-button color="white"- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- :href="zapierUrl" target="_blank"- >- <div class="flex-grow flex items-center">- <svg class="w-5 h-5 inline text-yellow-500" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">- <path- d="M318 256c0 19-4 36-10 52-16 7-34 10-52 10-19 0-36-3-52-9-7-17-10-34-10-53 0-18 3-36 10-52 16-6 33-10 52-10 18 0 36 4 52 10 6 16 10 34 10 52zm182-41H355l102-102c-8-11-17-22-26-32-10-9-21-18-32-26L297 157V12c-13-2-27-3-41-3s-28 1-41 3v145L113 55c-12 8-22 17-32 26-10 10-19 21-27 32l102 102H12s-3 27-3 41 1 28 3 41h144L54 399c16 23 36 43 59 59l102-102v144c13 2 27 3 41 3s28-1 41-3V356l102 102c11-8 22-17 32-27 9-10 18-20 26-32L355 297h145c2-13 3-27 3-41s-1-28-3-41z"- />- </svg>- <p class="flex-grow text-center font-normal">- Zapier Integration- </p>- </div>- </v-button>-- </editor-options-panel>-</template>--<script>-import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'-import FormNotificationsOption from './components/FormNotificationsOption.vue'-import FormNotificationsSlack from './components/FormNotificationsSlack.vue'-import FormNotificationsDiscord from './components/FormNotificationsDiscord.vue'-import FormNotificationsSubmissionConfirmation from './components/FormNotificationsSubmissionConfirmation.vue'-import FormNotificationsWebhook from './components/FormNotificationsWebhook.vue'-import opnformConfig from "~/opnform.config.js";--export default {- components: { FormNotificationsSubmissionConfirmation, FormNotificationsSlack, FormNotificationsDiscord, FormNotificationsOption, EditorOptionsPanel, FormNotificationsWebhook },- props: {},- setup () {- const workingFormStore = useWorkingFormStore()- const {content: form} = storeToRefs(workingFormStore)- return {- workingFormStore,- form,- opnformConfig- }- },-- computed: {- zapierUrl () {- return opnformConfig.links.zapier_integration- }- },-}-</script>diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsDiscord.vue b/client/components/open/forms/components/form-components/components/FormNotificationsDiscord.vuedeleted file mode 100644index 89ba8596a..000000000--- a/client/components/open/forms/components/form-components/components/FormNotificationsDiscord.vue+++ /dev/null@@ -1,90 +0,0 @@-<template>- <div>- <button- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- @click.prevent="showModal=true"- >- <div class="flex-grow flex items-center">- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 inline" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M7.5 7.5c3.5 -1 5.5 -1 9 0"></path><path d="M7 16.5c3.5 1 6.5 1 10 0"></path><path d="M15.5 17c0 1 1.5 3 2 3c1.5 0 2.833 -1.667 3.5 -3c.667 -1.667 .5 -5.833 -1.5 -11.5c-1.457 -1.015 -3 -1.34 -4.5 -1.5l-1 2.5"></path><path d="M8.5 17c0 1 -1.356 3 -1.832 3c-1.429 0 -2.698 -1.667 -3.333 -3c-.635 -1.667 -.476 -5.833 1.428 -11.5c1.388 -1.015 2.782 -1.34 4.237 -1.5l1 2.5"></path></svg>- <p class="flex-grow text-center">- Discord Notifications- </p>- </div>- <div v-if="form.notifies_discord">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 text-nt-blue"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </div>- </button>- <modal :show="showModal" @close="showModal=false">- <h2 class="text-2xl font-bold z-10 truncate mb-5 text-nt-blue">- Discord Notifications- <pro-tag />- </h2>- <toggle-switch-input name="notifies_discord" :form="form" class="mt-4"- label="Receive a Discord notification on submission"- />- <template v-if="form.notifies_discord">- <text-input name="discord_webhook_url" :form="form" class="mt-4"- label="Discord webhook url" help="help"- >- <template #help>- Receive a discord message on each form submission.- <a href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks" target="_blank">Click- here</a> to learn how to get a discord webhook url.- </template>- </text-input>- <h4 class="font-bold mt-4">Discord message actions</h4>- <form-notifications-message-actions v-model="form.notification_settings.discord" />- </template>- </modal>- </div>-</template>--<script>-import { useWorkingFormStore } from '../../../../../../stores/working_form'-import ProTag from '~/components/global/ProTag.vue'-import FormNotificationsMessageActions from './FormNotificationsMessageActions.vue'--export default {- components: { ProTag, FormNotificationsMessageActions },- props: {},- setup () {- const workingFormStore = useWorkingFormStore()- return {- workingFormStore- }- },- data () {- return {- showModal: false- }- },-- computed: {- form: {- get () {- return this.workingFormStore.content- },- /* We add a setter */- set (value) {- this.workingFormStore.set(value)- }- }- },-- watch: {},-- mounted () {- if(!this.form.notification_settings.discord || Array.isArray(this.form.notification_settings.discord)){- this.form.notification_settings.discord = {}- }- },-- methods: {}-}-</script>diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsOption.vue b/client/components/open/forms/components/form-components/components/FormNotificationsOption.vuedeleted file mode 100644index df54c19ae..000000000--- a/client/components/open/forms/components/form-components/components/FormNotificationsOption.vue+++ /dev/null@@ -1,94 +0,0 @@-<template>- <div>- <button- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- @click.prevent="showModal=true"- >- <div class="flex-grow flex items-center">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 inline"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"- />- </svg>- <p class="flex-grow text-center">- Email Notifications- </p>- </div>- <div v-if="form.notifies">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 text-nt-blue"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </div>- </button>- <modal :show="showModal" @close="showModal=false">- <h2 class="text-2xl font-bold z-10 truncate mb-5 text-nt-blue">- Form Notifications- <pro-tag />- </h2>- <toggle-switch-input name="notifies" :form="form" class="mt-4"- label="Receive email notifications on submission"-- />- <template v-if="form.notifies">- <text-input name="notification_reply_to"- v-model="form.notification_settings.notification_reply_to" class="mt-4"- label="Notification Reply To"- :help="notifiesHelp"- />- <text-area-input name="notification_emails" :form="form" class="mt-4"- label="Notification Emails" help="Add one email per line"- />- </template>- </modal>- </div>-</template>--<script>-import ProTag from '~/components/global/ProTag.vue'--export default {- components: { ProTag },- setup () {- const workingFormStore = useWorkingFormStore()- const {content: form} = storeToRefs(workingFormStore)- return {- form,- workingFormStore- }- },- data () {- return {- showModal: false- }- },-- computed: {- replayToEmailField () {- const emailFields = this.form.properties.filter((field) => {- return field.type === 'email' && !field.hidden- })- if (emailFields.length === 1) return emailFields[0]- return null- },- notifiesHelp () {- if (this.replayToEmailField) {- return 'If empty, Reply-to for this notification will be the email filled in the field "' + this.replayToEmailField.name + '".'- }- return 'If empty, Reply-to for this notification will be your own email. Add a single email field to your form, and it will automatically become the reply to value.'- }- },-- watch: {},-- mounted () {- },-- methods: {}-}-</script>diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsSlack.vue b/client/components/open/forms/components/form-components/components/FormNotificationsSlack.vuedeleted file mode 100644index 8e1d13d47..000000000--- a/client/components/open/forms/components/form-components/components/FormNotificationsSlack.vue+++ /dev/null@@ -1,91 +0,0 @@-<template>- <div>- <button- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- @click.prevent="showModal=true"- >- <div class="flex-grow flex items-center">- <svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 inline" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 10c-.83 0-1.5-.67-1.5-1.5v-5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5v5c0 .83-.67 1.5-1.5 1.5z" /><path d="M20.5 10H19V8.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z" /><path d="M9.5 14c.83 0 1.5.67 1.5 1.5v5c0 .83-.67 1.5-1.5 1.5S8 21.33 8 20.5v-5c0-.83.67-1.5 1.5-1.5z" /><path d="M3.5 14H5v1.5c0 .83-.67 1.5-1.5 1.5S2 16.33 2 15.5 2.67 14 3.5 14z" /><path d="M14 14.5c0-.83.67-1.5 1.5-1.5h5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-5c-.83 0-1.5-.67-1.5-1.5z" /><path d="M15.5 19H14v1.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z" /><path d="M10 9.5C10 8.67 9.33 8 8.5 8h-5C2.67 8 2 8.67 2 9.5S2.67 11 3.5 11h5c.83 0 1.5-.67 1.5-1.5z" /><path d="M8.5 5H10V3.5C10 2.67 9.33 2 8.5 2S7 2.67 7 3.5 7.67 5 8.5 5z" /></svg>- <p class="flex-grow text-center">- Slack Notifications- </p>- </div>- <div v-if="form.notifies_slack">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 text-nt-blue"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </div>- </button>- <modal :show="showModal" @close="showModal=false">- <h2 class="text-2xl font-bold z-10 truncate mb-5 text-nt-blue">- Slack Notifications- <pro-tag />- </h2>- <toggle-switch-input name="notifies_slack" :form="form" class="mt-4"- label="Receive a Slack notification on submission"- />- <template v-if="form.notifies_slack">- <text-input name="slack_webhook_url" :form="form" class="mt-4"- label="Slack webhook url" help="help"- >- <template #help>- Receive slack message on each form submission. <a href="https://api.slack.com/messaging/webhooks"- target="_blank"- >Click here</a> to learn how to get a slack- webhook url- </template>- </text-input>- <h4 class="font-bold mt-4">Slack message actions</h4>- <form-notifications-message-actions v-model="form.notification_settings.slack" />- </template>- </modal>- </div>-</template>--<script>-import { useWorkingFormStore } from '../../../../../../stores/working_form'-import ProTag from '~/components/global/ProTag.vue'-import FormNotificationsMessageActions from './FormNotificationsMessageActions.vue'--export default {- components: { ProTag, FormNotificationsMessageActions },- props: {},- setup () {- const workingFormStore = useWorkingFormStore()- return {- workingFormStore- }- },- data () {- return {- showModal: false- }- },-- computed: {- form: {- get () {- return this.workingFormStore.content- },- /* We add a setter */- set (value) {- this.workingFormStore.set(value)- }- }- },-- watch: {},-- mounted () {- if(!this.form.notification_settings.slack || Array.isArray(this.form.notification_settings.slack)){- this.form.notification_settings.slack = {}- }- },-- methods: {}-}-</script>diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsSubmissionConfirmation.vue b/client/components/open/forms/components/form-components/components/FormNotificationsSubmissionConfirmation.vuedeleted file mode 100644index f45e7b270..000000000--- a/client/components/open/forms/components/form-components/components/FormNotificationsSubmissionConfirmation.vue+++ /dev/null@@ -1,122 +0,0 @@-<template>- <div>- <button- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- @click.prevent="showModal=true"- >- <div class="flex-grow flex items-center">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">- <path stroke-linecap="round" stroke-linejoin="round" d="M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5" />- </svg>- <p class="flex-grow text-center">- Send submission confirmation- </p>- </div>- <div v-if="form.send_submission_confirmation">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 text-nt-blue"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </div>- </button>- <modal :show="showModal" @close="showModal=false">- <h2 class="text-2xl font-bold z-10 truncate mb-5 text-nt-blue">- Submission confirmation- <pro-tag />- </h2>- <toggle-switch-input :disabled="(emailSubmissionConfirmationField===null)?true:null" name="send_submission_confirmation"- :form="form" class="mt-4"- label="Send submission confirmation" :help="emailSubmissionConfirmationHelp"- />- <template v-if="form.send_submission_confirmation">- <text-input v-model="form.notification_settings.confirmation_reply_to"- name="confirmation_reply_to" class="mt-4"- label="Confirmation Reply To" help="help"- >- <template #help>- If empty, Reply-to will be your own email.- </template>- </text-input>- <text-input name="notification_sender"- :form="form" class="mt-4"- label="Confirmation Email Sender Name" help="Emails will be sent from our email address but you can customize the name of the Sender"- />- <text-input name="notification_subject"- :form="form" class="mt-4"- label="Confirmation email subject" help="Subject of the confirmation email that will be sent"- />- <rich-text-area-input name="notification_body"- :form="form" class="mt-4"- label="Confirmation email content" help="Content of the confirmation email that will be sent"- />- <toggle-switch-input name="notifications_include_submission"- :form="form" class="mt-4"- label="Include submission data" help="If enabled the confirmation email will contain form submission answers"- />- </template>- </modal>- </div>-</template>--<script>-import { useWorkingFormStore } from '../../../../../../stores/working_form'-import ProTag from '~/components/global/ProTag.vue'--export default {- components: { ProTag },- props: {},- setup () {- const workingFormStore = useWorkingFormStore()- return {- workingFormStore- }- },- data () {- return {- showModal: false- }- },-- computed: {- form: {- get () {- return this.workingFormStore.content- },- /* We add a setter */- set (value) {- this.workingFormStore.set(value)- }- },- emailSubmissionConfirmationField () {- if (!this.form.properties || !Array.isArray(this.form.properties)) return null- const emailFields = this.form.properties.filter((field) => {- return field.type === 'email' && !field.hidden- })- if (emailFields.length === 1) return emailFields[0]- return null- },- emailSubmissionConfirmationHelp () {- if (this.emailSubmissionConfirmationField) {- return 'Confirmation will be sent to the email in the "' + this.emailSubmissionConfirmationField.name + '" field.'- }- return 'Only available if your form contains 1 email field.'- }- },-- watch: {- emailSubmissionConfirmationField (val) {- if (val === null) {- this.form.send_submission_confirmation = false- }- }- },-- mounted () {- },-- methods: {}-}-</script>diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsWebhook.vue b/client/components/open/forms/components/form-components/components/FormNotificationsWebhook.vuedeleted file mode 100644index bfe7ac5f2..000000000--- a/client/components/open/forms/components/form-components/components/FormNotificationsWebhook.vue+++ /dev/null@@ -1,89 +0,0 @@-<template>- <div>- <button- class="flex items-center mt-3 cursor-pointer relative w-full rounded-lg flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full py-2 px-4 bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100"- @click.prevent="showModal=true"- >- <div class="flex-grow flex items-center">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 inline"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 01-.657.643 48.39 48.39 0 01-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 01-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 00-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 01-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 00.657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 01-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 005.427-.63 48.05 48.05 0 00.582-4.717.532.532 0 00-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 00.658-.663 48.422 48.422 0 00-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 01-.61-.58v0z"- />- </svg>- <p class="flex-grow text-center">- Webhook Notifications- </p>- </div>- <div v-if="form.notifies_webhook">- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"- class="w-5 h-5 text-nt-blue"- >- <path stroke-linecap="round" stroke-linejoin="round"- d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"- />- </svg>- </div>- </button>- <modal :show="showModal" @close="showModal=false">- <h2 class="text-2xl font-bold z-10 truncate mb-5 text-nt-blue">- Webhook Notifications- <pro-tag />- </h2>- <toggle-switch-input name="notifies_webhook" :form="form" class="mt-4"- label="Trigger a webhook notification on form submission"- @change="onToggleChange"- />- <text-input v-if="form.notifies_webhook" name="webhook_url" :form="form" class="mt-4"- label="Webhook url" help="We will post form submissions to this endpoint"- />- </modal>- </div>-</template>--<script>-import { useWorkingFormStore } from '../../../../../../stores/working_form'-import ProTag from '~/components/global/ProTag.vue'--export default {- components: { ProTag },- props: {},- setup () {- const workingFormStore = useWorkingFormStore()- return {- workingFormStore- }- },- data () {- return {- showModal: false- }- },-- computed: {- form: {- get () {- return this.workingFormStore.content- },- /* We add a setter */- set (value) {- this.workingFormStore.set(value)- }- }- },-- watch: {},-- mounted () {- },-- methods: {- onToggleChange () {- if (!this.form.notifies_webhook) {- this.form.webhook_url = ''- }- }- }-}-</script>diff --git a/client/components/open/integrations/DiscordIntegration.vue b/client/components/open/integrations/DiscordIntegration.vueindex c793a6b1a..99493dde9 100644--- a/client/components/open/integrations/DiscordIntegration.vue+++ b/client/components/open/integrations/DiscordIntegration.vue@@ -15,14 +15,13 @@</template></text-input><h4 class="font-bold mt-4">Discord message options</h4>- <form-notifications-message-actions v-model="integrationData.settings"/>+ <notifications-message-actions v-model="integrationData.settings"/></IntegrationWrapper></template><script setup>import IntegrationWrapper from "./components/IntegrationWrapper.vue"-import FormNotificationsMessageActions- from "~/components/open/forms/components/form-components/components/FormNotificationsMessageActions.vue"+import NotificationsMessageActions from "./components/NotificationsMessageActions.vue"const props = defineProps({integration: {type: Object, required: true},diff --git a/client/components/open/integrations/SlackIntegration.vue b/client/components/open/integrations/SlackIntegration.vueindex 82edfc2a8..bbc4786a6 100644--- a/client/components/open/integrations/SlackIntegration.vue+++ b/client/components/open/integrations/SlackIntegration.vue@@ -14,14 +14,13 @@</template></text-input><h4 class="font-bold mt-4">Slack message actions</h4>- <form-notifications-message-actions v-model="integrationData.settings"/>+ <notifications-message-actions v-model="integrationData.settings"/></IntegrationWrapper></template><script setup>import IntegrationWrapper from "./components/IntegrationWrapper.vue"-import FormNotificationsMessageActions- from "~/components/open/forms/components/form-components/components/FormNotificationsMessageActions.vue"+import NotificationsMessageActions from "./components/NotificationsMessageActions.vue"const props = defineProps({integration: {type: Object, required: true},diff --git a/client/components/open/forms/components/form-components/components/FormNotificationsMessageActions.vue b/client/components/open/integrations/components/NotificationsMessageActions.vuesimilarity index 97%rename from client/components/open/forms/components/form-components/components/FormNotificationsMessageActions.vuerename to client/components/open/integrations/components/NotificationsMessageActions.vueindex 35f9eb2aa..6a66d0f8d 100644--- a/client/components/open/forms/components/form-components/components/FormNotificationsMessageActions.vue+++ b/client/components/open/integrations/components/NotificationsMessageActions.vue@@ -23,7 +23,7 @@<script>export default {- name: 'FormNotificationsMessageActions',+ name: 'NotificationsMessageActions',components: { },props: {modelValue: { required: false }diff --git a/client/composables/forms/initForm.js b/client/composables/forms/initForm.jsindex c2f969cdf..d5a867d9b 100644--- a/client/composables/forms/initForm.js+++ b/client/composables/forms/initForm.js@@ -8,12 +8,6 @@ export const initForm = (defaultValue = {}, withDefaultProperties = false) => {workspace_id: null,properties: withDefaultProperties ? getDefaultProperties() :[],- notifies: false,- slack_notifies: false,- send_submission_confirmation: false,- webhook_url: null,- notification_settings: {},-// Customizationtheme: 'default',width: 'centered',@@ -32,10 +26,6 @@ export const initForm = (defaultValue = {}, withDefaultProperties = false) => {re_fillable: false,re_fill_button_text: 'Fill Again',submitted_text: 'Amazing, we saved your answers. Thank you for your time and have a great day!',- notification_sender: 'OpnForm',- notification_subject: 'We saved your answers',- notification_body: 'Hello there π <br>This is a confirmation that your submission was successfully saved.',- notifications_include_submission: true,use_captcha: false,max_submissions_count: null,max_submissions_reached_text: 'This form has now reached the maximum number of allowed submissions and is now closed.',diff --git a/client/pages/forms/[slug]/edit.vue b/client/pages/forms/[slug]/edit.vueindex fc9b98afa..f9f23b624 100644--- a/client/pages/forms/[slug]/edit.vue+++ b/client/pages/forms/[slug]/edit.vue@@ -50,10 +50,6 @@ function initUpdatedForm() {return}formInitialHash.value = hash(JSON.stringify(updatedForm.value.data()))-- if (updatedForm.value && (!updatedForm.value.notification_settings || Array.isArray(updatedForm.value.notification_settings))) {- updatedForm.value.notification_settings = {}- }}// Create a form.id watcher that updates working formdiff --git a/database/factories/FormFactory.php b/database/factories/FormFactory.phpindex 55d8fcd24..a3482749a 100644--- a/database/factories/FormFactory.php+++ b/database/factories/FormFactory.php@@ -59,9 +59,6 @@ class FormFactory extends Factory'title' => $this->faker->text(30),'description' => $this->faker->randomHtml(1),'visibility' => 'public',- 'notifies' => false,- 'send_submission_confirmation' => false,- 'webhook_url' => null,'theme' => $this->faker->randomElement(Form::THEMES),'width' => $this->faker->randomElement(Form::WIDTHS),'dark_mode' => $this->faker->randomElement(Form::DARK_MODE_VALUES),@@ -75,17 +72,10 @@ class FormFactory extends Factory're_fillable' => false,'re_fill_button_text' => 'Fill Again','submitted_text' => '<p>Amazing, we saved your answers. Thank you for your time and have a great day!</p>',- 'notification_sender' => 'OpenForm',- 'notification_subject' => 'We saved your answers',- 'notification_body' => 'Hello there π <br>This is a confirmation that your submission was successfully saved.',- 'notifications_include_submission' => true,'use_captcha' => false,'can_be_indexed' => true,'password' => false,'tags' => [],- 'slack_webhook_url' => null,- 'discord_webhook_url' => null,- 'notification_settings' => [],'editable_submissions_button_text' => 'Edit submission','confetti_on_submission' => false,'seo_meta' => [],diff --git a/database/migrations/2024_03_26_170934_remove_notifications_fields_from_forms.php b/database/migrations/2024_03_26_170934_remove_notifications_fields_from_forms.phpnew file mode 100644index 000000000..be54434d5--- /dev/null+++ b/database/migrations/2024_03_26_170934_remove_notifications_fields_from_forms.php@@ -0,0 +1,61 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Query\Expression;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\DB;+use Illuminate\Support\Facades\Schema;++return new class () extends Migration {+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ Schema::table('forms', function (Blueprint $table) {+ $table->dropColumn([+ 'notifies',+ 'notification_emails',+ 'send_submission_confirmation',+ 'notification_sender',+ 'notification_subject',+ 'notification_body',+ 'notifications_include_submission',+ 'slack_webhook_url',+ 'discord_webhook_url',+ 'webhook_url',+ 'notification_settings'+ ]);+ });+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ $driver = DB::getDriverName();++ Schema::table('forms', function (Blueprint $table) use ($driver) {+ $table->boolean('notifies')->default(false);+ $table->text('notification_emails')->nullable();+ $table->boolean('send_submission_confirmation')->default(false);+ $table->string('notification_sender')->default('OpenForm');+ $table->string('notification_subject')->default('We saved your answers');+ $table->text('notification_body')->default(new Expression("('<p>Hello there π <br>This is a confirmation that your submission was successfully saved.</p>')"));+ $table->boolean('notifications_include_submission')->default(true);+ $table->string('slack_webhook_url')->nullable();+ $table->string('discord_webhook_url')->nullable();+ $table->string('webhook_url')->nullable();+ if ($driver === 'mysql') {+ $table->json('notification_settings')->default(new Expression('(JSON_OBJECT())'))->nullable(true);+ } else {+ $table->json('notification_settings')->default('{}')->nullable(true);+ }+ });+ }+};diff --git a/tests/Feature/Forms/FormIntegrationTest.php b/tests/Feature/Forms/FormIntegrationTest.phpindex 191fde780..9478d9cb7 100644--- a/tests/Feature/Forms/FormIntegrationTest.php+++ b/tests/Feature/Forms/FormIntegrationTest.php@@ -26,8 +26,6 @@ it('can CRUD form integration', function () {->assertSuccessful()->assertJsonCount(1);- ray($response->json('form_integration.id'), $response->json());-$this->putJson(route('open.forms.integration.update', [$form->id, $response->json('form_integration.id')]), $data)->assertSuccessful()->assertJson([