Skip to content

Commit e2aed6e

Browse files
committed
Zapier requests updates, cleanup.
1 parent 53f3fa4 commit e2aed6e

File tree

14 files changed

+86
-265
lines changed

14 files changed

+86
-265
lines changed

src/Umbraco.Cms.Integrations.Automation.Zapier/Api/Management/Controllers/UpdateSubscriptionHookController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ public UpdateSubscriptionHookController(IOptions<ZapierSettings> options,
2727

2828
[HttpPost("subscription")]
2929
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
30+
[ProducesResponseType(StatusCodes.Status400BadRequest)]
3031
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
3132
public IActionResult UpdatePreferences([FromBody] SubscriptionDto dto)
3233
{
33-
if (!IsAccessValid() || dto == null)
34+
if (!IsAccessValid())
3435
return Unauthorized();
3536

37+
if (dto == null) return BadRequest();
38+
3639
var result = dto.SubscribeHook
3740
? _zapierSubscriptionHookService.Add(dto.EntityId, dto.Type, dto.HookUrl)
3841
: _zapierSubscriptionHookService.Delete(dto.EntityId, dto.Type, dto.HookUrl);

src/Umbraco.Cms.Integrations.Automation.Zapier/Client/generated/services.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class ZapierService {
6363
body: data.requestBody,
6464
mediaType: 'application/json',
6565
errors: {
66+
400: 'Bad Request',
6667
401: 'Unauthorized'
6768
}
6869
});

src/Umbraco.Cms.Integrations.Automation.Zapier/Client/generated/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,10 @@ export type $OpenApiTs = {
813813
* OK
814814
*/
815815
200: boolean;
816+
/**
817+
* Bad Request
818+
*/
819+
400: string;
816820
/**
817821
* Unauthorized
818822
*/

src/Umbraco.Cms.Integrations.Automation.Zapier/Client/src/dashboard/zapier-management-dashboard.element.ts

Lines changed: 44 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const elementName = "zapier-management-dashboard";
1111
export class ZapierManagementDashboardElement extends UmbLitElement {
1212
#zapierContext?: typeof ZAPIER_CONTEXT_TOKEN.TYPE;
1313
#paginationManager = new UmbPaginationManager();
14-
#itemList: GetAllResponse | undefined;
14+
#itemList: Array<SubscriptionDtoModel> = [];
1515
#isFormsExtensionInstalled: boolean | undefined = false;
1616

1717
@state()
@@ -60,36 +60,12 @@ export class ZapierManagementDashboardElement extends UmbLitElement {
6060
}
6161

6262
async getAll(){
63-
debugger;
64-
const data = await this.#zapierContext?.getAll();
63+
const { data } = await this.#zapierContext!.getAll();
6564
if (!data) return;
6665

67-
this.#itemList = data.data;
68-
69-
const lst : Array<SubscriptionDtoModel> = [{
70-
entityId: "docType1",
71-
typeName: "Content",
72-
hookUrl: "wwww.google.com",
73-
id: 1,
74-
subscribeHook: true,
75-
type: 1
76-
}, {
77-
entityId: "docType1",
78-
typeName: "Content",
79-
hookUrl: "wwww.google.com",
80-
id: 1,
81-
subscribeHook: true,
82-
type: 1
83-
}, {
84-
entityId: "docType1",
85-
typeName: "Content",
86-
hookUrl: "wwww.google.com",
87-
id: 1,
88-
subscribeHook: true,
89-
type: 1
90-
}];
91-
92-
this.#createTableItems(lst);
66+
this.#itemList = data;
67+
68+
this.#createTableItems(this.#itemList);
9369
}
9470

9571
async checkFormsExtension() {
@@ -99,75 +75,68 @@ export class ZapierManagementDashboardElement extends UmbLitElement {
9975
this.#isFormsExtensionInstalled = data.data;
10076
}
10177

102-
#createTableItems(products: Array<SubscriptionDtoModel>) {
103-
this._tableItems = products.map((product) => {
78+
#createTableItems(subscriptionHooks: Array<SubscriptionDtoModel>) {
79+
this._tableItems = subscriptionHooks.map((subscriptionHook) => {
10480
return {
105-
id: product.id.toString(),
81+
id: subscriptionHook.id.toString(),
10682
data: [{
10783
columnAlias: "identifer",
108-
value: product.entityId,
84+
value: subscriptionHook.entityId,
10985
},
11086
{
11187
columnAlias: "entityType",
112-
value: product.type,
88+
value: subscriptionHook.type,
11389
},
11490
{
11591
columnAlias: "hookUrl",
116-
value: product.hookUrl,
92+
value: subscriptionHook.hookUrl,
11793
}
11894
]
11995
}
12096
});
12197
}
12298

12399
override render() {
124-
return html`
125-
<div class="zapier-content">
126-
<umb-body-layout>
127-
<uui-box headline="Content Properties">
128-
<p>
129-
<a href="https://zapier.com/">Zapier</a> is an online platform that helps you automate workflows by connecting your apps and services you use.
130-
This allows you to automate tasks without having to build this integration yourself.
131-
When an event happens in one app, Zapier can tell another app to perform (or do) a particular action - no code necessary.
132-
</p>
133-
<p>
134-
The heart of any automation boils down to this simple command: <b>WHEN</b> <span>this happens</span> <b>THEN</b> <span>do that</span>.
135-
</p>
136-
<p>
137-
A Zap is an automated workflow that tells your apps to follow this simple command: "When this happens, do that."
138-
Every Zap has a trigger and one or more actions. A trigger is an event that starts a Zap, and an action is what your Zap does for you.
139-
</p>
100+
return html`
101+
<umb-body-layout>
102+
<uui-box headline="Content Properties">
103+
<p>
104+
<a href="https://zapier.com/">Zapier</a> is an online platform that helps you automate workflows by connecting your apps and services you use.
105+
This allows you to automate tasks without having to build this integration yourself.
106+
When an event happens in one app, Zapier can tell another app to perform (or do) a particular action - no code necessary.
107+
</p>
108+
<p>
109+
The heart of any automation boils down to this simple command: <b>WHEN</b> <span>this happens</span> <b>THEN</b> <span>do that</span>.
110+
</p>
111+
<p>
112+
A Zap is an automated workflow that tells your apps to follow this simple command: "When this happens, do that."
113+
Every Zap has a trigger and one or more actions. A trigger is an event that starts a Zap, and an action is what your Zap does for you.
114+
</p>
115+
<p>
116+
Zap triggers use webhooks to execute the actions. Webhooks are automated messages sent from apps when something happens.
117+
</p>
118+
${!this.#isFormsExtensionInstalled ? html`
140119
<p>
141-
Zap triggers use webhooks to execute the actions. Webhooks are automated messages sent from apps when something happens.
120+
You can initiate your automation when a content item of a particular document type is published in Umbraco.
142121
</p>
143-
${!this.#isFormsExtensionInstalled ? html`
144-
<p>
145-
You can initiate your automation when a content item of a particular document type is published in Umbraco.
146-
</p>
147-
` : html`
148-
<p>
149-
You can initiate your automation when a content item of a particular document type is published or a form is submitted in Umbraco.
150-
</p>
151-
`
152-
}
122+
` : html`
153123
<p>
154-
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.
124+
You can initiate your automation when a content item of a particular document type is published or a form is submitted in Umbraco.
155125
</p>
156-
</uui-box>
157-
</umb-body-layout>
158-
</div>
159-
160-
<div>
161-
<umb-body-layout>
162-
<uui-box headline="Registed Subscription Hooks">
163-
<umb-table
126+
`
127+
}
128+
<p>
129+
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.
130+
</p>
131+
</uui-box>
132+
<uui-box id="subscriptionHooks" headline="Registed Subscription Hooks">
133+
<umb-table
164134
.columns=${this._tableColumns}
165135
.items=${this._tableItems}>
166136
</umb-table>
167137
${this.#renderPagination()}
168138
</uui-box>
169-
</umb-body-layout>
170-
</div>
139+
</umb-body-layout>
171140
`;
172141
}
173142

@@ -198,8 +167,8 @@ export class ZapierManagementDashboardElement extends UmbLitElement {
198167
}
199168

200169
static styles = [css`
201-
.zapier-content p:first-child {
202-
margin-top: 0 !important;
170+
#subscriptionHooks {
171+
margin-top: 20px;
203172
}
204173
`];
205174
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Components/NewContentPublishedComponent.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Umbraco.Cms.Integrations.Automation.Zapier.Configuration
1+
namespace Umbraco.Cms.Integrations.Automation.Zapier.Configuration
82
{
93
public abstract class AppSettings
104
{
11-
public string UserGroupAlias { get; set; }
5+
public string UserGroupAlias { get; set; } = string.Empty;
6+
7+
public string ApiKey { get; set; } = string.Empty;
8+
}
129

13-
public string ApiKey { get; set; }
10+
public class ZapierSettings : AppSettings
11+
{
12+
}
13+
14+
public class ZapierFormsSettings : ZapierSettings
15+
{
1416
}
1517
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Configuration/ZapierFormsSettings.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Umbraco.Cms.Integrations.Automation.Zapier/Configuration/ZapierSettings.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Umbraco.Cms.Integrations.Automation.Zapier/Constants.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ public class Constants
99

1010
public const string TargetStateName = "zapiersubscriptionhook-db";
1111

12-
public const string UmbracoCmsIntegrationsAutomationZapierUserGroupAlias = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroupAlias";
13-
14-
public const string UmbracoCmsIntegrationsAutomationZapierApiKey = "Umbraco.Cms.Integrations.Automation.Zapier.ApiKey";
15-
16-
public const string UmbracoFormsIntegrationsAutomationZapierUserGroupAlias = "Umbraco.Forms.Integrations.Automation.Zapier.UserGroupAlias";
17-
18-
public const string UmbracoFormsIntegrationsAutomationZapierApiKey = "Umbraco.Forms.Integrations.Automation.Zapier.ApiKey";
19-
2012
public static class ManagementApi
2113
{
2214
public const string RootPath = "zapier/management/api";

0 commit comments

Comments
 (0)