diff --git a/composer.json b/composer.json index 3c1bc81..68cf2e8 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "guilty/hubspot-connector", "description": "Expose Hubspot API features in Twig and pull in content from your HubSpot Portal.", "type": "craft-plugin", - "version": "1.0.2", + "version": "1.0.3", "keywords": [ "craft", "cms", diff --git a/src/HubspotConnector.php b/src/HubspotConnector.php index 629a89b..73ee530 100644 --- a/src/HubspotConnector.php +++ b/src/HubspotConnector.php @@ -33,7 +33,7 @@ class HubspotConnector extends Plugin /** * @var string */ - public $schemaVersion = '1.0.2'; + public $schemaVersion = '1.0.3'; public function init() { @@ -76,6 +76,7 @@ protected function settingsHtml(): string 'hubspot-connector/settings', [ 'settings' => $this->getSettings(), + 'isConnected' => $this->hubspot->hasApiKey(), 'blogSubscriptionFrequencies' => $this->getFrequencyList(), 'contactProperties' => $this->getContactInformationPropertiesList(), ] @@ -84,6 +85,10 @@ protected function settingsHtml(): string protected function getFrequencyList() { + if ($this->hubspot->hasApiKey() === false) { + return []; + } + return [ [ "label" => "Instant", @@ -106,6 +111,12 @@ protected function getFrequencyList() protected function getContactInformationPropertiesList() { + + + if ($this->hubspot->hasApiKey() === false) { + return []; + } + return array_map(function ($item) { return [ "label" => $item->label, diff --git a/src/models/Settings.php b/src/models/Settings.php index 7400ddd..8d4d05e 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -31,7 +31,7 @@ public function rules() { return [ ['apiKey', 'string'], - ['apiKey', 'required'], + ['apiKey', 'string'], ['defaultBlogSubscriptionFrequency', 'string'], ['blogSubscriptionProperty', 'string'], ]; diff --git a/src/templates/settings.twig b/src/templates/settings.twig index 4f667e3..16b536c 100644 --- a/src/templates/settings.twig +++ b/src/templates/settings.twig @@ -8,23 +8,27 @@