Skip to content

Commit

Permalink
feat: control linked account by settings (#39)
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 95cad8d)

* feat: don't support site_configuration use general settings instead
  • Loading branch information
andrey-canon authored Dec 3, 2024
1 parent 5071f28 commit 95fa31f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
return function(
fieldsData,
disableOrderHistoryTab,
showLinkedAccountsTab,
ordersHistoryData,
authData,
passwordResetSupportUrl,
Expand Down Expand Up @@ -442,6 +443,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 @@ -39,15 +39,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 @@ -53,6 +53,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 @@ -30,7 +30,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_api_data
Expand Down Expand Up @@ -159,6 +160,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
10 changes: 8 additions & 2 deletions openedx/core/djangoapps/user_api/accounts/toggles.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
Toggles for accounts related code.
"""

from django.conf import settings
from edx_toggles.toggles import WaffleFlag

from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers

# .. toggle_name: order_history.redirect_to_microfrontend
Expand All @@ -26,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 getattr(settings, 'SHOW_LINKED_ACCOUNTS', True)


# .. toggle_name: account.redirect_to_microfrontend
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
Expand Down

0 comments on commit 95fa31f

Please sign in to comment.