revert learner portal links blocking juniper release

This commit is contained in:
Adam Stankiewicz
2020-05-04 14:45:50 -04:00
parent bc8aa8bf7a
commit 6d942bc94d
19 changed files with 10 additions and 414 deletions

View File

@@ -1,11 +0,0 @@
module.exports = {
extends: 'eslint-config-edx',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
};

View File

@@ -1,16 +0,0 @@
import { getAuthenticatedApiClient } from '@edx/frontend-auth';
import { NewRelicLoggingService } from '@edx/frontend-logging';
const apiClient = getAuthenticatedApiClient({
appBaseUrl: process.env.LMS_ROOT_URL,
authBaseUrl: process.env.LMS_ROOT_URL,
loginUrl: `${process.env.LMS_ROOT_URL}/login`,
logoutUrl: `${process.env.LMS_ROOT_URL}/logout`,
csrfTokenApiPath: '/csrf/api/v1/token',
refreshAccessTokenEndpoint: `${process.env.LMS_ROOT_URL}/login_refresh`,
accessTokenCookieName: process.env.JWT_AUTH_COOKIE_HEADER_PAYLOAD,
userInfoCookieName: process.env.EDXMKTG_USER_INFO_COOKIE_NAME,
loggingService: NewRelicLoggingService,
});
export default apiClient;

View File

@@ -1,11 +0,0 @@
module.exports = {
extends: 'eslint-config-edx',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
};

View File

@@ -1,22 +0,0 @@
import { getAuthenticatedUser } from '@edx/frontend-auth';
import { getLearnerPortalLinks } from '@edx/frontend-enterprise';
import apiClient from '../apiClient';
function CustomUserMenuLinks() {
const authenticatedUser = getAuthenticatedUser();
// Inject enterprise learner portal links
getLearnerPortalLinks(apiClient, authenticatedUser).then((learnerPortalLinks) => {
const $dashboardLink = $('#user-menu .dashboard');
const classNames = 'mobile-nav-item dropdown-item dropdown-nav-item';
for (let i = 0; i < learnerPortalLinks.length; i += 1) {
const link = learnerPortalLinks[i];
$dashboardLink.after( // xss-lint: disable=javascript-jquery-insertion
`<div class="${classNames}"><a href="${link.url}" role="menuitem">${link.title} Dashboard</a></div>`,
);
}
});
}
export { CustomUserMenuLinks }; // eslint-disable-line import/prefer-default-export

View File

@@ -1,80 +0,0 @@
import React, { Component } from 'react';
import { getAuthenticatedUser } from '@edx/frontend-auth';
import { getLearnerPortalLinks } from '@edx/frontend-enterprise';
import { StatusAlert } from '@edx/paragon';
import apiClient from '../apiClient';
const LOCAL_STORAGE_KEY = 'has-viewed-enterprise-learner-portal-banner';
function getAlertHtml(learnerPortalLinks) {
let html = '';
for (let i = 0; i < learnerPortalLinks.length; i += 1) {
const link = learnerPortalLinks[i];
html += `<div class="copy-content">
${link.title} has a dedicated page where you can see all of your sponsored courses.
Go to <a href="${link.url}">your learner portal</a>.
</div>`;
}
return html;
}
function setViewedBanner() {
window.localStorage.setItem(LOCAL_STORAGE_KEY, true);
}
function hasViewedBanner() {
return window.localStorage.getItem(LOCAL_STORAGE_KEY) != null;
}
class EnterpriseLearnerPortalBanner extends Component {
constructor(props) {
super(props);
this.onClose = this.onClose.bind(this);
this.state = {
open: false,
alertHtml: '',
};
}
componentDidMount() {
if (!hasViewedBanner()) {
const authenticatedUser = getAuthenticatedUser();
getLearnerPortalLinks(apiClient, authenticatedUser).then((learnerPortalLinks) => {
this.setState({
open: true,
alertHtml: getAlertHtml(learnerPortalLinks),
});
});
}
}
onClose() {
this.setState({ open: false });
setViewedBanner();
}
render() {
const { alertHtml, open } = this.state;
if (open && alertHtml) {
return (
<div className="edx-enterprise-learner-portal-banner-wrapper">
<StatusAlert
className={['edx-enterprise-learner-portal-banner']}
open={open}
// eslint-disable-next-line react/no-danger
dialog={(<span dangerouslySetInnerHTML={{ __html: alertHtml }} />)}
onClose={this.onClose}
/>
</div>
);
}
return null;
}
}
export { EnterpriseLearnerPortalBanner }; // eslint-disable-line import/prefer-default-export