Skip to content

Commit f209b10

Browse files
committed
Authorization directive
1 parent 8c12cc8 commit f209b10

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
vm.searchTerm = "";
1111
vm.error = "";
1212
vm.isValid = true;
13+
vm.isConnected = false;
1314

1415
// check configuration
1516
checkConfiguration(loadForms);
@@ -65,6 +66,7 @@
6566
if (vm.status.useOAuth === true) {
6667
// use OAuth
6768
umbracoCmsIntegrationsCrmHubspotResource.validateAccessToken().then(function (response) {
69+
6870
if (response.isExpired === true || response.isValid === false) {
6971
vm.loading = false;
7072
notificationsService.warning("HubSpot API", "Unable to connect to HubSpot. Please review the settings of the form picker property's data type.");
@@ -77,7 +79,8 @@
7779

7880
if (data.isValid === false || data.isExpired === true) {
7981
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.");
80-
}
82+
} else
83+
vm.isConnected = true;
8184
});
8285
});
8386
} else {
@@ -89,9 +92,20 @@
8992

9093
if (data.isValid === false || data.isExpired === true) {
9194
notificationsService.error("HubSpot API", "Invalid API key");
92-
}
95+
} else
96+
vm.isConnected = true;
9397
});
9498

9599
}
96100
}
101+
102+
$scope.connected = function () {
103+
vm.isConnected = true;
104+
loadForms();
105+
};
106+
107+
$scope.revoked = function () {
108+
vm.isConnected = false;
109+
vm.hubspotFormsList = [];
110+
};
97111
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
angular.module("umbraco.directives")
2+
.directive("hubspotAuthorization", function () {
3+
return {
4+
restrict: "E",
5+
scope: {
6+
"connected": "&onConnected",
7+
"revoked": "&onRevoked"
8+
},
9+
templateUrl: "/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/views/settings.html"
10+
}
11+
});

src/Umbraco.Cms.Integrations.Crm.Hubspot/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/package.manifest

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/formpicker.controller.js",
44
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/settings.controller.js",
55
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/hubspot.resource.js",
6-
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/hubspot.service.js"
6+
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/hubspot.service.js",
7+
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/js/hubspotauthorization.directive.js"
78
],
89
"css": [
910
"~/App_Plugins/UmbracoCms.Integrations/Crm/Hubspot/css/styles.css"

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<umb-box>
55
<umb-box-header title="{{ model.title }}" description="{{ model.subtitle }}"></umb-box-header>
66
<umb-box-content>
7-
<div class="hsOverlayGroup">
7+
<div class="hsOverlayGroup" ng-if="vm.isConnected">
88
<div class="form-search">
99
<i class="icon-search"></i>
1010
<input type="text" class="-full-width-input" ng-model="vm.searchTerm" placeholder="Type to search..." umb-auto-focus="" aria-invalid="false">
1111
</div>
1212
</div>
13-
<div class="hsOverlayGroup">
13+
<div class="hsOverlayGroup" ng-if="vm.isConnected">
1414
<ul class="hsFormsList">
1515
<li ng-repeat="form in vm.hubspotFormsList | orderBy:'name' | filter:vm.searchTerm" ng-click="model.pickForm(form)" class="ng-scope" role="button" tabindex="0">
1616
<a href="" ng-attr-title="form.name">
@@ -23,6 +23,14 @@
2323
</div>
2424
</umb-box-content>
2525
</umb-box>
26+
<umb-box>
27+
<umb-box-header title="HubSpot - Authorization Status" description="Please connect to HubSpot."></umb-box-header>
28+
<umb-box-content>
29+
<div class="hsOverlayGroup">
30+
<hubspot-authorization on-connected="connected()" on-revoked="revoked()"></hubspot-authorization>
31+
</div>
32+
</umb-box-content>
33+
</umb-box>
2634
</umb-editor-container>
2735

2836
<umb-editor-footer>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;net50</TargetFrameworks>
3+
<TargetFrameworks>net472;net50;net60</TargetFrameworks>
44
</PropertyGroup>
55

66
<PropertyGroup>
@@ -19,7 +19,7 @@
1919
<PackageReference Include="UmbracoCms.Web" version="8.4.0" />
2020
</ItemGroup>
2121

22-
<ItemGroup Condition="'$(TargetFramework)' == 'net50'">
22+
<ItemGroup Condition="'$(TargetFramework)' == 'net50' OR '$(TargetFramework)' == 'net60'">
2323
<PackageReference Include="Umbraco.Cms.Web.Website" version="9.0.1" />
2424
<PackageReference Include="Umbraco.Cms.Web.BackOffice" version="9.0.1" />
2525
<PackageReference Include="Umbraco.Cms.Web.Common" version="9.0.1" />
@@ -43,10 +43,18 @@
4343
</Content>
4444
</ItemGroup>
4545

46+
<ItemGroup>
47+
<None Remove="App_Plugins\UmbracoCms.Integrations\Crm\Hubspot\js\hubspotauthorization.directive.js" />
48+
</ItemGroup>
49+
4650
<Target Name="RemoveLuceneAnalyzer" BeforeTargets="CoreCompile">
4751
<ItemGroup>
4852
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Lucene.Net.CodeAnalysis.CSharp'" />
4953
</ItemGroup>
5054
</Target>
5155

56+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
57+
<Exec Command=" set UmbracoCmsIntegrationsTestsiteV8Path=$(SolutionDir)\Umbraco.Cms.Integrations.Testsite.V8&#xD;&#xA; set HubspotDir=%25UmbracoCmsIntegrationsTestsiteV8Path%25\App_Plugins\UmbracoCms.Integrations\Crm\Hubspot&#xD;&#xA; if not exist %25HubspotDir%25 mkdir -p %25HubspotDir%25&#xD;&#xA; xcopy &quot;$(ProjectDir)App_Plugins\UmbracoCms.Integrations\Crm\Hubspot&quot; &quot;%25HubspotDir%25&quot; /e /y" />
58+
</Target>
59+
5260
</Project>

0 commit comments

Comments
 (0)