Merge pull request #20213 from edx/arch/order-history-toggle
Order History: Toggled redirection to Micro-frontend
This commit is contained in:
@@ -3469,6 +3469,9 @@ WRITABLE_GRADEBOOK_URL = None
|
||||
# completely removed and this redirect is no longer needed, we can remove this.
|
||||
PROFILE_MICROFRONTEND_URL = "http://some.profile.spa/u/"
|
||||
|
||||
# URL configuration for new microfrontends.
|
||||
ORDER_HISTORY_MICROFRONTEND_URL = "http://some.order_history.spa/"
|
||||
|
||||
############### Settings for django-fernet-fields ##################
|
||||
FERNET_KEYS = [
|
||||
'DUMMY KEY CHANGE BEFORE GOING TO PRODUCTION',
|
||||
|
||||
@@ -17,6 +17,7 @@ define(['backbone',
|
||||
var createAccountSettingsPage = function() {
|
||||
var context = AccountSettingsPage(
|
||||
Helpers.FIELDS_DATA,
|
||||
false,
|
||||
[],
|
||||
Helpers.AUTH_DATA,
|
||||
Helpers.PASSWORD_RESET_SUPPORT_LINK,
|
||||
@@ -153,6 +154,7 @@ define(['backbone',
|
||||
var createEnterpriseLearnerAccountSettingsPage = function() {
|
||||
var context = AccountSettingsPage(
|
||||
Helpers.FIELDS_DATA,
|
||||
false,
|
||||
[],
|
||||
Helpers.AUTH_DATA,
|
||||
Helpers.PASSWORD_RESET_SUPPORT_LINK,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
AccountSettingsFieldViews, AccountSettingsView, StringUtils, HtmlUtils) {
|
||||
return function(
|
||||
fieldsData,
|
||||
disableOrderHistoryTab,
|
||||
ordersHistoryData,
|
||||
authData,
|
||||
passwordResetSupportUrl,
|
||||
@@ -421,6 +422,7 @@
|
||||
ordersTabSections: ordersSectionData
|
||||
},
|
||||
userPreferencesModel: userPreferencesModel,
|
||||
disableOrderHistoryTab: disableOrderHistoryTab,
|
||||
betaLanguage: betaLanguage
|
||||
});
|
||||
|
||||
|
||||
@@ -13,33 +13,6 @@
|
||||
|
||||
navLink: '.account-nav-link',
|
||||
activeTab: 'aboutTabSections',
|
||||
accountSettingsTabs: [
|
||||
{
|
||||
name: 'aboutTabSections',
|
||||
id: 'about-tab',
|
||||
label: gettext('Account Information'),
|
||||
class: 'active',
|
||||
tabindex: 0,
|
||||
selected: true,
|
||||
expanded: true
|
||||
},
|
||||
{
|
||||
name: 'accountsTabSections',
|
||||
id: 'accounts-tab',
|
||||
label: gettext('Linked Accounts'),
|
||||
tabindex: -1,
|
||||
selected: false,
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
name: 'ordersTabSections',
|
||||
id: 'orders-tab',
|
||||
label: gettext('Order History'),
|
||||
tabindex: -1,
|
||||
selected: false,
|
||||
expanded: false
|
||||
}
|
||||
],
|
||||
events: {
|
||||
'click .account-nav-link': 'switchTab',
|
||||
'keydown .account-nav-link': 'keydownHandler',
|
||||
@@ -54,6 +27,36 @@
|
||||
render: function() {
|
||||
var tabName, betaLangMessage, helpTranslateText, helpTranslateLink, betaLangCode, oldLangCode,
|
||||
view = this;
|
||||
var accountSettingsTabs = [
|
||||
{
|
||||
name: 'aboutTabSections',
|
||||
id: 'about-tab',
|
||||
label: gettext('Account Information'),
|
||||
class: 'active',
|
||||
tabindex: 0,
|
||||
selected: true,
|
||||
expanded: true
|
||||
},
|
||||
{
|
||||
name: 'accountsTabSections',
|
||||
id: 'accounts-tab',
|
||||
label: gettext('Linked Accounts'),
|
||||
tabindex: -1,
|
||||
selected: false,
|
||||
expanded: false
|
||||
}
|
||||
];
|
||||
if (!view.options.disableOrderHistoryTab) {
|
||||
accountSettingsTabs.push({
|
||||
name: 'ordersTabSections',
|
||||
id: 'orders-tab',
|
||||
label: gettext('Order History'),
|
||||
tabindex: -1,
|
||||
selected: false,
|
||||
expanded: false
|
||||
});
|
||||
}
|
||||
|
||||
if (!_.isEmpty(view.options.betaLanguage) && $.cookie('old-pref-lang')) {
|
||||
betaLangMessage = HtmlUtils.interpolateHtml(
|
||||
gettext('You have set your language to {beta_language}, which is currently not fully translated. You can help us translate this language fully by joining the Transifex community and adding translations from English for learners that speak {beta_language}.'), // eslint-disable-line max-len
|
||||
@@ -77,14 +80,14 @@
|
||||
$.cookie('focus_id', '#beta-language-message');
|
||||
}
|
||||
HtmlUtils.setHtml(this.$el, HtmlUtils.template(accountSettingsTemplate)({
|
||||
accountSettingsTabs: this.accountSettingsTabs,
|
||||
accountSettingsTabs: accountSettingsTabs,
|
||||
HtmlUtils: HtmlUtils,
|
||||
message: betaLangMessage,
|
||||
helpTranslateText: helpTranslateText,
|
||||
helpTranslateLink: helpTranslateLink,
|
||||
oldLangCode: oldLangCode
|
||||
}));
|
||||
_.each(view.accountSettingsTabs, function(tab) {
|
||||
_.each(accountSettingsTabs, function(tab) {
|
||||
tabName = tab.name;
|
||||
view.renderSection(view.options.tabSections[tabName], tabName, tab.label);
|
||||
});
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
|
||||
<%!
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user
|
||||
from openedx.core.djangoapps.user_api.accounts.toggles import REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND
|
||||
from openedx.core.djangoapps.user_api.accounts.utils import retrieve_last_sitewide_block_completed
|
||||
from openedx.features.enterprise_support.utils import get_enterprise_learner_generic_name
|
||||
%>
|
||||
@@ -38,6 +40,9 @@ displayname = get_enterprise_learner_generic_name(request) or username
|
||||
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('dashboard')}" role="menuitem">${_("Dashboard")}</a></div>
|
||||
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('learner_profile', kwargs={'username': username})}" role="menuitem">${_("Profile")}</a></div>
|
||||
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('account_settings')}" role="menuitem">${_("Account")}</a></div>
|
||||
% if REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND.is_enabled():
|
||||
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${settings.ORDER_HISTORY_MICROFRONTEND_URL}" role="menuitem">${_("Order History")}</a></div>
|
||||
% endif
|
||||
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('logout')}" role="menuitem">${_("Sign Out")}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,6 +51,7 @@ from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_f
|
||||
|
||||
AccountSettingsFactory(
|
||||
fieldsData,
|
||||
${ disable_order_history_tab | n, dump_js_escaped_json },
|
||||
ordersHistoryData,
|
||||
authData,
|
||||
'${ password_reset_support_link | n, js_escaped_string }',
|
||||
|
||||
@@ -19,6 +19,7 @@ from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
|
||||
from openedx.core.djangoapps.lang_pref.api import all_languages, released_languages
|
||||
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.user_api.accounts.toggles import REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND
|
||||
from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences
|
||||
from openedx.core.lib.edx_api_utils import get_edx_api_data
|
||||
from openedx.core.lib.time_zone_utils import TIME_ZONE_CHOICES
|
||||
@@ -118,11 +119,12 @@ def account_settings_context(request):
|
||||
'show_program_listing': ProgramsApiConfig.is_enabled(),
|
||||
'show_dashboard_tabs': True,
|
||||
'order_history': user_orders,
|
||||
'disable_order_history_tab': REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND.is_enabled(),
|
||||
'enable_account_deletion': configuration_helpers.get_value(
|
||||
'ENABLE_ACCOUNT_DELETION', settings.FEATURES.get('ENABLE_ACCOUNT_DELETION', False)
|
||||
),
|
||||
'extended_profile_fields': _get_extended_profile_fields(),
|
||||
'beta_language': beta_language
|
||||
'beta_language': beta_language,
|
||||
}
|
||||
|
||||
enterprise_customer = get_enterprise_customer_for_learner(site=request.site, user=request.user)
|
||||
|
||||
18
openedx/core/djangoapps/user_api/accounts/toggles.py
Normal file
18
openedx/core/djangoapps/user_api/accounts/toggles.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
Toggles for accounts related code.
|
||||
"""
|
||||
from openedx.core.djangoapps.waffle_utils import WaffleFlag
|
||||
|
||||
|
||||
# .. toggle_name: REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND
|
||||
# .. toggle_type: waffle_flag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the order history page.
|
||||
# .. toggle_category: micro-frontend
|
||||
# .. toggle_use_cases: incremental_release, open_edx
|
||||
# .. toggle_creation_date: 2019-04-11
|
||||
# .. toggle_expiration_date: 2020-12-31
|
||||
# .. toggle_warnings: Remember to also set ORDER_HISTORY_MICROFRONTEND_URL before this toggle is enabled.
|
||||
# .. toggle_tickets: DEPR-17
|
||||
# .. toggle_status: supported
|
||||
REDIRECT_TO_ORDER_HISTORY_MICROFRONTEND = WaffleFlag('order_history', 'redirect_to_microfrontend')
|
||||
@@ -305,12 +305,15 @@ class WaffleFlag(object):
|
||||
Initializes the waffle flag instance.
|
||||
|
||||
Arguments:
|
||||
waffle_namespace (WaffleFlagNamespace): Provides a cached namespace
|
||||
for this flag.
|
||||
waffle_namespace (WaffleFlagNamespace | String): Namespace for this flag.
|
||||
flag_name (String): The name of the flag (without namespacing).
|
||||
flag_undefined_default (Boolean): A default value to be returned if
|
||||
the waffle flag is to be checked, but doesn't exist.
|
||||
"""
|
||||
if isinstance(waffle_namespace, six.string_types):
|
||||
waffle_namespace = WaffleFlagNamespace(name=waffle_namespace)
|
||||
|
||||
self.waffle_namespace = waffle_namespace
|
||||
self.waffle_namespace = waffle_namespace
|
||||
self.flag_name = flag_name
|
||||
self.flag_undefined_default = flag_undefined_default
|
||||
|
||||
Reference in New Issue
Block a user