-
Notifications
You must be signed in to change notification settings - Fork 81
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: replace hardcoded edx string with site_name from configs #425
Merged
jristau1984
merged 3 commits into
openedx:master
from
raccoongang:romaniuk/feat/replace-hardcoded-edx-string
Mar 9, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { Helmet } from 'react-helmet'; | ||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import messages from './messages'; | ||
|
||
const Head = ({ intl }) => ( | ||
<Helmet> | ||
<title> | ||
{intl.formatMessage(messages['course-authoring.page.title'], { siteName: getConfig().SITE_NAME })} | ||
</title> | ||
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" /> | ||
</Helmet> | ||
); | ||
|
||
Head.propTypes = { | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export default injectIntl(Head); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { Helmet } from 'react-helmet'; | ||
import { mount } from 'enzyme'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import Head from './Head'; | ||
|
||
describe('Head', () => { | ||
const props = {}; | ||
it('should match render title tag and favicon with the site configuration values', () => { | ||
mount(<IntlProvider locale="en"><Head {...props} /></IntlProvider>); | ||
const helmet = Helmet.peek(); | ||
expect(helmet.title).toEqual(`Course Authoring | ${getConfig().SITE_NAME}`); | ||
expect(helmet.linkTags[0].rel).toEqual('shortcut icon'); | ||
expect(helmet.linkTags[0].href).toEqual(getConfig().FAVICON_URL); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
'course-authoring.page.title': { | ||
id: 'course-authoring.page.title', | ||
defaultMessage: 'Course Authoring | {siteName}', | ||
description: 'Title tag', | ||
}, | ||
}); | ||
|
||
export default messages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arbrandes This uses static configuration (
process.env.SITE_NAME
) instead of runtime configuration (getConfig().SITE_NAME
). Am I right in presuming that runtime config isn't available in this file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, just a static configuration. Also, this approach is used by all MFEs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ihor-romaniuk, right. However, Kyle's point is relevant: in order to truly fix the problem, we'll have to introduce a way to get the
SITE_NAME
dynamically.We can use
frontend-app-account
as a template. See the<Head />
component that was introduced there for this very purpose. It makes use of the<Helmet />
component to modify the page title with the dynamically-obtained site name.Do you mind doing that here as well? Otherwise, the change is not very useful to current users.