Skip to content

Commit 58ba947

Browse files
committed
V14: Integrations (HubSpot/Forms)
- Namespace cleanup - Add confirmation dialog when deauthorize
1 parent 90288ea commit 58ba947

File tree

10 files changed

+17
-67
lines changed

10 files changed

+17
-67
lines changed

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/AuthorizeController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;
94
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
105

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/ContactControllerBase.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Asp.Versioning;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Cms.Web.Common.Routing;
94
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
105

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/DeauthorizeController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;
94
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
105

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/GetAllPropertiesController.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using Umbraco.Cms.Web.Common.Attributes;
93
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Responses;
104
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
115

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/GetAuthenticationUrlController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
94

105
namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Contacts

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Contacts/IsAuthorizationConfiguredController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Forms.Integrations.Crm.Hubspot.Services;
94

105
namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Contacts

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Forms/FormControllerBase.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Asp.Versioning;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
8-
using Umbraco.Cms.Web.Common.Authorization;
93
using Umbraco.Cms.Web.Common.Routing;
104
using Umbraco.Forms.Core.Services;
115

126
namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers.Forms
137
{
8+
[ApiVersion("1.0")]
149
[BackOfficeRoute($"{Constants.ManagementApi.RootPath}/v{{version:apiVersion}}/forms")]
1510
[ApiExplorerSettings(GroupName = Constants.ManagementApi.FormGroupName)]
16-
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
1711
public class FormControllerBase : HubspotControllerBase
1812
{
1913
protected readonly IFormService FormService;

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/Forms/GetFormFieldsController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83
using Umbraco.Forms.Core.Services;
94
using Umbraco.Forms.Integrations.Crm.Hubspot.Models.Dtos;
105

src/Umbraco.Forms.Integrations.Crm.Hubspot/Api/Management/Controllers/HubspotControllerBase.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
using Asp.Versioning;
2-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authorization;
32
using Microsoft.AspNetCore.Mvc;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Threading.Tasks;
93
using Umbraco.Cms.Api.Common.Attributes;
104
using Umbraco.Cms.Web.Common.Authorization;
11-
using Umbraco.Cms.Web.Common.Routing;
125

136
namespace Umbraco.Forms.Integrations.Crm.Hubspot.Api.Management.Controllers
147
{

src/Umbraco.Forms.Integrations.Crm.Hubspot/Client/src/property-editor/hubspot-mapping.property-editor.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HubspotWorkflowFormFieldDto, Property } from '@umbraco-integrations/hub
66
import { UUIInputEvent, UUISelectEvent } from '@umbraco-cms/backoffice/external/uui';
77
import { HubspotMappingValue } from '../models/hubspot.model';
88
import { UMB_NOTIFICATION_CONTEXT, UmbNotificationColor } from '@umbraco-cms/backoffice/notification';
9+
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
910

1011
const elementName = "hubspot-mapping-property-editor";
1112

@@ -20,12 +21,6 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
2021
@state()
2122
public hubspotMappingArray : Array<HubspotMappingValue> = [];
2223

23-
@state()
24-
private selectedHubspotField: string = "";
25-
26-
@state()
27-
private selectedFormField: string = "";
28-
2924
@state()
3025
private hubspotFields: Array<Property> | undefined = [];
3126

@@ -96,9 +91,9 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
9691
async #onConnect(){
9792
const { data } = await this.#hubspotContext.authorize(this.authorizationCode);
9893

99-
if(!data) return;
94+
if (!data) return;
10095

101-
if(data.success){
96+
if (data.success){
10297
this.authorizationStatus = "OAuth";
10398
this.authorizationCode = "";
10499

@@ -107,7 +102,7 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
107102
this.requestUpdate();
108103
this.dispatchEvent(new CustomEvent("authorizationStatus"));
109104
this._showSuccess("Your Umbraco Forms installation is now connected to your HubSpot account");
110-
}else{
105+
} else{
111106
this._showError(data.errorMessage);
112107
}
113108
}
@@ -122,7 +117,13 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
122117
}
123118

124119
async #deauthorize(){
125-
//TODO: add overlay to confirm deauthorize
120+
await umbConfirmModal(this, {
121+
color: "danger",
122+
headline: "Confirmation",
123+
content: "Are you sure you wish to disconnect your Hubspot account?",
124+
confirmLabel: 'Disconnect',
125+
});
126+
126127
const { data } = await this.#hubspotContext.deauthorize();
127128

128129
if(!data) return;
@@ -137,7 +138,7 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
137138
}
138139

139140
this._showSuccess("Your Umbraco Forms installation is no longer connected to your HubSpot account");
140-
}else{
141+
} else{
141142
this._showError(data.errorMessage!);
142143
}
143144

@@ -180,17 +181,15 @@ export class HubspotMappingPropertyUiElement extends UmbLitElement implements Um
180181
}
181182

182183
#onHubspotSelectChange(e: UUISelectEvent, idx: number){
183-
this.selectedHubspotField = e.target.value.toString();
184-
this.hubspotMappingArray[idx].hubspotField = this.selectedHubspotField;
184+
this.hubspotMappingArray[idx].hubspotField = e.target.value.toString();
185185

186186
this.value = JSON.stringify(this.hubspotMappingArray);
187187
this.requestUpdate();
188188
this.dispatchEvent(new CustomEvent('property-value-change'));
189189
}
190190

191191
#onFormFieldSelectChange(e: UUISelectEvent, idx: number){
192-
this.selectedFormField = e.target.value.toString();
193-
this.hubspotMappingArray[idx].formField = this.selectedFormField;
192+
this.hubspotMappingArray[idx].formField = e.target.value.toString();
194193

195194
this.value = JSON.stringify(this.hubspotMappingArray);
196195
this.requestUpdate();

0 commit comments

Comments
 (0)