Skip to content

Commit

Permalink
OPENEUROPA-1500: Add custom permission for webtools analytics config.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagyad committed Jan 7, 2019
1 parent cec4035 commit c28ecd1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
administer webtools analytics:
title: 'Administer Webtools Analytics'
restrict access: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ oe_webtools_analytics.settings:
_form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm'
_title: 'Webtools Analytics settings'
requirements:
_permission: 'administer site configuration'
_permission: 'administer webtools analytics'
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getEditableConfigNames() {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['siteID'] = [
'#type' => 'textfield',
'#type' => 'number',
'#title' => $this->t('Site ID'),
'#default_value' => $this->config(static::CONFIGNAME)->get('siteID'),
'#description' => $this->t('The site unique numeric identifier.'),
Expand All @@ -56,18 +56,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
return parent::buildForm($form, $form_state);
}

/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);

$site_id = $form_state->getValue('siteID');
if (!is_numeric($site_id)) {
$form_state->setErrorByName('siteID', $this->t('The value must be numeric.'));
}
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 0 additions & 5 deletions tests/features/analytics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ Feature: Webtools Analytics
Scenario: Create Webtools Analytics settings
Given I am on "admin/config/system/oe_webtools_analytics"
Then I should see "Webtools Analytics settings"
When I fill in "Site ID" with "INFO"
And I fill in "Site path" with "ec.europa.eu/info"
And I fill in "Instance" with "ec.europa.eu"
And I press "Save configuration"
Then I should see the message "The value must be numeric."
When I fill in "Site ID" with "123456"
And I fill in "Site path" with "ec.europa.eu/info"
And I fill in "Instance" with "ec.europa.eu"
Expand Down

0 comments on commit c28ecd1

Please sign in to comment.