Skip to content

Commit 91f028d

Browse files
committed
PR review updates: readme, styling, form rendering.
1 parent 7a274fe commit 91f028d

File tree

6 files changed

+68
-59
lines changed

6 files changed

+68
-59
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@using System.Configuration
22
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Cms.Integrations.Crm.Hubspot.Models.ViewModels.HubspotFormViewModel>
33

4-
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/shell.js"></script>
4+
<script charset="utf-8" type="text/javascript" src="https://js-eu1.hsforms.net/forms/shell.js"></script>
55
<script>
66
hbspt.forms.create({
77
region: "eu1",
88
portalId: "@Model.PortalId",
99
formId: "@Model.Id"
1010
});
11-
</script>
11+
</script>
12+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
.hsFormsList a i {
2222
position: absolute;
23-
top: .25rem;
23+
top: .5rem;
2424
left: .25rem;
2525
}
2626

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

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,39 @@
44

55
const oauthName = "OAuth";
66

7+
vm.oauthSetup = {};
78
vm.status = {};
89

9-
umbracoCmsIntegrationsCrmHubspotResource.checkApiConfiguration().then(function (response) {
10+
$scope.$on('formSubmitting', function () {
1011

11-
vm.status = {
12-
isValid: response.isValid === true,
13-
type: response.type,
14-
description: response.isValid === true ? `${response.type.value} is configured.` : "Invalid configuration",
15-
useOAuth: response.isValid === true && response.type.value === oauthName
16-
};
12+
$scope.model.value.isValid = vm.status.isValid;
13+
$scope.model.value.type = vm.status.type;
1714

18-
if (response.isValid === true) {
19-
notificationsService.success("Configuration", `${response.type.value} setup is configured.`);
20-
} else {
21-
notificationsService.warning("Configuration",
22-
"Invalid setup. Please review the API/OAuth settings.");
23-
}
2415
});
2516

26-
//if (vm.useOAuth) {
27-
// // validate token
28-
// validateOAuthAccessToken();
29-
//}
30-
31-
//$scope.$on('formSubmitting', function () {
17+
umbracoCmsIntegrationsCrmHubspotResource.checkApiConfiguration()
18+
.then(function(response) {
3219

33-
// $scope.model.value.isValid = vm.status.isValid;
34-
// $scope.model.value.type = vm.status.type;
20+
vm.status = {
21+
isValid: response.isValid === true,
22+
type: response.type,
23+
description: response.isValid === true
24+
? `${response.type.value} is configured.`
25+
: "Invalid configuration",
26+
useOAuth: response.isValid === true && response.type.value === oauthName
27+
};
3528

36-
//});
29+
if (vm.status.useOAuth) {
30+
validateOAuthSetup();
31+
}
3732

33+
if (response.isValid === true) {
34+
notificationsService.success("Configuration", `${response.type.value} setup is configured.`);
35+
} else {
36+
notificationsService.warning("Configuration",
37+
"Invalid setup. Please review the API/OAuth settings.");
38+
}
39+
});
3840

3941
vm.onConnectClick = function () {
4042

@@ -48,7 +50,7 @@
4850
// authorization listener
4951
window.addEventListener("message", function (event) {
5052
if (event.data.type === "hubspot:oauth:success") {
51-
53+
5254
umbracoCmsIntegrationsCrmHubspotResource.getAccessToken(event.data.code).then(function (response) {
5355
vm.oauthSetup.isConnected = true;
5456
});
@@ -57,28 +59,7 @@
5759
}, false);
5860

5961

60-
// custom handlers
61-
62-
function handleOAuthConfiguration() {
63-
umbracoCmsIntegrationsCrmHubspotResource.checkOAuthConfiguration().then(function (response) {
64-
handleConfigurationValidation(response);
65-
if (vm.settingsValidation.isValid === false) {
66-
vm.useOAuth = false;
67-
vm.items.find(el => el.name === oAuthName).checked = false;
68-
}
69-
70-
});
71-
}
72-
73-
function handleConfigurationValidation(result) {
74-
if (result === false) {
75-
vm.settingsValidation.isValid = false;
76-
notificationsService.warning("Settings", vm.settingsValidation.message);
77-
} else
78-
vm.settingsValidation.isValid = true;
79-
}
80-
81-
function validateOAuthAccessToken() {
62+
function validateOAuthSetup() {
8263
umbracoCmsIntegrationsCrmHubspotResource.validateAccessToken().then(function (response) {
8364

8465
vm.oauthSetup = {

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,49 @@ Add this to an app setting in `Web.config`:
2424
```
2525
<appSettings>
2626
...
27-
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.DefaultLanguage" value="[your API key]" />
27+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.ApiKey" value="[your API key]" />
2828
...
2929
</appSettings>
3030
```
3131

3232
#### OAuth
3333

34-
TBC.
34+
In order to use HubSpot OAuth authentication, you will need at least one private app registered with your account.
35+
36+
Log into your HubSpot account, go to _Settings > Integrations > Private Apps_ and create a new private app. In the _Scopes_ tab select
37+
the following two: _oauth_ and _forms_.
38+
39+
Add the following app settings in `Web.config`:
40+
```
41+
<appSettings>
42+
...
43+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthClientId" value="[your Client ID]" />
44+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthScopes" value="oauth forms" />
45+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthRedirectUrl" value="[your website URL]" />
46+
<add key="Umbraco.Cms.Integrations.OAuthProxyUrl" value="[Umbraco proxy URL]" />
47+
...
48+
</appSettings>
49+
```
50+
No two set of app settings will work simultaneously.
51+
52+
#### Debug Configuration
53+
54+
While in DEBUG mode use following post build events:
55+
```
56+
set UmbracoCmsIntegrationsTestsiteV8Path=$(SolutionDir)\Umbraco.Cms.Integrations.Testsite.V8
57+
set HubspotDir=%UmbracoCmsIntegrationsTestsiteV8Path%\App_Plugins\UmbracoCms.Integrations\Crm\Hubspot
58+
if not exist %HubspotDir% mkdir -p %HubspotDir%
59+
xcopy "$(ProjectDir)App_Plugins\UmbracoCms.Integrations\Crm\Hubspot" "%HubspotDir%" /e /y
60+
```
3561

3662
### Backoffice usage
3763

38-
TBC.
64+
Property Editor will check the settings in `Web.config`, validate the configuration based on the existing
65+
app settings and prompt the user a notification.
66+
67+
If OAuth is available, then the _Connect_ button will be enabled, prompting the user, on clicked,
68+
with the HubSpot authorization window. The retrieved access token will be saved into the database and
69+
used for future requests.
3970

4071
### Front-end rendering
4172

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

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

src/Umbraco.Cms.Integrations.Testsite.V8/Web.config

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@
5252
<!-- Hubspot Configuration -->
5353
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.ApiKey" value=""/>
5454

55-
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthClientId" value=""/>
56-
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthScopes" value="oauth reports forms"/>
55+
<!-- OAuth Settings -->
56+
<!--<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthClientId" value=""/>
57+
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthScopes" value="oauth forms"/>
5758
<add key="Umbraco.Cms.Integrations.Crm.Hubspot.OAuthRedirectUrl" value=""/>
58-
<add key="Umbraco.Cms.Integrations.OAuthProxyUrl" value="" />
59+
<add key="Umbraco.Cms.Integrations.OAuthProxyUrl" value="" />-->
5960
</appSettings>
6061
<!--
6162
Important: if you're upgrading Umbraco, do not clear the connectionString/providerName during your Web.config merge.

0 commit comments

Comments
 (0)