From 8d722b52b7421c2c24b4fa148b97a0036bc5fa40 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Thu, 15 Aug 2024 14:34:46 +0200 Subject: [PATCH 1/8] Add and describe the feature flag in config --- README.md | 7 +++++++ config/openconext/parameters.yaml.dist | 3 +++ config/packages/open_conext.yaml | 1 + .../ProfileBundle/DependencyInjection/Configuration.php | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/README.md b/README.md index a10c9f315..a18dba6c6 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,13 @@ delete button. Clicking this button will retract consent for only that service. In order for this feature to work, you need to have an EngineBlock instance that supports this feature. See the EngineBlock docs for more information on enabling the feature on the EngineBlock Api. +## OpenConext Invite roles + +By setting the `invite_roles_enabled` flag to `true`, Profile will display the Invite Roles assigned to the logged in +user. By default the roles page is disabled. + +See: https://github.com/OpenConext/OpenConext-Invite + ## Release strategy Please read: https://github.com/OpenConext/Stepup-Deploy/wiki/Release-Management for more information on the release strategy used in Openconext projects. diff --git a/config/openconext/parameters.yaml.dist b/config/openconext/parameters.yaml.dist index 8e0bb731c..db438515c 100644 --- a/config/openconext/parameters.yaml.dist +++ b/config/openconext/parameters.yaml.dist @@ -55,6 +55,9 @@ parameters: remove_consent_enabled: false + # Feature flag to display the OpenConext Invite roles assigned to the logged in user + invite_roles_enabled: false + # Session handler override # Change to the following to use the database to store sessions: #session_handler: 'Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler' diff --git a/config/packages/open_conext.yaml b/config/packages/open_conext.yaml index 2fd85d897..413961216 100644 --- a/config/packages/open_conext.yaml +++ b/config/packages/open_conext.yaml @@ -24,3 +24,4 @@ open_conext_profile: # The Url where the attribute can be connected connect_url: '%attribute_aggregation_orcid_connect_url%' remove_consent_enabled: '%remove_consent_enabled%' + invite_roles_enabled: '%invite_roles_enabled%' diff --git a/src/OpenConext/ProfileBundle/DependencyInjection/Configuration.php b/src/OpenConext/ProfileBundle/DependencyInjection/Configuration.php index 29c98ee08..33fd5ab5b 100644 --- a/src/OpenConext/ProfileBundle/DependencyInjection/Configuration.php +++ b/src/OpenConext/ProfileBundle/DependencyInjection/Configuration.php @@ -46,6 +46,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->info('This is the feature flag that toggles the remove consent feature') ->isRequired() ->end() + ->booleanNode('invite_roles_enabled') + ->info('This is the feature flag that toggles the OpenConext Invite roles page feature') + ->isRequired() + ->end() ->end(); $this->setupLocaleConfiguration($rootNode); From 808b56a63f8ecd43f8d65981861fba9b8dd4a48a Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Thu, 15 Aug 2024 15:34:35 +0200 Subject: [PATCH 2/8] Create `/invite-roles` route and restrict access Only allow access to this route when the feature flag is enabled --- assets/css/helpers/variables.scss | 2 + assets/css/shared/navigation.scss | 8 ++++ config/packages/twig.yaml | 1 + config/services.yaml | 5 ++ .../Controller/InviteRolesController.php | 48 +++++++++++++++++++ templates/InviteRoles/overview.html.twig | 14 ++++++ templates/layout/main/navigation.html.twig | 8 ++++ translations/messages.en.php | 6 +++ translations/messages.nl.php | 5 ++ translations/messages.pt.php | 6 +++ 10 files changed, 103 insertions(+) create mode 100644 src/OpenConext/ProfileBundle/Controller/InviteRolesController.php create mode 100644 templates/InviteRoles/overview.html.twig diff --git a/assets/css/helpers/variables.scss b/assets/css/helpers/variables.scss index e4f8c04a5..0daeb6406 100644 --- a/assets/css/helpers/variables.scss +++ b/assets/css/helpers/variables.scss @@ -97,3 +97,5 @@ $myServices_active: "data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns= $connections: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='33' viewBox='0 0 32 33' style='fill:none;stroke:%23000;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;'%3E%3Ctitle%3Ecog%3C/title%3E%3Cpath d='M10.546,2.438a1.957,1.957,0,0,0,2.908,0L14.4,1.4a1.959,1.959,0,0,1,3.41,1.413l-.071,1.4A1.958,1.958,0,0,0,19.79,6.267l1.4-.071A1.959,1.959,0,0,1,22.6,9.606l-1.042.94a1.96,1.96,0,0,0,0,2.909l1.042.94a1.959,1.959,0,0,1-1.413,3.41l-1.4-.071a1.958,1.958,0,0,0-2.056,2.056l.071,1.4A1.959,1.959,0,0,1,14.4,22.6l-.941-1.041a1.959,1.959,0,0,0-2.908,0L9.606,22.6A1.959,1.959,0,0,1,6.2,21.192l.072-1.4a1.958,1.958,0,0,0-2.056-2.056l-1.4.071A1.958,1.958,0,0,1,1.4,14.4l1.041-.94a1.96,1.96,0,0,0,0-2.909L1.4,9.606A1.958,1.958,0,0,1,2.809,6.2l1.4.071A1.958,1.958,0,0,0,6.267,4.211L6.2,2.81A1.959,1.959,0,0,1,9.606,1.4Z'/%3E%3Ccircle cx='12' cy='12.001' r='4.5'/%3E%3C/svg%3E%0A"; $connections_active: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='33' viewBox='0 0 32 33' style='fill:none;stroke:%23008738;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;'%3E%3Ctitle%3Ecog%3C/title%3E%3Cpath d='M10.546,2.438a1.957,1.957,0,0,0,2.908,0L14.4,1.4a1.959,1.959,0,0,1,3.41,1.413l-.071,1.4A1.958,1.958,0,0,0,19.79,6.267l1.4-.071A1.959,1.959,0,0,1,22.6,9.606l-1.042.94a1.96,1.96,0,0,0,0,2.909l1.042.94a1.959,1.959,0,0,1-1.413,3.41l-1.4-.071a1.958,1.958,0,0,0-2.056,2.056l.071,1.4A1.959,1.959,0,0,1,14.4,22.6l-.941-1.041a1.959,1.959,0,0,0-2.908,0L9.606,22.6A1.959,1.959,0,0,1,6.2,21.192l.072-1.4a1.958,1.958,0,0,0-2.056-2.056l-1.4.071A1.958,1.958,0,0,1,1.4,14.4l1.041-.94a1.96,1.96,0,0,0,0-2.909L1.4,9.606A1.958,1.958,0,0,1,2.809,6.2l1.4.071A1.958,1.958,0,0,0,6.267,4.211L6.2,2.81A1.959,1.959,0,0,1,9.606,1.4Z'/%3E%3Ccircle cx='12' cy='12.001' r='4.5'/%3E%3C/svg%3E%0A"; $conextLogo: "data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 202.6 62.5' style='enable-background:new 0 0 202.6 62.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E %23SURFconext %7B fill: %23fff;%7D%0A%3C/style%3E%3Cg id='SURFconext'%3E%3Cpath d='M116.2,13c0.2,0.3,0.4,0.7,0.4,1c0,0.9-0.8,1.6-1.7,1.6c-0.5,0-1-0.2-1.3-0.6c-1-1-2.2-1.6-3.5-1.6c-3.1,0-5.3,2.4-5.3,5.6 s2.2,5.6,5.3,5.6c1.3,0,2.5-0.6,3.5-1.6c0.4-0.4,0.9-0.6,1.4-0.6c0.9,0,1.7,0.7,1.7,1.6c0,0.4-0.1,0.7-0.4,1 c-1.3,1.5-3.2,2.8-6.1,2.8c-5.1,0-9-3.6-9-8.8s3.9-8.8,9-8.8C112.9,10.2,114.9,11.4,116.2,13z'/%3E%3Cpath d='M127.3,27.7c-5.1,0-8.8-3.7-8.8-8.8s3.7-8.8,8.8-8.8c5.1,0,8.9,3.7,8.9,8.8S132.4,27.7,127.3,27.7z M127.3,13.4 c-3.1,0-5.1,2.4-5.1,5.6c0,3.2,2,5.6,5.1,5.6s5.2-2.4,5.2-5.6C132.5,15.7,130.4,13.4,127.3,13.4z'/%3E%3Cpath d='M151.6,27.5c-0.7,0-1.4-0.3-1.8-0.9l-7.5-10.3v9.4c0,1-0.8,1.8-1.8,1.8c-1,0-1.8-0.8-1.8-1.8V12.6c0-1.2,1-2.3,2.4-2.3 c0.8,0,1.5,0.4,2,1l7.2,9.8v-9c0-1,0.8-1.8,1.8-1.8c1,0,1.8,0.8,1.8,1.8v13.3C153.9,26.5,152.9,27.5,151.6,27.5z'/%3E%3Cpath d='M168.8,27.4h-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3E%3C/g%3E%3C/svg%3E%0A"; +$invite_roles: "data:image/svg+xml,%3Csvg id='Regular' xmlns='http://www.w3.org/2000/svg' width='32' height='33' viewBox='0 0 32 33' style='fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;'%3E%3Ctitle%3Esingle-neutral%3C/title%3E%3Ccircle cx='12' cy='6' r='5.25'/%3E%3Cpath d='M2.25,23.25a9.75,9.75,0,0,1,19.5,0'/%3E%3C/svg%3E%0A"; +$invite_roles_active: "data:image/svg+xml,%3Csvg id='Regular' xmlns='http://www.w3.org/2000/svg' width='32' height='33' viewBox='0 0 32 33' style='fill:none;stroke:%23008738;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;'%3E%3Ctitle%3Esingle-neutral%3C/title%3E%3Ccircle cx='12' cy='6' r='5.25'/%3E%3Cpath d='M2.25,23.25a9.75,9.75,0,0,1,19.5,0'/%3E%3C/svg%3E%0A"; diff --git a/assets/css/shared/navigation.scss b/assets/css/shared/navigation.scss index ce44db302..903aece01 100644 --- a/assets/css/shared/navigation.scss +++ b/assets/css/shared/navigation.scss @@ -186,3 +186,11 @@ background-image: url($connections_active); } } + +.navigation__inviteRoles { + background-image: url($invite_roles); + + &.active { + background-image: url($invite_roles_active); + } +} diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 35f85793a..a10bb2e90 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -4,6 +4,7 @@ twig: globals: global_view_parameters: "@open_conext.profile_bundle.service.global_view_parameters" root_path: "%kernel.project_dir%" + navigation_invite_roles_enabled: "%invite_roles_enabled%" paths: '%kernel.project_dir%/templates': 'OpenConextProfile' diff --git a/config/services.yaml b/config/services.yaml index 45261522a..37aa313e3 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -24,6 +24,11 @@ services: $removeConsentEnabled: '%remove_consent_enabled%' tags: [ 'controller.service_arguments' ] + OpenConext\ProfileBundle\Controller\InviteRolesController: + arguments: + $enabled: '%invite_roles_enabled%' + tags: [ 'controller.service_arguments' ] + surfnet_saml.saml_provider: class: OpenConext\ProfileBundle\Security\Authentication\Provider\SamlProvider diff --git a/src/OpenConext/ProfileBundle/Controller/InviteRolesController.php b/src/OpenConext/ProfileBundle/Controller/InviteRolesController.php new file mode 100644 index 000000000..d8e6678e7 --- /dev/null +++ b/src/OpenConext/ProfileBundle/Controller/InviteRolesController.php @@ -0,0 +1,48 @@ +enabled) { + throw $this->createAccessDeniedException(); + } + + return $this->render('@OpenConextProfile/InviteRoles/overview.html.twig',); + } +} diff --git a/templates/InviteRoles/overview.html.twig b/templates/InviteRoles/overview.html.twig new file mode 100644 index 000000000..09e241f92 --- /dev/null +++ b/templates/InviteRoles/overview.html.twig @@ -0,0 +1,14 @@ +{% extends '@OpenConextProfile/layout.html.twig' %} + +{% block title %} + {{ 'profile.my_profile.short_title'|trans }} — {{ parent() }} +{% endblock %} + +{% block contentClasses %} + content__myProfile +{% endblock %} + +{% block content %} +

{{ 'profile.invite_roles.long_title'|trans }}

+

{{ 'profile.invite_roles.intro'|trans }}

+{% endblock %} diff --git a/templates/layout/main/navigation.html.twig b/templates/layout/main/navigation.html.twig index a9317a070..e38fd6d95 100644 --- a/templates/layout/main/navigation.html.twig +++ b/templates/layout/main/navigation.html.twig @@ -27,6 +27,14 @@ {{ 'profile.my_profile.short_title'|trans }} + {% if navigation_invite_roles_enabled %} + {% set isActive = route == 'profile.invite_roles' %} + + {% endif %} {% set isActive = route == 'profile.my_surf_conext_overview' %}