Skip to content

Commit

Permalink
feat: control linked account by settings (#675)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
johanseto committed Oct 6, 2022
1 parent c4d2fca commit ae27a15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
return function(
fieldsData,
disableOrderHistoryTab,
showLinkedAccountsTab,
ordersHistoryData,
authData,
passwordResetSupportUrl,
Expand Down Expand Up @@ -426,6 +427,7 @@
},
userPreferencesModel: userPreferencesModel,
disableOrderHistoryTab: disableOrderHistoryTab,
showLinkedAccountsTab: showLinkedAccountsTab,
betaLanguage: betaLanguage
});

Expand Down
9 changes: 6 additions & 3 deletions lms/static/js/student_account/views/account_settings_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lms/templates/student_account/account_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }',
Expand Down
4 changes: 3 additions & 1 deletion openedx/core/djangoapps/user_api/accounts/settings_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
),
Expand Down
7 changes: 7 additions & 0 deletions openedx/core/djangoapps/user_api/accounts/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae27a15

Please sign in to comment.