Skip to content

Commit d7a7e13

Browse files
authored
Merge pull request #18 from umbraco/feature/zapier-integration-upgrade
Feature/zapier integration upgrade
2 parents 4d2afe5 + 9f27234 commit d7a7e13

35 files changed

+916
-669
lines changed

azure-pipelines - Automation.Zapier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trigger:
2-
- main
2+
- feature/zapier-integration-upgrade
33

44
pool:
55
vmImage: 'windows-latest'
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<div ng-controller="Umbraco.Cms.Integrations.Automation.Zapier.ZapConfigController as vm">
1+
<div ng-controller="Umbraco.Cms.Integrations.Automation.Zapier.ZapierConfigController as vm">
2+
<umb-load-indicator ng-show="vm.loading"></umb-load-indicator>
23
<umb-box>
34
<umb-box-header title="Content Properties"></umb-box-header>
45
<umb-box-content>
@@ -18,54 +19,40 @@
1819
<p>
1920
Zap triggers use webhooks to execute the actions. Webhooks are automated messages sent from apps when something happens.
2021
</p>
21-
<p>
22+
<p ng-if="!vm.formsExtensionInstalled">
2223
You can initiate your automation when a content item of a particular document type is published in Umbraco.
2324
</p>
25+
<p ng-if="vm.formsExtensionInstalled">
26+
You can initiate your automation when a content item of a particular document type is published or a form is submitted in Umbraco.
27+
</p>
2428
<p>
25-
Using the filters below, map content items with Zap triggered webhooks. This will:
29+
The integration uses Zapier subscription hook triggers, allowing Zapier to set up and remove hook subscriptions when Zaps are created or removed on the platform.
2630
</p>
27-
<ul>
28-
<li>Enable Zap invocations when content of the specified document type is published.</li>
29-
<li>Trigger a sample request using the webhook URL to review when creating the Zap trigger.</li>
30-
</ul>
31-
</div>
32-
<div class="mt3">
33-
<input id="inWebHookUrl" type="text" ng-model="vm.webHookUrl" class="w-20 mb0" placeholder="WebHook URL" no-dirty-check />
34-
<select id="selContentTypes" ng-model="vm.selectedContentType" class="mb0" no-dirty-check>
35-
<option value="">Please select a content type</option>
36-
<option ng-repeat="item in vm.contentTypes" value="{{ item.name }}">{{ item.name }}</option>
37-
</select>
38-
<umb-button action="vm.onAdd()"
39-
type="button"
40-
button-style="primary"
41-
label="Add">
42-
</umb-button>
4331
</div>
4432
</umb-box-content>
4533
</umb-box>
4634
<umb-box>
47-
<umb-box-header title="Registered Webhooks"></umb-box-header>
48-
<umb-content>
35+
<umb-box-header title="Registered Subscription Hooks"></umb-box-header>
36+
<umb-box-content>
37+
<div>
38+
<p ng-if="vm.contentConfigs.length == 0">There are no subscription hooks.</p>
39+
</div>
4940
<div class="mt2">
50-
51-
<umb-load-indicator ng-show="vm.loading"></umb-load-indicator>
52-
53-
<div class="umb-table" ng-if="vm.contentConfigs">
41+
<div class="umb-table" ng-if="vm.contentConfigs.length > 0">
5442
<!-- Listviews head section -->
5543
<div class="umb-table-head">
5644
<div class="umb-table-row">
5745
<div class="umb-table-cell"></div>
5846
<div class="umb-table-cell umb-table__name">
5947
<a class="umb-table-head__link" href="#" prevent-default>
60-
<span>Content Type Name</span>
48+
<span>Content Type Alias</span>
6149
</a>
6250
</div>
6351
<div class="umb-table-cell">
6452
<a class="umb-table-head__link" href="#" prevent-default>
65-
<span>WebHook URL</span>
53+
<span>Hook URL</span>
6654
</a>
6755
</div>
68-
<div class="umb-table-cell"></div>
6956
</div>
7057
</div>
7158

@@ -75,27 +62,57 @@
7562
ng-repeat="row in vm.contentConfigs track by $index">
7663
<div class="umb-table-cell"></div>
7764
<div class="umb-table-cell umb-table__name">
78-
<span ng-bind="row.contentTypeName"></span>
65+
<span ng-bind="row.contentTypeAlias"></span>
7966
</div>
8067
<div class="umb-table-cell">
81-
<span ng-bind="row.webHookUrl"></span>
68+
<span ng-bind="row.hookUrl"></span>
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
74+
</umb-box-content>
75+
</umb-box>
76+
<umb-box ng-if="vm.formsExtensionInstalled">
77+
<umb-box-header title="Registered Form Subscription Hooks"></umb-box-header>
78+
<umb-box-content>
79+
<div>
80+
<p ng-if="vm.formConfigs.length == 0">There are no form subscription hooks.</p>
81+
</div>
82+
<div class="mt2">
83+
<div class="umb-table" ng-if="vm.formConfigs.length > 0">
84+
<!-- Listviews head section -->
85+
<div class="umb-table-head">
86+
<div class="umb-table-row">
87+
<div class="umb-table-cell"></div>
88+
<div class="umb-table-cell umb-table__name">
89+
<a class="umb-table-head__link" href="#" prevent-default>
90+
<span>Form Name</span>
91+
</a>
92+
</div>
93+
<div class="umb-table-cell">
94+
<a class="umb-table-head__link" href="#" prevent-default>
95+
<span>Hook URL</span>
96+
</a>
97+
</div>
98+
</div>
99+
</div>
100+
101+
<!-- Listview body section -->
102+
<div class="umb-table-body">
103+
<div class="umb-table-row"
104+
ng-repeat="row in vm.formConfigs track by $index">
105+
<div class="umb-table-cell"></div>
106+
<div class="umb-table-cell umb-table__name">
107+
<span ng-bind="row.formName"></span>
82108
</div>
83109
<div class="umb-table-cell">
84-
<umb-button action="vm.onTrigger(row.webHookUrl, row.contentTypeName)"
85-
label="Trigger Webhook"
86-
type="button"
87-
button-style="info">
88-
</umb-button>
89-
<umb-button action="vm.onDelete(row.id)"
90-
label="Delete"
91-
type="button"
92-
button-style="danger">
93-
</umb-button>
110+
<span ng-bind="row.hookUrl"></span>
94111
</div>
95112
</div>
96113
</div>
97114
</div>
98115
</div>
99-
</umb-content>
116+
</umb-box-content>
100117
</umb-box>
101118
</div>

src/Umbraco.Cms.Integrations.Automation.Zapier/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier-validation.service.js

Lines changed: 0 additions & 33 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,39 @@
1-
function zapierController(notificationsService, overlayService, localizationService, umbracoCmsIntegrationsAutomationZapierValidationService, umbracoCmsIntegrationsAutomationZapierResource) {
1+
function zapierController(umbracoCmsIntegrationsAutomationZapierResource) {
22

33
var vm = this;
44

55
vm.loading = false;
6-
vm.contentTypes = [];
6+
vm.formsExtensionInstalled = false;
77
vm.contentConfigs = [];
8-
9-
getContentTypes();
8+
vm.formConfigs = [];
109

1110
getContentConfigs();
1211

13-
vm.onAdd = function () {
14-
const validationResult =
15-
umbracoCmsIntegrationsAutomationZapierValidationService.validateConfiguration(vm.webHookUrl,
16-
vm.selectedContentType);
12+
umbracoCmsIntegrationsAutomationZapierResource.checkFormsExtension().then(function (response) {
13+
vm.formsExtensionInstalled = response;
1714

18-
if (validationResult.length > 0) {
19-
notificationsService.warning("Zapier Content Config", validationResult);
20-
return;
15+
if (response) {
16+
getFormConfigs();
2117
}
18+
});
2219

23-
umbracoCmsIntegrationsAutomationZapierResource.addConfig(vm.webHookUrl, vm.selectedContentType).then(function (response) {
24-
25-
if (response.length > 0) {
26-
notificationsService.warning("Zapier Content Config", response);
27-
return;
28-
}
29-
30-
getContentTypes();
31-
32-
getContentConfigs();
33-
34-
reset();
35-
});
36-
}
37-
38-
vm.onTrigger = function (webHookUrl, contentTypeName) {
39-
20+
function getContentConfigs() {
4021
vm.loading = true;
41-
42-
umbracoCmsIntegrationsAutomationZapierResource.triggerWebHook(webHookUrl, contentTypeName).then(function (response) {
43-
22+
umbracoCmsIntegrationsAutomationZapierResource.getAllContentConfigs().then(function (response) {
23+
vm.contentConfigs = response;
4424
vm.loading = false;
45-
46-
if (response.length > 0)
47-
notificationsService.warning("WebHook Trigger", response);
48-
else
49-
notificationsService.success("WebHook Trigger", "WebHook triggered successfully. Please check your Zap trigger for the newly submitted request.");
50-
});
51-
}
52-
53-
vm.onDelete = function (id) {
54-
55-
localizationService.localizeMany(["zapierDashboard_promptDeleteTitle", "zapierDashboard_promptDeleteContent", "general_yes", "general_no"])
56-
.then(function (labels) {
57-
var overlay = {
58-
view: "confirm",
59-
title: labels[0],
60-
content: labels[1],
61-
closeButtonLabel: labels[3],
62-
submitButtonLabel: labels[2],
63-
submitButtonStyle: "danger",
64-
close: function () {
65-
overlayService.close();
66-
},
67-
submit: function () {
68-
69-
umbracoCmsIntegrationsAutomationZapierResource.deleteConfig(id).then(function () {
70-
getContentTypes();
71-
72-
getContentConfigs();
73-
});
74-
75-
overlayService.close();
76-
}
77-
};
78-
overlayService.open(overlay);
79-
});
80-
}
81-
82-
function getContentTypes() {
83-
umbracoCmsIntegrationsAutomationZapierResource.getContentTypes().then(function (response) {
84-
vm.contentTypes = response;
8525
});
8626
}
8727

88-
function getContentConfigs() {
89-
umbracoCmsIntegrationsAutomationZapierResource.getAllConfigs().then(function (response) {
90-
vm.contentConfigs = response;
28+
function getFormConfigs() {
29+
vm.loading = true;
30+
umbracoCmsIntegrationsAutomationZapierResource.getAllFormConfigs().then(function (response) {
31+
vm.formConfigs = response;
32+
vm.loading = false;
9133
});
9234
}
9335

94-
function reset() {
95-
vm.webHookUrl = "";
96-
vm.selectedContentType = "";
97-
}
98-
99-
10036
}
10137

10238
angular.module("umbraco")
103-
.controller("Umbraco.Cms.Integrations.Automation.Zapier.ZapConfigController", zapierController);
39+
.controller("Umbraco.Cms.Integrations.Automation.Zapier.ZapierConfigController", zapierController);

src/Umbraco.Cms.Integrations.Automation.Zapier/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier.resource.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
angular.module('umbraco.resources').factory('umbracoCmsIntegrationsAutomationZapierResource',
22
function ($http, umbRequestHelper) {
33

4-
const apiEndpoint = "backoffice/UmbracoCmsIntegrationsAutomationZapier/ZapConfig";
4+
const apiEndpoint = "backoffice/UmbracoCmsIntegrationsAutomationZapier/ZapierConfig";
55

66
return {
7-
getContentTypes: function () {
7+
getAllContentConfigs: function() {
88
return umbRequestHelper.resourcePromise(
9-
$http.get(`${apiEndpoint}/GetContentTypes`),
9+
$http.get(`${apiEndpoint}/GetAll`),
1010
"Failed to get resource");
1111
},
12-
addConfig: function (webHookUrl, contentTypeName) {
12+
checkFormsExtension: function() {
1313
return umbRequestHelper.resourcePromise(
14-
$http.post(`${apiEndpoint}/Add`, { contentTypeName: contentTypeName, webHookUrl: webHookUrl }), "Failed to get resource");
14+
$http.get(`${apiEndpoint}/IsFormsExtensionInstalled`), "Failed to get resource");
1515
},
16-
getAllConfigs: function () {
16+
getAllFormConfigs: function() {
1717
return umbRequestHelper.resourcePromise(
18-
$http.get(`${apiEndpoint}/GetAll`), "Failed to get resource");
19-
},
20-
triggerWebHook: function (webHookUrl, contentTypeName) {
21-
return umbRequestHelper.resourcePromise(
22-
$http.post(`${apiEndpoint}/TriggerWebHook`, { contentTypeName: contentTypeName, webHookUrl: webHookUrl }), "Failed to get resource");
23-
},
24-
deleteConfig: function (id) {
25-
return umbRequestHelper.resourcePromise(
26-
$http.delete(`${apiEndpoint}/Delete?id=${id}`), "Failed to get resource");
18+
$http.get(`${apiEndpoint}/GetAllForms`), "Failed to get resource");
2719
}
2820
};
2921
}

src/Umbraco.Cms.Integrations.Automation.Zapier/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/package.manifest

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"javascript": [
33
"~/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier.controller.js",
4-
"~/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier.resource.js",
5-
"~/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier-validation.service.js"
4+
"~/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/js/zapier.resource.js"
65
],
76
"css": [
87
"~/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/css/zapier.css"

0 commit comments

Comments
 (0)