Skip to content

Commit

Permalink
Final polishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Krulis committed Sep 9, 2019
1 parent 4c7739a commit 0da7e86
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import React from 'react';
import { FormattedMessage } from 'react-intl';
import { LoadingIcon } from '../../../icons';

import styles from '../Sidebar.less';

const LoadingMenuItem = () => (
<li>
<a>
<LoadingIcon gapRight />
<span
style={{
whiteSpace: 'normal',
}}>
<span className={styles.menuItem}>
<FormattedMessage id="generic.loading" defaultMessage="Loading..." />
</span>
</a>
Expand Down
24 changes: 4 additions & 20 deletions src/components/widgets/Sidebar/MenuAvatar/MenuAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

import styles from './MenuAvatar.less';
import styles from '../Sidebar.less';
import AvatarContainer from '../../../../containers/AvatarContainer/AvatarContainer';

const MenuAvatar = ({
title,
avatarUrl,
firstName,
notificationsCount = 0,
isActive = false,
useGravatar = false,
onClick,
}) => (
const MenuAvatar = ({ title, avatarUrl, firstName, notificationsCount = 0, isActive = false, onClick }) => (
<li
className={classnames({
active: isActive,
Expand All @@ -23,22 +15,15 @@ const MenuAvatar = ({
e.preventDefault();
onClick();
}}
style={{ cursor: 'pointer' }}>
className={styles.cursorPointer}>
<AvatarContainer
avatarUrl={avatarUrl}
fullName={title}
firstName={firstName}
size={20}
altClassName={styles.avatar}
/>
<span
style={{
whiteSpace: 'normal',
display: 'inline-block',
verticalAlign: 'top',
}}>
{title}
</span>
<span className={styles.menuItem}>{title}</span>
{notificationsCount > 0 && <small className="label pull-right bg-yellow">{notificationsCount}</small>}
</a>
</li>
Expand All @@ -51,7 +36,6 @@ MenuAvatar.propTypes = {
onClick: PropTypes.func,
notificationsCount: PropTypes.number,
isActive: PropTypes.bool,
useGravatar: PropTypes.bool,
};

export default MenuAvatar;
3 changes: 0 additions & 3 deletions src/components/widgets/Sidebar/MenuAvatar/MenuAvatar.less

This file was deleted.

20 changes: 5 additions & 15 deletions src/components/widgets/Sidebar/MenuGroup/MenuGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { isLoading } from '../../../../redux/helpers/resourceManager';
import { getLocalizedName } from '../../../../helpers/localizedData';
import Icon from '../../../icons';

import styles from '../Sidebar.less';

class MenuGroup extends Component {
state = {
open: null,
Expand Down Expand Up @@ -44,11 +46,6 @@ class MenuGroup extends Component {
intl: { locale },
} = this.props;

const dropdownStyles = {
overflowY: 'auto',
overflowX: 'hidden',
};

const itemsNotificationsCount = item => notifications[item.getIn(['data', 'id'])];
const notificationsCount = items.reduce((acc, item) => acc + itemsNotificationsCount(item), 0);

Expand All @@ -60,20 +57,13 @@ class MenuGroup extends Component {
})}>
<a href="#" onClick={this.toggle}>
<Icon icon={icon} gapRight fixedWidth />
<span
style={{
whiteSpace: 'normal',
display: 'inline-block',
verticalAlign: 'top',
}}>
{title}
</span>
<span className={styles.menuItem}>{title}</span>
<span className="pull-right-container">
{notificationsCount > 0 && <small className="label pull-right bg-blue">{notificationsCount}</small>}
<Icon icon="angle-left" className="pull-right" style={{ height: '15px' }} />
<Icon icon="angle-left" className={classnames({ [styles.arrowIcon]: true, 'pull-right': true })} />
</span>
</a>
<ul className="treeview-menu" style={dropdownStyles}>
<ul className={classnames({ 'treeview-menu': true, [styles.dropdown]: true })}>
{items.map((item, key) =>
isLoading(item) ? (
<LoadingMenuItem key={key} />
Expand Down
10 changes: 2 additions & 8 deletions src/components/widgets/Sidebar/MenuItem/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { withRouter } from 'react-router';
import { Link } from 'react-router-dom';

import Icon from '../../../icons';
import styles from '../Sidebar.less';

const MenuItem = ({
title,
Expand All @@ -24,14 +25,7 @@ const MenuItem = ({
})}>
<Link to={link} target={inNewTab ? '_blank' : undefined}>
<Icon icon={icon} fixedWidth gapRight />
<span
style={{
whiteSpace: 'normal',
display: 'inline-block',
verticalAlign: 'top',
}}>
{title}
</span>
<span className={styles.menuItem}>{title}</span>
{notificationsCount > 0 && <small className="label pull-right bg-yellow">{notificationsCount}</small>}
</Link>
</li>
Expand Down
22 changes: 22 additions & 0 deletions src/components/widgets/Sidebar/Sidebar.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.avatar {
margin-right: 6px;
}

.menuItem {
white-space: normal;
display: inline-block;
vertical-align: top;
}

.cursorPointer {
cursor: pointer;
}

.arrowIcon {
height: 15px !important;
}

.dropdown {
overflow-y: auto;
overflow-x: hidden;
}
2 changes: 1 addition & 1 deletion src/containers/CAS/AuthenticationButtonContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import withLinks from '../../helpers/withLinks';
const makeAbsolute = url =>
typeof window === 'undefined' ? url : `${window.location.origin}/${url.indexOf('/') === 0 ? url.substr(1) : url}`;

const ensureAbsoluteUrl = url => (url.match('^(https?:)?//.+') !== null ? url : makeAbsolute(url));
const ensureAbsoluteUrl = url => (url.match('^https?://.+') !== null ? url : makeAbsolute(url));

class AuthenticationButtonContainer extends Component {
constructor(props, context) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const createLink = path => {
const res = [...tokens]; // make a copy of URL path tokens (so we can fill in parameters)
index.forEach(idx => (res[idx] = params.shift())); // fill in parameters using indexed positions
while (res.length > 0 && !res[res.length - 1]) {
// remove empty parameters at the end
// remove empty parameters at the end (params.shift() will fill in undefined for every missing parameter)
res.pop();
}
res.unshift(URL_PATH_PREFIX);
Expand Down

0 comments on commit 0da7e86

Please sign in to comment.