Skip to content

Commit 12a10be

Browse files
committed
Minor amends (readme, notifications on error, styling).
1 parent d42d707 commit 12a10be

File tree

11 files changed

+77
-47
lines changed

11 files changed

+77
-47
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ This repository houses open-source extensions, created for Umbraco CMS, that int
88

99
[CommerceTools](./src/Umbraco.Cms.Integrations.Commerce.CommerceTools/) - a product and category picker that can be added as a property editor for content, with a value converter providing a strongly typed model for rendering.
1010

11+
### SEO
12+
1113
[Semrush](./src/Umbraco.Cms.Integrations.SEO.Semrush/) - a search tool available as a content app, helping editors research and use appropriate keywords for their content, to help with website search engine optimisation.
14+
15+
### CRM
16+
17+
[HubSpot](./src/Umbraco.Cms.Integrations.Crm.HubSpot/) - a form picker and rendering component for Hubspot forms.

src/Umbraco.Cms.Integrations.Crm.Hubspot/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/css/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@
2929
display: block;
3030
}
3131

32+
.hsSettings {
33+
padding-top: 4px;
34+
}
35+
3236

src/Umbraco.Cms.Integrations.Crm.Hubspot/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/formpicker.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
umbracoCmsIntegrationsCrmHubspotResource.validateAccessToken().then(function (response) {
6868
if (response.isExpired === true || response.isValid === false) {
6969
vm.loading = false;
70-
notificationsService.warning("HubSpot API", "Invalid access token. Please review OAuth settings of the editor.");
70+
notificationsService.warning("HubSpot API", "Unable to connect to HubSpot. Please review the settings of the form picker property's data type.");
7171
return;
7272
}
7373

@@ -76,7 +76,7 @@
7676
vm.hubspotFormsList = data.forms;
7777

7878
if (data.isValid === false || data.isExpired === true) {
79-
notificationsService.error("HubSpot API", "Invalid access token. Please review OAuth settings of the editor.");
79+
notificationsService.error("HubSpot API", "Unable to retrieve the list of forms from HubSpot. Please review the settings of the form picker property's data type.");
8080
}
8181
});
8282
});

src/Umbraco.Cms.Integrations.Crm.Hubspot/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/settings.controller.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
vm.onRevokeToken = function() {
4747
umbracoCmsIntegrationsCrmHubspotResource.revokeAccessToken().then(function (response) {
4848
vm.oauthSetup.isConnected = false;
49+
notificationsService.success("HubSpot Configuration", "OAuth connection revoked.");
4950
});
5051
}
5152

@@ -54,9 +55,13 @@
5455
if (event.data.type === "hubspot:oauth:success") {
5556

5657
umbracoCmsIntegrationsCrmHubspotResource.getAccessToken(event.data.code).then(function (response) {
57-
vm.oauthSetup.isConnected = true;
58-
vm.status.description = umbracoCmsIntegrationsCrmHubspotService.configDescription.OAuthConnected;
59-
notificationsService.success("HubSpot Configuration", "OAuth connected.");
58+
if (response.startsWith("Error:")) {
59+
notificationsService.error("HubSpot Configuration", response);
60+
} else {
61+
vm.oauthSetup.isConnected = true;
62+
vm.status.description = umbracoCmsIntegrationsCrmHubspotService.configDescription.OAuthConnected;
63+
notificationsService.success("HubSpot Configuration", "OAuth connected.");
64+
}
6065
});
6166

6267
}

src/Umbraco.Cms.Integrations.Crm.Hubspot/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/views/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div ng-controller="Umbraco.Cms.Integrations.Crm.Hubspot.SettingsController as vm">
1+
<div ng-controller="Umbraco.Cms.Integrations.Crm.Hubspot.SettingsController as vm" class="hsSettings">
22
<div>
33
<p>{{ vm.status.description }}</p>
44
</div>

src/Umbraco.Cms.Integrations.Crm.Hubspot/Controllers/FormsController.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,15 @@ public async Task<string> GetAccessToken([FromBody] OAuthRequestDto authRequestD
213213
return result;
214214
}
215215

216-
return "error";
216+
if (response.StatusCode == HttpStatusCode.BadRequest)
217+
{
218+
var errorResult = await response.Content.ReadAsStringAsync();
219+
var errorDto = JsonConvert.DeserializeObject<ErrorDto>(errorResult);
220+
221+
return "Error: " + errorDto.Message;
222+
}
223+
224+
return "Error: An unexpected error occurred.";
217225
}
218226

219227
[HttpPost]

src/Umbraco.Cms.Integrations.Crm.Hubspot/HubspotFormPickerPropertyEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Umbraco.Cms.Integrations.Crm.Hubspot
55
{
66
[DataEditor(
77
alias: "Umbraco.Cms.Integrations.Crm.Hubspot.FormPicker",
8-
name: "Hubspot Form Picker",
8+
name: "HubSpot Form Picker",
99
view: "~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/views/formpicker.html",
1010
Group = "Pickers",
1111
Icon = "icon-handshake"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Umbraco.Cms.Integrations.Crm.Hubspot.Models.Dtos
4+
{
5+
public class ErrorDto
6+
{
7+
[JsonProperty("status")]
8+
public string Status { get; set; }
9+
10+
[JsonProperty("message")]
11+
public string Message { get; set; }
12+
}
13+
}

src/Umbraco.Cms.Integrations.Crm.Hubspot/Umbraco.Cms.Integrations.Crm.Hubspot.csproj

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageIconUrl></PackageIconUrl>
1111
<PackageProjectUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</PackageProjectUrl>
1212
<RepositoryUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</RepositoryUrl>
13-
<Version>1.0.0</Version>
13+
<Version>1.0.0-alpha001</Version>
1414
<Authors>Umbraco HQ</Authors>
1515
<Company>Umbraco</Company>
1616
</PropertyGroup>
@@ -26,12 +26,4 @@
2626
</Content>
2727
</ItemGroup>
2828

29-
<ItemGroup>
30-
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\js\hubspot.service.js" />
31-
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\js\settings.controller.js" />
32-
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\Render\HubspotForm.cshtml" />
33-
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\views\formpickereditor.html" />
34-
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\views\settings.html" />
35-
</ItemGroup>
36-
3729
</Project>

src/Umbraco.Cms.Integrations.Crm.Hubspot/readme.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ The package supports two modes of authentication:
1515
- API Key
1616
- OAuth
1717

18-
To support multi-region HubSpot forms, the following app setting is required in `Web.config`:
19-
```
20-
<appSettings>
21-
...
22-
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.Region" value="[region]" />
23-
...
24-
</appSettings>
25-
```
26-
2718
#### API Key
2819

2920
Log into your HubSpot account, go to _Settings > Integrations > API Key_ and create an API key.
@@ -38,40 +29,39 @@ Add this to an app setting in `Web.config`:
3829
</appSettings>
3930
```
4031

32+
The key will be added to all requests made to the HubSpot API and used to authenticate access.
33+
4134
#### OAuth
4235

43-
OAuth required parameters are represented by a group of constants in the _FormsController_ with the following values:
44-
```
45-
OAuthClientId
46-
OAuthScopes
47-
OAuthProxyBaseUrl
48-
OAuthProxyEndpoint
49-
```
36+
If you prefer not to use an API key, an authentication flow using OAuth is also available.
5037

51-
No two set of app settings will work simultaneously.
38+
To use this, simply ensure you don't have an API key in your configurataion file.
5239

53-
#### Debug Configuration
40+
### Additional Configuration
5441

55-
While in DEBUG mode use following post build events:
42+
To support multi-region HubSpot forms, the following app setting is required in `Web.config`:
5643
```
57-
set UmbracoCmsIntegrationsTestsiteV8Path=$(SolutionDir)\Umbraco.Cms.Integrations.Testsite.V8
58-
set HubspotDir=%UmbracoCmsIntegrationsTestsiteV8Path%\App_Plugins\UmbracoCms.Integrations\Crm\Hubspot
59-
if not exist %HubspotDir% mkdir -p %HubspotDir%
60-
xcopy "$(ProjectDir)App_Plugins\UmbracoCms.Integrations\Crm\Hubspot" "%HubspotDir%" /e /y
44+
<appSettings>
45+
...
46+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.Region" value="[region]" />
47+
...
48+
</appSettings>
6149
```
6250

51+
For example, in Europe, a setting of `eu1` should be used.
52+
6353
### Backoffice usage
6454

65-
Property Editor will check the settings in `Web.config`, validate the configuration based on the existing
66-
app settings and prompt the user a notification.
55+
To use the form picker, a new data type should be created based on the HubSpot Form Picker property editor.
6756

68-
If OAuth is available, then the _Connect_ button will be enabled, prompting the user, on clicked,
69-
with the HubSpot authorization window. The retrieved access token will be saved into the database and
70-
used for future requests. _Revoke_ action will remove the access token from the database and the authorization process will need to be repeated.
57+
The settings in `Web.config` will be checked and a message presented indicating whether authenticiation is in place.
7158

72-
When a form is selected, the user needs to toggle the region flag notifying whether the data is stored in EU or US. This is very important as
73-
it triggers the front-end JS script and the form creation depending on the region.
59+
If OAuth is being used for authentication is available, then the _Connect_ button will be enabled, prompting the user when clicked,
60+
with the HubSpot authorization window.
7461

62+
The retrieved access token will be saved into the database and used for future requests.
63+
64+
_Revoke_ action will remove the access token from the database and the authorization process will need to be repeated.
7565

7666
### Front-end rendering
7767

@@ -88,3 +78,14 @@ And render the form using (assuming a property based on the created data type, w
8878
```
8979
@Html.RenderHubspotForm(Model.HubspotForm)
9080
```
81+
82+
### Developer Notes
83+
84+
To copy the front-end assets to the test site While in DEBUG mode, use following post build events:
85+
```
86+
set UmbracoCmsIntegrationsTestsiteV8Path=$(SolutionDir)\Umbraco.Cms.Integrations.Testsite.V8
87+
set HubspotDir=%UmbracoCmsIntegrationsTestsiteV8Path%\App_Plugins\UmbracoCms.Integrations\Crm\Hubspot
88+
if not exist %HubspotDir% mkdir -p %HubspotDir%
89+
xcopy "$(ProjectDir)App_Plugins\UmbracoCms.Integrations\Crm\Hubspot" "%HubspotDir%" /e /y
90+
```
91+

0 commit comments

Comments
 (0)