Skip to content

Commit 9623a54

Browse files
committed
PR updates
1 parent 52734ea commit 9623a54

File tree

8 files changed

+40
-55
lines changed

8 files changed

+40
-55
lines changed

src/Umbraco.Cms.Integrations.Automation.Zapier/App_Plugins/UmbracoCms.Integrations/Automation/Zapier/dashboard.html

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,59 +35,22 @@
3535
<umb-box-header title="Registered Subscription Hooks"></umb-box-header>
3636
<umb-box-content>
3737
<div>
38-
<p ng-if="vm.contentSubscriptionHooks.length == 0">There are no subscription hooks.</p>
38+
<p ng-if="vm.subscriptionHooks.length == 0">There are no subscription hooks.</p>
3939
</div>
4040
<div class="mt2">
41-
<div class="umb-table" ng-if="vm.contentSubscriptionHooks.length > 0">
41+
<div class="umb-table" ng-if="vm.subscriptionHooks.length > 0">
4242
<!-- Listviews head section -->
4343
<div class="umb-table-head">
4444
<div class="umb-table-row">
4545
<div class="umb-table-cell"></div>
4646
<div class="umb-table-cell umb-table__name">
4747
<a class="umb-table-head__link" href="#" prevent-default>
48-
<span>Name</span>
48+
<span>Identifier</span>
4949
</a>
5050
</div>
5151
<div class="umb-table-cell">
5252
<a class="umb-table-head__link" href="#" prevent-default>
53-
<span>Hook URL</span>
54-
</a>
55-
</div>
56-
</div>
57-
</div>
58-
59-
<!-- Listview body section -->
60-
<div class="umb-table-body">
61-
<div class="umb-table-row"
62-
ng-repeat="row in vm.contentSubscriptionHooks track by $index">
63-
<div class="umb-table-cell"></div>
64-
<div class="umb-table-cell umb-table__name">
65-
<span ng-bind="row.entityId"></span>
66-
</div>
67-
<div class="umb-table-cell">
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.formSubscriptionHooks.length == 0">There are no form subscription hooks.</p>
81-
</div>
82-
<div class="mt2">
83-
<div class="umb-table" ng-if="vm.formSubscriptionHooks.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 Id</span>
53+
<span>Entity Type</span>
9154
</a>
9255
</div>
9356
<div class="umb-table-cell">
@@ -101,11 +64,14 @@
10164
<!-- Listview body section -->
10265
<div class="umb-table-body">
10366
<div class="umb-table-row"
104-
ng-repeat="row in vm.formSubscriptionHooks track by $index">
67+
ng-repeat="row in vm.subscriptionHooks track by $index">
10568
<div class="umb-table-cell"></div>
10669
<div class="umb-table-cell umb-table__name">
10770
<span ng-bind="row.entityId"></span>
10871
</div>
72+
<div class="umb-table-cell">
73+
<span ng-bind="row.typeName"></span>
74+
</div>
10975
<div class="umb-table-cell">
11076
<span ng-bind="row.hookUrl"></span>
11177
</div>

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
vm.loading = false;
66
vm.formsExtensionInstalled = false;
77

8-
vm.contentSubscriptionHooks = [];
9-
vm.formSubscriptionHooks = [];
8+
vm.subscriptionHooks = [];
109

1110
// check if forms is installed
1211
umbracoCmsIntegrationsAutomationZapierResource.checkFormsExtension().then(function (response) {
@@ -17,8 +16,7 @@
1716
vm.loading = true;
1817
umbracoCmsIntegrationsAutomationZapierResource.getAll().then(function (response) {
1918

20-
vm.contentSubscriptionHooks = response.filter(p => p.isFormSubscription === false);
21-
vm.formSubscriptionHooks = response.filter(p => p.isFormSubscription === true);
19+
vm.subscriptionHooks = response;
2220

2321
vm.loading = false;
2422
});

src/Umbraco.Cms.Integrations.Automation.Zapier/Controllers/AuthController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#else
1313
using System.Web.Http;
1414
using System.Configuration;
15-
15+
using Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos;
1616
using Umbraco.Web.WebApi;
1717
#endif
1818

src/Umbraco.Cms.Integrations.Automation.Zapier/Controllers/SubscriptionController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public bool UpdatePreferences([FromBody] SubscriptionDto dto)
4040
if (!IsUserValid() || dto == null) return false;
4141

4242
var result = dto.SubscribeHook
43-
? _zapierSubscriptionHookService.Add(dto.EntityId, dto.HookUrl)
44-
: _zapierSubscriptionHookService.Delete(dto.EntityId, dto.HookUrl);
43+
? _zapierSubscriptionHookService.Add(dto.EntityId, dto.Type, dto.HookUrl)
44+
: _zapierSubscriptionHookService.Delete(dto.EntityId, dto.Type, dto.HookUrl);
4545

4646
return string.IsNullOrEmpty(result);
4747
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Migrations/ZapierMigration.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public class ZapierSubscriptionHookTable
6969
[Index(IndexTypes.UniqueNonClustered, Name = "IX_ZapierSubscriptionHook_EntityId")]
7070
public string EntityId { get; set; }
7171

72+
[Column("Type")]
73+
[Index(IndexTypes.UniqueNonClustered, Name = "IX_ZapierSubscriptionHook_Type", ForColumns = "EntityId,Type")]
74+
public int Type { get; set; }
75+
7276
[Column("HookUrl")]
7377
[Index(IndexTypes.UniqueNonClustered, Name = "IX_ZapierSubscriptionHook_HookUrl")]
7478
public string HookUrl { get; set; }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+

2+
namespace Umbraco.Cms.Integrations.Automation.Zapier.Models.Dtos
3+
{
4+
public class EntityDto
5+
{
6+
public enum Type
7+
{
8+
Content = 1,
9+
Form
10+
}
11+
}
12+
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Models/Dtos/SubscriptionDto.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ public class SubscriptionDto
1212
[JsonProperty("entityId")]
1313
public string EntityId { get; set; }
1414

15+
[JsonProperty("type")]
16+
public int Type { get; set; }
17+
18+
[JsonProperty("typeName")]
19+
public string TypeName => Enum.Parse(typeof(EntityDto.Type), Type.ToString()).ToString();
20+
1521
[JsonProperty("hookUrl")]
1622
public string HookUrl { get; set; }
1723

1824
[JsonProperty("subscribeHook")]
1925
public bool SubscribeHook { get; set; }
20-
21-
[JsonProperty("isFormSubscription")]
22-
public bool IsFormSubscription => Guid.TryParse(EntityId, out _);
2326
}
2427
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Services/ZapierSubscriptionHookService.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ public IEnumerable<SubscriptionDto> GetAll()
5353
{
5454
Id = p.Id,
5555
EntityId = p.EntityId,
56+
Type = p.Type,
5657
HookUrl = p.HookUrl
5758
});
5859
}
5960
}
6061

61-
public string Add(string entityId, string hookUrl)
62+
public string Add(string entityId, int type, string hookUrl)
6263
{
6364
try
6465
{
@@ -67,6 +68,7 @@ public string Add(string entityId, string hookUrl)
6768
var zapContentConfig = new ZapierMigration.ZapierSubscriptionHookTable
6869
{
6970
EntityId = entityId,
71+
Type = type,
7072
HookUrl = hookUrl,
7173
};
7274

@@ -90,14 +92,14 @@ public string Add(string entityId, string hookUrl)
9092
}
9193
}
9294

93-
public string Delete(string entityId, string hookUrl)
95+
public string Delete(string entityId, int type, string hookUrl)
9496
{
9597
try
9698
{
9799
using (var scope = _scopeProvider.CreateScope())
98100
{
99101
var entity = scope.Database.Query<ZapierMigration.ZapierSubscriptionHookTable>()
100-
.FirstOrDefault(p => p.EntityId == entityId && p.HookUrl == hookUrl);
102+
.FirstOrDefault(p => p.EntityId == entityId && p.Type == type && p.HookUrl == hookUrl);
101103
if (entity != null)
102104
{
103105
scope.Database.Delete(entity);

0 commit comments

Comments
 (0)