From 10e14f004bc574219a115a3e972e643622552a4c Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Tue, 16 May 2023 10:22:16 +0200 Subject: [PATCH] Added os2forms_maestro_webform settings --- config/sync/core.extension.yml | 1 + config/sync/maestro.settings.yml | 2 + .../os2forms_maestro_webform.settings.yml | 14 +++ ...tem.action.user_add_role_action.borger.yml | 14 --- ...em.action.user_add_role_action.citizen.yml | 14 +++ ....action.user_remove_role_action.borger.yml | 14 --- ...action.user_remove_role_action.citizen.yml | 14 +++ config/sync/user.role.borger.yml | 16 ---- config/sync/user.role.citizen.yml | 9 ++ config/sync/user.role.forloeb_designer.yml | 2 +- .../os2forms_maestro_webform.info.yml | 3 +- .../os2forms_maestro_webform.links.menu.yml | 5 ++ .../os2forms_maestro_webform.routing.yml | 7 ++ .../src/Form/SettingsForm.php | 88 +++++++++++++++++++ 14 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 config/sync/os2forms_maestro_webform.settings.yml delete mode 100644 config/sync/system.action.user_add_role_action.borger.yml create mode 100644 config/sync/system.action.user_add_role_action.citizen.yml delete mode 100644 config/sync/system.action.user_remove_role_action.borger.yml create mode 100644 config/sync/system.action.user_remove_role_action.citizen.yml delete mode 100644 config/sync/user.role.borger.yml create mode 100644 config/sync/user.role.citizen.yml create mode 100644 web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.links.menu.yml create mode 100644 web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.routing.yml create mode 100644 web/modules/custom/os2forms_maestro_webform/src/Form/SettingsForm.php diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 625e421f..7ac6bdfc 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -81,6 +81,7 @@ module: os2forms_fbs_handler: 0 os2forms_forloeb: 0 os2forms_get_organized: 0 + os2forms_maestro_webform: 0 os2forms_nemid: 0 os2forms_nemlogin_openid_connect: 0 os2forms_organisation: 0 diff --git a/config/sync/maestro.settings.yml b/config/sync/maestro.settings.yml index 48cc0b82..d10363ac 100644 --- a/config/sync/maestro.settings.yml +++ b/config/sync/maestro.settings.yml @@ -7,3 +7,5 @@ maestro_orchestrator_development_mode: 0 _core: default_config_hash: mCGD8kihnK7wqaQPAlYskypDDPWuP2VO502z-Wwg_RM langcode: da +maestro_sitewide_token: task +maestro_token_zero_user: 1 diff --git a/config/sync/os2forms_maestro_webform.settings.yml b/config/sync/os2forms_maestro_webform.settings.yml new file mode 100644 index 00000000..02a3cb81 --- /dev/null +++ b/config/sync/os2forms_maestro_webform.settings.yml @@ -0,0 +1,14 @@ +known_anonymous_roles: + anonymous: anonymous + virksomhed: virksomhed + citizen: citizen + authenticated: 0 + administrator: 0 + site_admin: 0 + flow_designer: 0 + forloeb_designer: 0 + sagsbehandler: 0 + medarbejder: 0 + leder: 0 + os2forms_rest_api_user: 0 + os2forms_rest_api_user_write: 0 diff --git a/config/sync/system.action.user_add_role_action.borger.yml b/config/sync/system.action.user_add_role_action.borger.yml deleted file mode 100644 index 0a0e6cd4..00000000 --- a/config/sync/system.action.user_add_role_action.borger.yml +++ /dev/null @@ -1,14 +0,0 @@ -uuid: f46512d0-a40a-4885-ad5c-1a24271f4841 -langcode: en -status: true -dependencies: - config: - - user.role.borger - module: - - user -id: user_add_role_action.borger -label: 'Add the borger role to the selected user(s)' -type: user -plugin: user_add_role_action -configuration: - rid: borger diff --git a/config/sync/system.action.user_add_role_action.citizen.yml b/config/sync/system.action.user_add_role_action.citizen.yml new file mode 100644 index 00000000..d7c6070e --- /dev/null +++ b/config/sync/system.action.user_add_role_action.citizen.yml @@ -0,0 +1,14 @@ +uuid: 569a7733-ae74-40a0-9e91-5756d9a6d982 +langcode: en +status: true +dependencies: + config: + - user.role.citizen + module: + - user +id: user_add_role_action.citizen +label: 'Add the citizen role to the selected user(s)' +type: user +plugin: user_add_role_action +configuration: + rid: citizen diff --git a/config/sync/system.action.user_remove_role_action.borger.yml b/config/sync/system.action.user_remove_role_action.borger.yml deleted file mode 100644 index c4949023..00000000 --- a/config/sync/system.action.user_remove_role_action.borger.yml +++ /dev/null @@ -1,14 +0,0 @@ -uuid: 7a5a50b1-01ee-401b-bedd-b2c515043b5e -langcode: en -status: true -dependencies: - config: - - user.role.borger - module: - - user -id: user_remove_role_action.borger -label: 'Remove the borger role from the selected user(s)' -type: user -plugin: user_remove_role_action -configuration: - rid: borger diff --git a/config/sync/system.action.user_remove_role_action.citizen.yml b/config/sync/system.action.user_remove_role_action.citizen.yml new file mode 100644 index 00000000..344c6e9c --- /dev/null +++ b/config/sync/system.action.user_remove_role_action.citizen.yml @@ -0,0 +1,14 @@ +uuid: cec4dd8e-b94f-40ea-bd35-4ac38ac0315d +langcode: en +status: true +dependencies: + config: + - user.role.citizen + module: + - user +id: user_remove_role_action.citizen +label: 'Remove the citizen role from the selected user(s)' +type: user +plugin: user_remove_role_action +configuration: + rid: citizen diff --git a/config/sync/user.role.borger.yml b/config/sync/user.role.borger.yml deleted file mode 100644 index f34cd3e7..00000000 --- a/config/sync/user.role.borger.yml +++ /dev/null @@ -1,16 +0,0 @@ -uuid: fe4413c3-994e-4dad-a58e-3901378ac6f2 -langcode: da -status: true -dependencies: - module: - - eu_cookie_compliance - - system -_core: - default_config_hash: TsCQjdnxJ5STVwGbGIoKwol4DeF4wNdvIQ3c61XHuD0 -id: borger -label: borger -weight: 0 -is_admin: null -permissions: - - 'access content' - - 'display eu cookie compliance popup' diff --git a/config/sync/user.role.citizen.yml b/config/sync/user.role.citizen.yml new file mode 100644 index 00000000..63623d49 --- /dev/null +++ b/config/sync/user.role.citizen.yml @@ -0,0 +1,9 @@ +uuid: b4026821-ce05-4a4d-9be2-ca1e2972d66e +langcode: en +status: true +dependencies: { } +id: citizen +label: borger +weight: 3 +is_admin: null +permissions: { } diff --git a/config/sync/user.role.forloeb_designer.yml b/config/sync/user.role.forloeb_designer.yml index 7862771e..452a0139 100644 --- a/config/sync/user.role.forloeb_designer.yml +++ b/config/sync/user.role.forloeb_designer.yml @@ -72,8 +72,8 @@ permissions: - 'edit webform twig' - 'revert webform revisions' - 'search content' - - 'translate own webform' - 'translate any webform' + - 'translate own webform' - 'use advanced search' - 'use text format full_html' - 'use udgivelse_af_forlob_og_webformularer transition create_new_draft' diff --git a/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.info.yml b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.info.yml index b3592216..7830a0ef 100644 --- a/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.info.yml +++ b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.info.yml @@ -3,4 +3,5 @@ description: Stubbed-out code for OS2Forms core_version_requirement: ^9.4 || ^10 package: OS2Forms type: module -scripts: + +configure: os2forms_maestro_webform.settings diff --git a/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.links.menu.yml b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.links.menu.yml new file mode 100644 index 00000000..9b81f4ec --- /dev/null +++ b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.links.menu.yml @@ -0,0 +1,5 @@ +os2forms_maestro_webform.settings: + title: OS2Forms maestro webform + description: Configure the OS2Forms maestro webform module + parent: system.admin_config_system + route_name: os2forms_maestro_webform.settings diff --git a/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.routing.yml b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.routing.yml new file mode 100644 index 00000000..f05cb495 --- /dev/null +++ b/web/modules/custom/os2forms_maestro_webform/os2forms_maestro_webform.routing.yml @@ -0,0 +1,7 @@ +os2forms_maestro_webform.settings: + path: '/admin/config/system/os2forms_maestro_webform' + defaults: + _form: '\Drupal\os2forms_maestro_webform\Form\SettingsForm' + _title: 'OS2Forms maestro webform' + requirements: + _permission: 'administer site configuration' diff --git a/web/modules/custom/os2forms_maestro_webform/src/Form/SettingsForm.php b/web/modules/custom/os2forms_maestro_webform/src/Form/SettingsForm.php new file mode 100644 index 00000000..a85acccc --- /dev/null +++ b/web/modules/custom/os2forms_maestro_webform/src/Form/SettingsForm.php @@ -0,0 +1,88 @@ +get('config.factory'), + $container->get('entity_type.manager')->getStorage('user_role'), + ); + } + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'os2forms_maestro_webform_config'; + } + + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return [ + self::SETTINGS, + ]; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + $config = $this->config(static::SETTINGS); + + $roles = $this->roleStorage->loadMultiple(); + $form['known_anonymous_roles'] = [ + '#title' => $this->t('Known anonymous roles'), + '#type' => 'checkboxes', + '#options' => array_map(static fn (RoleInterface $role) => $role->label(), $roles), + '#default_value' => $config->get('known_anonymous_roles') ?: [], + '#description' => $this->t('Roles that can act as “known anonymous”'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $formState) { + $this->config(static::SETTINGS) + ->set('known_anonymous_roles', $formState->getValue('known_anonymous_roles')) + ->save(); + + parent::submitForm($form, $formState); + } + +}