-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OPENEUROPA-1500: Create configuration UI for Webtools Analytics module #24
Changes from 9 commits
77e0eb5
c19f244
480a33c
f7a70da
7fbf610
e5efea0
64565e7
e615e06
114f7d9
8a0d469
04f742d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
oe_webtools_analytics.settings: | ||
title: Webtools Analytics | ||
description: 'Configure Webtools Analytics.' | ||
route_name: oe_webtools_analytics.settings | ||
parent: system.admin_config_system |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
oe_webtools_analytics.settings: | ||
path: '/admin/config/system/oe_webtools_analytics' | ||
defaults: | ||
_form: 'Drupal\oe_webtools_analytics\Form\WebtoolsAnalyticsSettingsForm' | ||
_title: 'Webtools Analytics settings' | ||
requirements: | ||
_permission: 'administer webtools analytics' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_webtools_analytics\Form; | ||
|
||
use Drupal\Core\Form\ConfigFormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Settings form for module. | ||
*/ | ||
class WebtoolsAnalyticsSettingsForm extends ConfigFormBase { | ||
|
||
/** | ||
* Name of the config being edited. | ||
*/ | ||
const CONFIGNAME = 'oe_webtools_analytics.settings'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId() { | ||
return 'oe_webtools_analytics_settings'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state) { | ||
$form['siteID'] = [ | ||
'#type' => 'number', | ||
'#title' => $this->t('Site ID'), | ||
'#default_value' => $this->config(static::CONFIGNAME)->get('siteID'), | ||
'#description' => $this->t('The site unique numeric identifier.'), | ||
]; | ||
$form['sitePath'] = [ | ||
'#type' => 'textfield', | ||
'#title' => $this->t('Site path'), | ||
'#default_value' => $this->config(static::CONFIGNAME)->get('sitePath'), | ||
'#description' => $this->t('The domain + root path without protocol.'), | ||
]; | ||
$form['instance'] = [ | ||
'#type' => 'textfield', | ||
'#title' => $this->t('Instance'), | ||
'#default_value' => $this->config(static::CONFIGNAME)->get('instance'), | ||
'#description' => $this->t('The server instance. e.g. testing, ec.europa.eu or europa.eu.'), | ||
]; | ||
drupol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return parent::buildForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$this->config(static::CONFIGNAME) | ||
->set('siteID', $form_state->getValues()['siteID']) | ||
->set('sitePath', $form_state->getValues()['sitePath']) | ||
->set('instance', $form_state->getValues()['instance']) | ||
->save(); | ||
parent::submitForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getEditableConfigNames() { | ||
return ['oe_webtools_analytics.settings']; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@api | ||
Feature: Webtools Analytics | ||
In order to provide analytics | ||
As the site manager | ||
I need to be able to configure the settings | ||
|
||
@BackupAnalyticsConfigs | ||
Scenario: Create Webtools Analytics settings | ||
nagyad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Given I am logged in as a user with the "administer webtools analytics" permission | ||
And I am on "admin/config/system/oe_webtools_analytics" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the transformation context to turn this path into a business readable string, such as:
And then in the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work for me. |
||
Then I should see "Webtools Analytics settings" | ||
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" | ||
And I press "Save configuration" | ||
Then I should see the message "The configuration options have been saved." | ||
And the "Site ID" field should contain "123456" | ||
And the "Site path" field should contain "ec.europa.eu/info" | ||
And the "Instance" field should contain "ec.europa.eu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this into
WebtoolsAnalyticsSettingsForm::CONFIG_NAME
.