Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ability to point header logo to other locations #479

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SEGMENT_KEY=null
SITE_NAME=Open edX
USER_INFO_COOKIE_NAME=edx-user-info
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_DESTINATION=http://localhost:18000/dashboard
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Environment Variables
* ``SITE_NAME`` - The user-facing name of the site, used as `alt` text on the logo in the header.
Defaults to "localhost" in development.
* ``LOGO_URL`` - The URL of the site's logo. This logo is displayed in the header.
* ``LOGO_DESTINATION`` - The URL of where the site's logo should point to.
* ``ORDER_HISTORY_URL`` - The URL of the order history page.
* ``ACCOUNT_PROFILE_URL`` - The URL of the account profile page.
* ``ACCOUNT_SETTINGS_URL`` - The URL of the account settings page.
Expand Down
3 changes: 2 additions & 1 deletion src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ensureConfig([
'LOGIN_URL',
'SITE_NAME',
'LOGO_URL',
'LOGO_DESTINATION',
'ORDER_HISTORY_URL',
], 'Header component');

Expand Down Expand Up @@ -91,7 +92,7 @@ const Header = ({ intl }) => {
const props = {
logo: config.LOGO_URL,
logoAltText: config.SITE_NAME,
logoDestination: `${config.LMS_BASE_URL}/dashboard`,
logoDestination: config.LOGO_DESTINATION || `${config.LMS_BASE_URL}/dashboard`,
loggedIn: authenticatedUser !== null,
username: authenticatedUser !== null ? authenticatedUser.username : null,
avatar: authenticatedUser !== null ? authenticatedUser.avatar : null,
Expand Down
4 changes: 4 additions & 0 deletions src/Header.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('<Header />', () => {
LOGIN_URL: process.env.LOGIN_URL,
LOGOUT_URL: process.env.LOGOUT_URL,
LOGO_URL: process.env.LOGO_URL,
LOGO_DESTINATION: process.env.LOGO_DESTINATION,
},
};
const component = <HeaderComponent width={{ width: 1280 }} contextValue={contextValue} />;
Expand All @@ -52,6 +53,7 @@ describe('<Header />', () => {
LOGIN_URL: process.env.LOGIN_URL,
LOGOUT_URL: process.env.LOGOUT_URL,
LOGO_URL: process.env.LOGO_URL,
LOGO_DESTINATION: process.env.LOGO_DESTINATION,
},
};
const component = <HeaderComponent width={{ width: 1280 }} contextValue={contextValue} />;
Expand All @@ -70,6 +72,7 @@ describe('<Header />', () => {
LOGIN_URL: process.env.LOGIN_URL,
LOGOUT_URL: process.env.LOGOUT_URL,
LOGO_URL: process.env.LOGO_URL,
LOGO_DESTINATION: process.env.LOGO_DESTINATION,
},
};
const component = <HeaderComponent width={{ width: 500 }} contextValue={contextValue} />;
Expand All @@ -93,6 +96,7 @@ describe('<Header />', () => {
LOGIN_URL: process.env.LOGIN_URL,
LOGOUT_URL: process.env.LOGOUT_URL,
LOGO_URL: process.env.LOGO_URL,
LOGO_DESTINATION: process.env.LOGO_DESTINATION,
},
};
const component = <HeaderComponent width={{ width: 500 }} contextValue={contextValue} />;
Expand Down
2 changes: 1 addition & 1 deletion src/learning-header/LearningHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const LearningHeader = ({
const headerLogo = (
<LinkedLogo
className="logo"
href={`${getConfig().LMS_BASE_URL}/dashboard`}
href={getConfig().LOGO_DESTINATION}
src={getConfig().LOGO_URL}
alt={getConfig().SITE_NAME}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ process.env.SEGMENT_KEY = 'segment_whoa';
process.env.SITE_NAME = 'edX';
process.env.USER_INFO_COOKIE_NAME = 'edx-user-info';
process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg';
process.env.LOGO_DESTINATION = `${process.env.LMS_BASE_URL}/dashboard`;
process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg';
process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg';
process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico';
Expand Down Expand Up @@ -65,6 +66,7 @@ export function initializeMockApp() {
ACCESS_TOKEN_COOKIE_NAME: process.env.ACCESS_TOKEN_COOKIE_NAME || null,
CSRF_TOKEN_API_PATH: process.env.CSRF_TOKEN_API_PATH || null,
LOGO_URL: process.env.LOGO_URL || null,
LOGO_DESTINATION: process.env.LOGO_DESTINATION || `${process.env.LMS_BASE_URL}/dashboard`,
SITE_NAME: process.env.SITE_NAME || null,

authenticatedUser: {
Expand Down
2 changes: 2 additions & 0 deletions src/studio-header/StudioHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ensureConfig([
'LOGOUT_URL',
'LOGIN_URL',
'LOGO_URL',
'LOGO_DESTINATION',
], 'Studio Header component');

const StudioHeader = ({
Expand All @@ -21,6 +22,7 @@ const StudioHeader = ({
const { authenticatedUser, config } = useContext(AppContext);
const props = {
logo: config.LOGO_URL,
logoDestination: config.LOGO_DESTINATION,
logoAltText: `Studio ${config.SITE_NAME}`,
number,
org,
Expand Down
1 change: 1 addition & 0 deletions src/studio-header/StudioHeader.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const RootWrapper = ({
config: {
LOGOUT_URL: process.env.LOGOUT_URL,
LOGO_URL: process.env.LOGO_URL,
LOGO_DESTINATION: process.env.LOGO_DESTINATION,
SITE_NAME: process.env.SITE_NAME,
STUDIO_BASE_URL: process.env.STUDIO_BASE_URL,
LOGIN_URL: process.env.LOGIN_URL,
Expand Down
Loading