Skip to content

Commit

Permalink
Merge pull request #441 from frontside-folio/jc/current-app
Browse files Browse the repository at this point in the history
STCOR-255 Make current app clickable
  • Loading branch information
cherewaty authored Oct 1, 2018
2 parents 025e33f + 7933044 commit b9e7d5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Add `react-hot-loader` to development environment
* Remove notifications, STCOR-257
* Use new type stack
* Make current app clickable, STCOR-255

## [2.13.0](https://github.com/folio-org/stripes-core/tree/v2.13.0) (2018-09-18)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v2.12.0...v2.13.0)
Expand Down
17 changes: 15 additions & 2 deletions src/components/MainNav/CurrentApp/CurrentApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import Link from 'react-router-dom/Link';
import AppIcon from '@folio/stripes-components/lib/AppIcon';
import Badge from '@folio/stripes-components/lib/Badge';
import Headline from '@folio/stripes-components/lib/Headline';
Expand Down Expand Up @@ -31,13 +32,25 @@ const defaultProps = {
const CurrentApp = ({ currentApp, iconData, id, badge }) => {
const { displayName, description, module } = currentApp;
const iconKey = module && module.replace(/^@[a-z0-9_]+\//, '');
let Element = 'div';
let elementProps = {};

if (currentApp && (currentApp.home || currentApp.route)) {
Element = Link;
elementProps = { to: (currentApp.home || currentApp.route) };
}

return (
<div id={id} title={description} className={css.currentApp}>
<Element
id={id}
className={css.currentApp}
title={description}
{...elementProps}
>
{badge && (<Badge color="red" className={css.badge}>{badge}</Badge>)}
<AppIcon icon={iconData} app={iconKey} className={css.icon} />
<Headline tag="h1" size="small" margin="none">{displayName}</Headline>
</div>
</Element>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/components/MainNav/MainNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class MainNav extends Component {
alt: 'Tenant Settings',
title: 'Settings',
},
route: '/settings'
});
}

Expand Down

0 comments on commit b9e7d5b

Please sign in to comment.