Skip to content

Commit

Permalink
fix: use helpLink from settings end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Nov 17, 2020
1 parent 19bde26 commit e2a1ac6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/widgets/src/HeaderBar/HeaderBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const query = {
title: {
resource: 'systemSettings/applicationTitle',
},
help: {
resource: 'systemSettings/helpLink',
},
user: {
resource: 'me',
},
Expand Down Expand Up @@ -71,7 +74,7 @@ export const HeaderBar = ({ appName, className }) => {
userAuthorities={data.user.authorities}
/>
<Apps apps={apps} />
<Profile user={data.user} baseUrl={baseUrl} />
<Profile user={data.user} baseUrl={baseUrl} helpUrl={data.help.helpLink}/>
</>
)}

Expand Down
3 changes: 3 additions & 0 deletions packages/widgets/src/HeaderBar/HeaderBar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const customData = {
'systemSettings/applicationTitle': {
applicationTitle: 'Foobar',
},
'systemSettings/helpLink': {
helpLink: '//custom-help-link',
},
me: {
name: 'John Doe',
email: '[email protected]',
Expand Down
3 changes: 2 additions & 1 deletion packages/widgets/src/HeaderBar/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class Profile extends React.Component {
}

render() {
const { user, baseUrl } = this.props
const { user, baseUrl, helpUrl } = this.props

return (
<div
Expand All @@ -72,6 +72,7 @@ export default class Profile extends React.Component {
avatar={avatarPath(user.avatar, baseUrl)}
name={user.name}
email={user.email}
helpUrl={helpUrl}
/>
) : null}

Expand Down
17 changes: 10 additions & 7 deletions packages/widgets/src/HeaderBar/Profile/ProfileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const iconStyle = css.resolve`
}
`

const getMenuList = () => [
const getMenuList = (helpUrl) => [
{
icon: <Settings className={iconStyle.className} />,
label: i18n.t('Settings'),
Expand All @@ -40,8 +40,9 @@ const getMenuList = () => [
icon: <Help className={iconStyle.className} />,
label: i18n.t('Help'),
value: 'help',
link:
'https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en.html',
link: helpUrl
? helpUrl
: 'https://docs.dhis2.org/master/en/user/html/dhis2_user_manual_en.html',
nobase: true,
},
{
Expand All @@ -58,7 +59,7 @@ const getMenuList = () => [
},
]

const ProfileContents = ({ name, email, avatar }) => {
const ProfileContents = ({ name, email, avatar, helpUrl }) => {
const { baseUrl } = useConfig()

return (
Expand All @@ -67,7 +68,7 @@ const ProfileContents = ({ name, email, avatar }) => {
<ProfileHeader name={name} email={email} img={avatar} />
<Divider margin="13px 0 7px 0" />
<ul data-test="headerbar-profile-menu">
{getMenuList().map(
{getMenuList(helpUrl).map(
({ label, value, icon, link, nobase }) => (
<MenuItem
href={nobase ? link : joinPath(baseUrl, link)}
Expand Down Expand Up @@ -110,11 +111,12 @@ ProfileContents.propTypes = {
avatar: propTypes.element,
email: propTypes.string,
name: propTypes.string,
helpUrl: propTypes.string,
}

export const ProfileMenu = ({ avatar, name, email }) => (
export const ProfileMenu = ({ avatar, name, email, helpUrl }) => (
<div data-test="headerbar-profile-menu">
<ProfileContents name={name} email={email} avatar={avatar} />
<ProfileContents name={name} email={email} avatar={avatar} helpUrl={helpUrl} />
<style jsx>{`
div {
z-index: 10000;
Expand All @@ -132,4 +134,5 @@ ProfileMenu.propTypes = {
avatar: propTypes.element,
email: propTypes.string,
name: propTypes.string,
helpUrl: propTypes.string,
}

0 comments on commit e2a1ac6

Please sign in to comment.