From ae27a1527073664a930b2bfdfee48ff801416d95 Mon Sep 17 00:00:00 2001 From: Johan Castiblanco <51926076+johanv26@users.noreply.github.com> Date: Thu, 6 Oct 2022 12:34:57 -0500 Subject: [PATCH] feat: control linked account by settings (#675) * feat: control linked account by settings This feature allows to control the tab linked_accounts in account settings to appear or not. Is controlled using `SHOW_LINKED_ACCOUNTS` (cherry picked from commit 7d43718042414d4e736d1c225cb9008c363dfbd3) (cherry picked from commit 6fef8d1ca7efe1b87602a764a8cbe62c880f623b) * feat: PR improvements - doblequotes for dosctring - avoid jump of line if its not necessary --- .../js/student_account/views/account_settings_factory.js | 2 ++ .../js/student_account/views/account_settings_view.js | 9 ++++++--- lms/templates/student_account/account_settings.html | 1 + .../core/djangoapps/user_api/accounts/settings_views.py | 4 +++- openedx/core/djangoapps/user_api/accounts/toggles.py | 7 +++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lms/static/js/student_account/views/account_settings_factory.js b/lms/static/js/student_account/views/account_settings_factory.js index 7bb492076af..98d35dbe997 100644 --- a/lms/static/js/student_account/views/account_settings_factory.js +++ b/lms/static/js/student_account/views/account_settings_factory.js @@ -13,6 +13,7 @@ return function( fieldsData, disableOrderHistoryTab, + showLinkedAccountsTab, ordersHistoryData, authData, passwordResetSupportUrl, @@ -426,6 +427,7 @@ }, userPreferencesModel: userPreferencesModel, disableOrderHistoryTab: disableOrderHistoryTab, + showLinkedAccountsTab: showLinkedAccountsTab, betaLanguage: betaLanguage }); diff --git a/lms/static/js/student_account/views/account_settings_view.js b/lms/static/js/student_account/views/account_settings_view.js index fa50a031678..a7e6f0e88d9 100644 --- a/lms/static/js/student_account/views/account_settings_view.js +++ b/lms/static/js/student_account/views/account_settings_view.js @@ -37,15 +37,18 @@ selected: true, expanded: true }, - { + ]; + + if (view.options.showLinkedAccountsTab) { + accountSettingsTabs.push({ name: 'accountsTabSections', id: 'accounts-tab', label: gettext('Linked Accounts'), tabindex: -1, selected: false, expanded: false - } - ]; + }); + } if (!view.options.disableOrderHistoryTab) { accountSettingsTabs.push({ name: 'ordersTabSections', diff --git a/lms/templates/student_account/account_settings.html b/lms/templates/student_account/account_settings.html index 83bb822327b..77b4a87e476 100644 --- a/lms/templates/student_account/account_settings.html +++ b/lms/templates/student_account/account_settings.html @@ -52,6 +52,7 @@ AccountSettingsFactory( fieldsData, ${ disable_order_history_tab | n, dump_js_escaped_json }, + ${ show_linked_accounts_tab | n, dump_js_escaped_json }, ordersHistoryData, authData, '${ password_reset_support_link | n, js_escaped_string }', diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index ab321638d2f..09430b22435 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -25,7 +25,8 @@ from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.user_api.accounts.toggles import ( should_redirect_to_account_microfrontend, - should_redirect_to_order_history_microfrontend + should_redirect_to_order_history_microfrontend, + should_show_linked_accounts_tab ) from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences from openedx.core.lib.edx_api_utils import get_edx_api_data @@ -139,6 +140,7 @@ def account_settings_context(request): 'show_dashboard_tabs': True, 'order_history': user_orders, 'disable_order_history_tab': should_redirect_to_order_history_microfrontend(), + 'show_linked_accounts_tab': should_show_linked_accounts_tab(), 'enable_account_deletion': configuration_helpers.get_value( 'ENABLE_ACCOUNT_DELETION', settings.FEATURES.get('ENABLE_ACCOUNT_DELETION', False) ), diff --git a/openedx/core/djangoapps/user_api/accounts/toggles.py b/openedx/core/djangoapps/user_api/accounts/toggles.py index f8221a02ab9..b141f2805f5 100644 --- a/openedx/core/djangoapps/user_api/accounts/toggles.py +++ b/openedx/core/djangoapps/user_api/accounts/toggles.py @@ -25,6 +25,13 @@ def should_redirect_to_order_history_microfrontend(): ) +def should_show_linked_accounts_tab(): + """Check if the the var `SHOW_LINKED_ACCOUNTS` + is defined in configuration helpers. + """ + return configuration_helpers.get_value('SHOW_LINKED_ACCOUNTS', True) + + # .. toggle_name: account.redirect_to_microfrontend # .. toggle_implementation: WaffleFlag # .. toggle_default: False