new sidebar header

pull/9608/head
Karl Prieb 7 years ago
parent 42f2306bdb
commit d782ce6bb8
  1. 221
      packages/rocketchat-theme/client/imports/components/sidebar/sidebar-account.css
  2. 105
      packages/rocketchat-theme/client/imports/components/sidebar/sidebar-header.css
  3. 4
      packages/rocketchat-theme/client/imports/general/variables.css
  4. 2
      packages/rocketchat-theme/client/main.css
  5. 5
      packages/rocketchat-ui-master/public/icons.svg
  6. 27
      packages/rocketchat-ui-sidenav/client/accountBox.html
  7. 134
      packages/rocketchat-ui-sidenav/client/accountBox.js
  8. 8
      packages/rocketchat-ui-sidenav/client/createCombinedFlex.js
  9. 8
      packages/rocketchat-ui-sidenav/client/listChannelsFlex.js
  10. 8
      packages/rocketchat-ui-sidenav/client/listCombinedFlex.js
  11. 8
      packages/rocketchat-ui-sidenav/client/listPrivateGroupsFlex.js
  12. 5
      packages/rocketchat-ui-sidenav/client/sideNav.html
  13. 8
      packages/rocketchat-ui-sidenav/client/sideNav.js
  14. 21
      packages/rocketchat-ui-sidenav/client/sidebarHeader.html
  15. 189
      packages/rocketchat-ui-sidenav/client/sidebarHeader.js
  16. 4
      packages/rocketchat-ui-sidenav/package.js
  17. 14
      packages/rocketchat-ui/client/lib/accountBox.js
  18. 34
      packages/rocketchat-ui/client/lib/sideNav.js
  19. 35
      packages/rocketchat-ui/client/views/app/popover.js

@ -1,221 +0,0 @@
.sidebar-light {
& .sidebar__account-username {
color: var(--color-dark);
}
& .sidebar__account-menu {
fill: var(--color-dark);
}
& .sidebar__account.active:hover {
background-color: var(--sidebar-background-light-hover);
}
}
.sidebar__account {
display: flex;
margin: 0 0 var(--sidebar-extra-small-default-padding);
padding: var(--sidebar-extra-small-default-padding) var(--sidebar-default-padding);
transition: background-color 0.3s;
align-items: center;
&.active:hover {
cursor: pointer;
background-color: var(--sidebar-item-hover-background);
}
&-thumb {
flex: 0 0 var(--sidebar-account-thumb-size);
width: var(--sidebar-account-thumb-size);
height: var(--sidebar-account-thumb-size);
margin: 0 0.5rem 0 0;
}
&-data {
position: relative;
display: flex;
overflow: hidden;
flex-direction: column;
flex: 1;
margin: 0 0.5rem;
}
&-username {
overflow: hidden;
flex: 1;
max-width: fit-content;
height: calc(var(--sidebar-account-username-size) + 0.1rem);
white-space: nowrap;
text-overflow: ellipsis;
color: var(--sidebar-account-username-color);
font-size: var(--sidebar-account-username-size);
font-weight: var(--sidebar-account-username-weight);
line-height: calc(var(--sidebar-account-username-size) + 0.1rem);
}
&-visual-status {
max-width: 124px;
margin-right: 8px;
user-select: none;
font-size: var(--sidebar-account-status-font-size);
}
&-status {
display: flex;
margin: 0 -0.25rem;
color: var(--sidebar-account-status-color);
align-items: center;
}
&-status-bullet {
display: block;
width: var(--sidebar-account-status-bullet-size);
height: var(--sidebar-account-status-bullet-size);
margin: 0.25rem;
border-radius: var(--sidebar-account-status-bullet-radius);
&--online {
background-color: var(--status-online);
}
&--away {
background-color: var(--status-away);
}
&--busy {
background-color: var(--status-busy);
}
&--invisible {
background-color: var(--status-invisible);
}
&--offline {
background-color: var(--status-invisible);
}
}
&-label {
position: relative;
padding: 0;
cursor: pointer;
&:hover .sidebar__account-menu {
fill: var(--sidebar-account-status-color);
}
}
&-menu {
transition: fill 0.2s;
font-size: 1.375rem;
fill: var(--sidebar-account-username-color);
}
& .rc-popover {
top: 40px;
left: 0;
}
}
.rtl .sidebar__account .rc-popover {
right: 0;
left: initial;
}
@media (width <= 400px) {
.sidebar__account {
margin: 0 0 5px;
padding: var(--sidebar-extra-small-default-padding) calc(var(--sidebar-small-default-padding) - 8px) var(--sidebar-extra-small-default-padding);
&-thumb {
flex: 0 0 var(--sidebar-small-account-thumb-size);
width: var(--sidebar-small-account-thumb-size);
height: var(--sidebar-small-account-thumb-size);
}
&-data {
flex-direction: row;
margin: 0;
align-items: center;
}
&-username {
width: auto;
margin: 0 0.65rem;
font-weight: var(--sidebar-small-account-username-weight);
}
&-visual-status {
display: none;
}
&-status-bullet {
width: var(--sidebar-small-account-status-bullet-size);
height: var(--sidebar-small-account-status-bullet-size);
margin: 0;
}
}
}
.rc-popover--account {
& [data-type="set-state"] {
& .rc-icon {
font-size: var(--sidebar-account-status-bullet-size);
}
&.rc-popover__item {
&--online {
& .rc-icon {
color: var(--status-online);
}
}
&--away {
& .rc-icon {
color: var(--status-away);
}
}
&--busy {
& .rc-icon {
color: var(--status-busy);
}
}
&--offline {
& .rc-icon {
color: var(--status-invisible);
}
}
}
}
}

@ -0,0 +1,105 @@
.sidebar__header {
display: flex;
margin: 0 -10px;
padding: var(--sidebar-default-padding);
align-items: center;
&-thumb {
position: relative;
flex: 0 0 var(--sidebar-account-thumb-size);
width: var(--sidebar-account-thumb-size);
height: var(--sidebar-account-thumb-size);
margin: 0 10px;
}
&-status-bullet {
position: absolute;
right: -2px;
bottom: -1px;
display: block;
width: var(--sidebar-account-status-bullet-size);
height: var(--sidebar-account-status-bullet-size);
border-width: 2px;
border-style: solid;
border-color: var(--sidebar-background);
border-radius: var(--sidebar-account-status-bullet-radius);
&--online {
background-color: var(--status-online);
}
&--away {
background-color: var(--status-away);
}
&--busy {
background-color: var(--status-busy);
}
&--invisible {
background-color: var(--status-invisible);
}
&--offline {
background-color: var(--status-invisible);
}
}
}
.sidebar__toolbar {
display: flex;
flex: 1 1 100%;
margin: 0 10px;
justify-content: space-between;
&-button {
color: var(--sidebar-item-text-color);
font-size: 18px;
fill: var(--sidebar-item-text-color);
}
}
.rc-popover--sidebar-header {
& [data-type="set-state"] {
& .rc-icon {
font-size: var(--sidebar-account-status-bullet-size);
}
&.rc-popover__item {
&--online {
& .rc-icon {
color: var(--status-online);
}
}
&--away {
& .rc-icon {
color: var(--status-away);
}
}
&--busy {
& .rc-icon {
color: var(--status-busy);
}
}
&--offline {
& .rc-icon {
color: var(--status-invisible);
}
}
}
}
}

@ -176,9 +176,9 @@
/*
* Sidebar Account
*/
--sidebar-account-thumb-size: 36px;
--sidebar-account-thumb-size: 23px;
--sidebar-small-account-thumb-size: 40px;
--sidebar-account-status-bullet-size: 12px;
--sidebar-account-status-bullet-size: 10px;
--sidebar-small-account-status-bullet-size: 8px;
--sidebar-account-status-bullet-radius: 50%;
--sidebar-account-username-size: 1rem;

@ -17,7 +17,7 @@
/* Sidebar */
@import 'imports/components/sidebar/sidebar.css';
@import 'imports/components/sidebar/sidebar-account.css';
@import 'imports/components/sidebar/sidebar-header.css';
@import 'imports/components/sidebar/sidebar-item.css';
@import 'imports/components/sidebar/sidebar-flex.css';
@import 'imports/components/sidebar/toolbar.css';

@ -83,4 +83,9 @@
<symbol viewBox="0 0 512 512" id="icon-shield-check"><path d="M466.461 83.692l-192-80a47.996 47.996 0 0 0-36.923 0l-192 80A48 48 0 0 0 16 128c0 198.487 114.495 335.713 221.539 380.308a48 48 0 0 0 36.923 0C360.066 472.645 496 349.282 496 128a48 48 0 0 0-29.539-44.308zM262.154 478.768a16.64 16.64 0 0 1-12.31-.001C152 440 48 304 48 128c0-6.48 3.865-12.277 9.846-14.769l192-80a15.99 15.99 0 0 1 12.308 0l192 80A15.957 15.957 0 0 1 464 128c0 176-104 312-201.846 350.768zm144.655-299.505l-180.48 179.032c-4.705 4.667-12.303 4.637-16.97-.068l-85.878-86.572c-4.667-4.705-4.637-12.303.068-16.97l8.52-8.451c4.705-4.667 12.303-4.637 16.97.068l68.976 69.533 163.441-162.13c4.705-4.667 12.303-4.637 16.97.068l8.451 8.52c4.668 4.705 4.637 12.303-.068 16.97z"/></symbol>
<symbol viewBox="0 0 640 512" id="icon-team"><path d="M573.127 249.095C584.979 233.127 592 213.369 592 192c0-52.935-43.065-96-96-96-26.331 0-50.217 10.658-67.578 27.885a128.993 128.993 0 0 0-17.913-22.394C386.334 77.314 354.19 64 320 64s-66.334 13.314-90.51 37.49a129.115 129.115 0 0 0-17.913 22.394C194.217 106.658 170.331 96 144 96c-52.935 0-96 43.065-96 96 0 21.369 7.021 41.127 18.873 57.095C28.987 255.378 0 288.36 0 328v44c0 24.262 19.738 44 44 44h117.677c5.238 18.445 22.222 32 42.323 32h232c20.102 0 37.085-13.555 42.323-32H596c24.262 0 44-19.738 44-44v-44c0-39.64-28.986-72.622-66.873-78.905zM496 128c35.346 0 64 28.654 64 64s-28.654 64-64 64c-22.083 0-41.554-11.185-53.057-28.199C446.27 216.314 448 204.291 448 192s-1.73-24.314-5.057-35.801C454.446 139.185 473.917 128 496 128zM320 96c53.02 0 96 42.981 96 96s-42.98 96-96 96-96-42.981-96-96 42.98-96 96-96zm-176 32c22.083 0 41.554 11.185 53.057 28.199C193.73 167.686 192 179.709 192 192s1.73 24.314 5.057 35.801C185.554 244.815 166.083 256 144 256c-35.346 0-64-28.654-64-64s28.654-64 64-64zm16 224v32H44c-6.627 0-12-5.373-12-12v-44c0-26.51 21.49-48 48-48h25.655c24.374 10.662 52.272 10.681 76.689 0h22.81C178.452 292.976 160 320.372 160 352zm288 52c0 6.627-5.373 12-12 12H204c-6.627 0-12-5.373-12-12v-52c0-26.51 21.49-48 48-48h17.929c37.818 21.031 85.208 21.651 124.142 0H400c26.51 0 48 21.49 48 48v52zm160-32c0 6.627-5.373 12-12 12H480v-32c0-31.628-18.452-59.024-45.154-72h22.81c24.374 10.662 52.272 10.681 76.689 0H560c26.51 0 48 21.49 48 48v44z"/></symbol>
<symbol viewBox="0 0 640 512" id="icon-user-plus"><path d="M624 332v8c0 6.627-5.373 12-12 12h-68v68c0 6.627-5.373 12-12 12h-8c-6.627 0-12-5.373-12-12v-68h-68c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h68v-68c0-6.627 5.373-12 12-12h8c6.627 0 12 5.373 12 12v68h68c6.627 0 12 5.373 12 12zm-209.796 60.045A72.186 72.186 0 0 1 416 408v16c0 13.255-10.745 24-24 24H56c-13.255 0-24-10.745-24-24v-16c0-39.765 32.235-72 72-72h50.196c44.019 21.336 95.521 21.369 139.609 0H344c15.072 0 29.057 4.639 40.62 12.555-1.281-8.932-1.108-24.647 2.376-35.244C373.884 307.334 359.325 304 344 304h-5.753C367.477 274.198 384 234.32 384 192c0-88.353-71.613-160-160-160-88.353 0-160 71.613-160 160 0 42.261 16.481 82.155 45.753 112H104C46.654 304 0 350.654 0 408v16c0 30.879 25.122 56 56 56h336c30.879 0 56-25.121 56-56v-16c0-2.691-.103-5.359-.305-8-11.7 0-21.636-1.141-33.491-7.955zM96 192c0-70.693 57.308-128 128-128s128 57.307 128 128-57.308 128-128 128S96 262.693 96 192z"/></symbol>
<symbol viewBox="0 0 512 512" id="icon-globe"><path d="M504 256C504 118.815 392.705 8 256 8 119.371 8 8 118.74 8 256c0 136.938 111.041 248 248 248 136.886 0 248-110.987 248-248zm-41.625 64h-99.434c6.872-42.895 6.6-86.714.055-128h99.38c12.841 41.399 12.843 86.598-.001 128zM256.001 470.391c-30.732-27.728-54.128-69.513-67.459-118.391h134.917c-13.332 48.887-36.73 90.675-67.458 118.391zM181.442 320c-7.171-41.387-7.349-85.537.025-128h149.067c7.371 42.453 7.197 86.6.025 128H181.442zM256 41.617c33.557 30.295 55.554 74.948 67.418 118.383H188.582c11.922-43.649 33.98-88.195 67.418-118.383zM449.544 160h-93.009c-10.928-44.152-29.361-83.705-53.893-114.956C366.825 59.165 420.744 101.964 449.544 160zM209.357 45.044C184.826 76.293 166.393 115.847 155.464 160H62.456C91.25 101.975 145.162 59.169 209.357 45.044zM49.625 192h99.38c-6.544 41.28-6.818 85.1.055 128H49.625c-12.842-41.399-12.844-86.598 0-128zm12.831 160h93.122c11.002 44.176 29.481 83.824 53.833 114.968C144.875 452.786 91.108 409.738 62.456 352zm240.139 114.966c24.347-31.138 42.825-70.787 53.827-114.966h93.121c-28.695 57.827-82.504 100.802-146.948 114.966z"/></symbol>
<symbol viewBox="0 0 512 512" id="icon-th-list"><path d="M0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48H48C21.49 32 0 53.49 0 80zm480 0v90.667H192V64h272c8.837 0 16 7.163 16 16zm0 229.333H192V202.667h288v106.666zM32 202.667h128v106.667H32V202.667zM160 64v106.667H32V80c0-8.837 7.163-16 16-16h112zM32 432v-90.667h128V448H48c-8.837 0-16-7.163-16-16zm160 16V341.333h288V432c0 8.837-7.163 16-16 16H192z"/></symbol>
<symbol viewBox="0 0 512 512" id="icon-list"><path d="M506 114H134a6 6 0 0 1-6-6V84a6 6 0 0 1 6-6h372a6 6 0 0 1 6 6v24a6 6 0 0 1-6 6zm6 154v-24a6 6 0 0 0-6-6H134a6 6 0 0 0-6 6v24a6 6 0 0 0 6 6h372a6 6 0 0 0 6-6zm0 160v-24a6 6 0 0 0-6-6H134a6 6 0 0 0-6 6v24a6 6 0 0 0 6 6h372a6 6 0 0 0 6-6zM84 120V72c0-6.627-5.373-12-12-12H24c-6.627 0-12 5.373-12 12v48c0 6.627 5.373 12 12 12h48c6.627 0 12-5.373 12-12zm0 160v-48c0-6.627-5.373-12-12-12H24c-6.627 0-12 5.373-12 12v48c0 6.627 5.373 12 12 12h48c6.627 0 12-5.373 12-12zm0 160v-48c0-6.627-5.373-12-12-12H24c-6.627 0-12 5.373-12 12v48c0 6.627 5.373 12 12 12h48c6.627 0 12-5.373 12-12z"/></symbol>
<symbol viewBox="0 0 512 512" id="icon-list-alt"><path d="M464 64c8.823 0 16 7.178 16 16v352c0 8.822-7.177 16-16 16H48c-8.823 0-16-7.178-16-16V80c0-8.822 7.177-16 16-16h416m0-32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zm-336 96c-17.673 0-32 14.327-32 32s14.327 32 32 32 32-14.327 32-32-14.327-32-32-32zm0 96c-17.673 0-32 14.327-32 32s14.327 32 32 32 32-14.327 32-32-14.327-32-32-32zm0 96c-17.673 0-32 14.327-32 32s14.327 32 32 32 32-14.327 32-32-14.327-32-32-32zm288-148v-24a6 6 0 0 0-6-6H198a6 6 0 0 0-6 6v24a6 6 0 0 0 6 6h212a6 6 0 0 0 6-6zm0 96v-24a6 6 0 0 0-6-6H198a6 6 0 0 0-6 6v24a6 6 0 0 0 6 6h212a6 6 0 0 0 6-6zm0 96v-24a6 6 0 0 0-6-6H198a6 6 0 0 0-6 6v24a6 6 0 0 0 6 6h212a6 6 0 0 0 6-6z"/></symbol>
<symbol viewBox="0 0 448 512" id="icon-sort"><path d="M204.485 392l-84 84.485c-4.686 4.686-12.284 4.686-16.971 0l-84-84.485c-4.686-4.686-4.686-12.284 0-16.97l7.07-7.071c4.686-4.686 12.284-4.686 16.971 0L95 419.887V44c0-6.627 5.373-12 12-12h10c6.627 0 12 5.373 12 12v375.887l51.444-51.928c4.686-4.686 12.284-4.686 16.971 0l7.07 7.071c4.687 4.686 4.687 12.284 0 16.97zm100.492-220.355h61.547l15.5 44.317A12 12 0 0 0 393.351 224h11.552c8.31 0 14.105-8.243 11.291-16.062l-60.441-168A11.999 11.999 0 0 0 344.462 32h-16.924a11.999 11.999 0 0 0-11.291 7.938l-60.441 168c-2.813 7.82 2.981 16.062 11.291 16.062h11.271c5.12 0 9.676-3.248 11.344-8.088l15.265-44.267zm10.178-31.067l18.071-51.243c.853-2.56 1.776-5.626 2.668-8.743.871 3.134 1.781 6.219 2.644 8.806l17.821 51.18h-41.204zm-3.482 307.342c4.795-6.044-1.179 2.326 92.917-133.561a12.011 12.011 0 0 0 2.136-6.835V300c0-6.627-5.373-12-12-12h-113.84c-6.627 0-12 5.373-12 12v8.068c0 6.644 5.393 12.031 12.037 12.031 81.861.001 76.238.011 78.238-.026-2.973 3.818 4.564-7.109-92.776 133.303a12.022 12.022 0 0 0-2.142 6.847V468c0 6.627 5.373 12 12 12h119.514c6.627 0 12-5.373 12-12v-8.099c0-6.627-5.373-12-12-12-87.527-.001-81.97-.01-84.084.019z"/></symbol>
</svg>

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 46 KiB

@ -1,27 +0,0 @@
<template name="accountBox">
<div class="sidebar__account {{#unless isAnonymous}}active{{/unless}}" aria-label="{{_ "Account"}}" role="region">
{{#with myUserInfo}}
{{#if username}}
<div class="sidebar__account-thumb" data-status='{{visualStatus}}'>
{{> avatar username=username}}
</div>
<div class="sidebar__account-data">
{{#if fname}}
<h3 class="sidebar__account-username" data-username="{{username}}">{{fname}}</h3>
{{else}}
<h3 class="sidebar__account-username" data-username="{{username}}">@{{username}}</h3>
{{/if}}
<div class="sidebar__account-status">
<div class="sidebar__account-status-bullet sidebar__account-status-bullet--{{bullet}}" title="{{visualStatus}}"></div>
<div class="sidebar__account-visual-status">{{visualStatus}}</div>
</div>
</div>
{{#unless isAnonymous}}
<label class="sidebar__account-label">
{{> icon block="sidebar__account-menu" icon="menu"}}
</label>
{{/unless}}
{{/if}}
{{/with}}
</div>
</template>

@ -1,134 +0,0 @@
/* globals popover isRtl */
Template.accountBox.helpers({
myUserInfo() {
if (Meteor.user() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
return {
name: t('Anonymous'),
fname: RocketChat.settings.get('UI_Use_Real_Name') && t('Anonymous'),
status: 'online',
visualStatus: t('online'),
bullet: 'general-success-background',
username: 'anonymous'
};
}
const user = Meteor.user() || {};
const { name, username } = user;
const userStatus = Session.get(`user_${ username }_status`);
return {
name: Session.get(`user_${ username }_name`) || username,
status: Session.get(`user_${ username }_status`),
visualStatus: t(userStatus.charAt(0).toUpperCase() + userStatus.slice(1)),
bullet: userStatus,
_id: Meteor.userId(),
username,
fname: RocketChat.settings.get('UI_Use_Real_Name') && name
};
},
isAnonymous() {
if (Meteor.userId() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
return 'disabled';
}
}
});
Template.accountBox.events({
'click .sidebar__account.active'() {
let adminOption;
if (RocketChat.authz.hasAtLeastOnePermission(['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting' ]) || (RocketChat.AdminBox.getOptions().length > 0)) {
adminOption = {
icon: 'customize',
name: t('Administration'),
type: 'open',
id: 'administration'
};
}
const accountBox = document.querySelector('.sidebar__account');
const config = {
popoverClass: 'account',
columns: [
{
groups: [
{
title: t('User'),
items: [
{
icon: 'circle',
name: t('Online'),
type: 'set-state',
id: 'online',
modifier: 'online'
},
{
icon: 'circle',
name: t('Away'),
type: 'set-state',
id: 'away',
modifier: 'away'
},
{
icon: 'circle',
name: t('Busy'),
type: 'set-state',
id: 'busy',
modifier: 'busy'
},
{
icon: 'circle',
name: t('Invisible'),
type: 'set-state',
id: 'offline',
modifier: 'offline'
}
]
},
{
items: AccountBox.getItems().map(item => {
return {
icon: item.icon,
name: t(item.name),
type: 'open',
id: item.name,
href: item.href,
sideNav: item.sideNav
};
}).concat([
adminOption,
{
icon: 'user',
name: t('My_Account'),
type: 'open',
id: 'account'
},
{
icon: 'sign-out',
name: t('Logout'),
type: 'open',
id: 'logout'
}
])
}
]
}
],
position: {
top: accountBox.offsetHeight
},
customCSSProperties: {
width: `${ accountBox.offsetWidth - parseInt(getComputedStyle(accountBox)['padding-left'].replace('px', '')) * 2 }px`,
left: isRtl() ? 'auto' : getComputedStyle(accountBox)['padding-left'],
right: 'auto'
}
};
popover.open(config);
}
});
Template.accountBox.onRendered(() => AccountBox.init());

@ -78,14 +78,6 @@ Template.createCombinedFlex.events({
return SideNav.closeFlex(() => instance.clearForm());
},
'mouseenter header'() {
return SideNav.overArrow();
},
'mouseleave header'() {
return SideNav.leaveArrow();
},
'keydown input[type="text"]'() {
return Template.instance().error.set([]);
},

@ -40,14 +40,6 @@ Template.listChannelsFlex.events({
}
},
'mouseenter header'() {
return SideNav.overArrow();
},
'mouseleave header'() {
return SideNav.leaveArrow();
},
'scroll .content': _.throttle(function(e, t) {
if (t.hasMore.get() && (e.target.scrollTop >= (e.target.scrollHeight - e.target.clientHeight))) {
return t.limit.set(t.limit.get() + 50);

@ -43,14 +43,6 @@ Template.listCombinedFlex.events({
return SideNav.closeFlex();
},
'mouseenter header'() {
return SideNav.overArrow();
},
'mouseleave header'() {
return SideNav.leaveArrow();
},
'scroll .content': _.throttle(function(e, t) {
if (t.hasMore.get() && (e.target.scrollTop >= (e.target.scrollHeight - e.target.clientHeight))) {
return t.limit.set(t.limit.get() + 50);

@ -25,14 +25,6 @@ Template.listPrivateGroupsFlex.events({
return SideNav.closeFlex();
},
'mouseenter header'() {
return SideNav.overArrow();
},
'mouseleave header'() {
return SideNav.leaveArrow();
},
'scroll .content': _.throttle(function(e, t) {
if (t.hasMore.get() && (e.target.scrollTop >= (e.target.scrollHeight - e.target.clientHeight))) {
return t.limit.set(t.limit.get() + 50);

@ -1,9 +1,6 @@
<template name="sideNav">
<aside class="sidebar {{#if isLastMessageActive}}sidebar--big{{/if}}" role="navigation">
<header class="sidebar__header">
{{> accountBox }}
{{> toolbar}}
</header>
{{> sidebarHeader }}
{{#if loggedInUser}}
<div class="unread-rooms background-primary-action-color color-primary-action-contrast top-unread-rooms hidden">

@ -45,14 +45,6 @@ Template.sideNav.events({
return SideNav.toggleCurrent();
},
'mouseenter .header'() {
return SideNav.overArrow();
},
'mouseleave .header'() {
return SideNav.leaveArrow();
},
'scroll .rooms-list'() {
return menu.updateUnreadBars();
},

@ -0,0 +1,21 @@
<template name="sidebarHeader">
<header class="sidebar__header">
{{#with myUserInfo}}
<div class="sidebar__header-thumb">
{{> avatar username=username}}
<div class="sidebar__header-status-bullet sidebar__header-status-bullet--{{status}}"></div>
</div>
<div class="sidebar__toolbar">
{{#each button in toolbarButtons}}
{{> sidebarHeaderButton button}}
{{/each}}
</div>
{{/with}}
</header>
</template>
<template name="sidebarHeaderButton">
<button class="sidebar__toolbar-button rc-tooltip rc-tooltip--down js-button" aria-label="{{name}}">
{{> icon block="sidebar__toolbar-button-icon" icon=icon }}
</button>
</template>

@ -0,0 +1,189 @@
/* globals popover isRtl */
const toolbarButtons = [
{
name: t('Search'),
icon: 'magnifier'
},
{
name: t('Browse_channels'),
icon: 'globe'
},
{
name: t('View_mode'),
icon: 'th-list'
},
{
name: t('Sort'),
icon: 'sort'
},
{
name: t('Create_A_New_Channel'),
icon: 'plus',
condition: () => !(Meteor.userId() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead'))
},
{
name: t('Options'),
icon: 'menu',
condition: () => !(Meteor.userId() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')),
action: () => {
let adminOption;
if (RocketChat.authz.hasAtLeastOnePermission(['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting' ]) || (RocketChat.AdminBox.getOptions().length > 0)) {
adminOption = {
icon: 'customize',
name: t('Administration'),
type: 'open',
id: 'administration',
action: () => {
SideNav.setFlex('adminFlex');
SideNav.openFlex();
FlowRouter.go('admin-info');
popover.close();
}
};
}
const sidebarHeader = document.querySelector('.sidebar__header');
const sidebarHeaderPadding = parseInt(getComputedStyle(sidebarHeader)['padding-left'].replace('px', '')) * 2;
const sidebarHeaderMargin = parseInt(getComputedStyle(sidebarHeader)['margin-left'].replace('px', '')) * 2;
const config = {
popoverClass: 'sidebar-header',
columns: [
{
groups: [
{
title: t('User'),
items: [
{
icon: 'circle',
name: t('Online'),
type: 'set-state',
id: 'online',
modifier: 'online'
},
{
icon: 'circle',
name: t('Away'),
type: 'set-state',
id: 'away',
modifier: 'away'
},
{
icon: 'circle',
name: t('Busy'),
type: 'set-state',
id: 'busy',
modifier: 'busy'
},
{
icon: 'circle',
name: t('Invisible'),
type: 'set-state',
id: 'offline',
modifier: 'offline'
}
]
},
{
items: AccountBox.getItems().map(item => {
let action;
if (item.href) {
action = () => {
FlowRouter.go(item.href);
popover.close();
};
}
if (item.sideNav) {
action = () => {
SideNav.setFlex(item.sideNav);
SideNav.openFlex();
popover.close();
};
}
return {
icon: item.icon,
name: t(item.name),
type: 'open',
id: item.name,
href: item.href,
sideNav: item.sideNav,
action
};
}).concat([
adminOption,
{
icon: 'user',
name: t('My_Account'),
type: 'open',
id: 'account',
action: () => {
SideNav.setFlex('accountFlex');
SideNav.openFlex();
FlowRouter.go('account');
popover.close();
}
},
{
icon: 'sign-out',
name: t('Logout'),
type: 'open',
id: 'logout',
action: () => {
const user = Meteor.user();
Meteor.logout(() => {
RocketChat.callbacks.run('afterLogoutCleanUp', user);
Meteor.call('logoutCleanUp', user);
FlowRouter.go('home');
popover.close();
});
}
}
])
}
]
}
],
position: {
top: sidebarHeader.offsetHeight
},
customCSSProperties: {
width: `${ sidebarHeader.offsetWidth - sidebarHeaderPadding + sidebarHeaderMargin }px`,
left: isRtl() ? 'auto' : getComputedStyle(sidebarHeader)['padding-left'],
right: isRtl() ? getComputedStyle(sidebarHeader)['padding-left'] : 'auto'
}
};
popover.open(config);
}
}];
Template.sidebarHeader.helpers({
myUserInfo() {
if (Meteor.user() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
return {
username: 'anonymous',
status: 'online'
};
}
const user = Meteor.user() || {};
const { username } = user;
const userStatus = Session.get(`user_${ username }_status`);
return {
username,
status: userStatus
};
},
toolbarButtons() {
return toolbarButtons.filter(button => !button.condition || button.condition());
}
});
Template.sidebarHeaderButton.events({
'click .js-button'(e) {
return this.action && this.action.apply(this);
}
});

@ -18,24 +18,24 @@ Package.onUse(function(api) {
'rocketchat:ui'
]);
api.addFiles('client/accountBox.html', 'client');
api.addFiles('client/createCombinedFlex.html', 'client');
api.addFiles('client/chatRoomItem.html', 'client');
api.addFiles('client/listChannelsFlex.html', 'client');
api.addFiles('client/listCombinedFlex.html', 'client');
api.addFiles('client/listPrivateGroupsFlex.html', 'client');
api.addFiles('client/sidebarHeader.html', 'client');
api.addFiles('client/sidebarItem.html', 'client');
api.addFiles('client/sideNav.html', 'client');
api.addFiles('client/toolbar.html', 'client');
api.addFiles('client/roomList.html', 'client');
api.addFiles('client/userStatus.html', 'client');
api.addFiles('client/accountBox.js', 'client');
api.addFiles('client/createCombinedFlex.js', 'client');
api.addFiles('client/chatRoomItem.js', 'client');
api.addFiles('client/listChannelsFlex.js', 'client');
api.addFiles('client/listCombinedFlex.js', 'client');
api.addFiles('client/listPrivateGroupsFlex.js', 'client');
api.addFiles('client/sidebarHeader.js', 'client');
api.addFiles('client/sidebarItem.js', 'client');
api.addFiles('client/sideNav.js', 'client');
api.addFiles('client/roomList.js', 'client');

@ -2,7 +2,6 @@ import _ from 'underscore';
this.AccountBox = (function() {
let status = 0;
const self = {};
const items = new ReactiveVar([]);
function setStatus(status) {
return Meteor.call('UserPresence:setDefaultStatus', status);
@ -13,15 +12,9 @@ this.AccountBox = (function() {
return;
}
status = 1;
self.options.removeClass('animated-hidden');
self.box.addClass('active');
return SideNav.toggleArrow(1);
}
function close() {
status = 0;
self.options.addClass('animated-hidden');
self.box.removeClass('active');
return SideNav.toggleArrow(-1);
}
function toggle() {
if (status) {
@ -32,12 +25,6 @@ this.AccountBox = (function() {
}
function openFlex() {
status = 0;
self.options.addClass('animated-hidden');
return self.box.removeClass('active');
}
function init() {
self.box = $('.account-box');
return self.options = self.box.find('.options');
}
/*
@ -100,7 +87,6 @@ this.AccountBox = (function() {
open,
close,
openFlex,
init,
addRoute,
addItem,
getItems

@ -3,26 +3,10 @@ this.SideNav = new class {
this.initiated = false;
this.sideNav = {};
this.flexNav = {};
this.arrow = {};
this.animating = false;
this.openQueue = [];
}
toggleArrow(status = null) {
if (status === 0) {
this.arrow.addClass('close');
this.arrow.removeClass('top');
return this.arrow.removeClass('bottom');
} else if (status === -1 || (status !== 1 && this.arrow.hasClass('top'))) {
this.arrow.removeClass('close');
this.arrow.removeClass('top');
return this.arrow.addClass('bottom');
} else {
this.arrow.removeClass('close');
this.arrow.addClass('top');
return this.arrow.removeClass('bottom');
}
}
toggleFlex(status, callback) {
if (this.animating === true) {
return;
@ -61,7 +45,6 @@ this.SideNav = new class {
if (this.animating === true) {
return;
}
this.toggleArrow(-1);
return this.toggleFlex(-1, callback);
}
flexStatus() {
@ -88,20 +71,6 @@ this.SideNav = new class {
return AccountBox.toggle();
}
}
overArrow() {
return this.arrow.addClass('hover');
}
leaveArrow() {
return this.arrow.removeClass('hover');
}
arrowBindHover() {
this.arrow.on('mouseenter', () => {
return this.sideNav.find('header').addClass('hover');
});
return this.arrow.on('mouseout', () => {
return this.sideNav.find('header').removeClass('hover');
});
}
focusInput() {
const sideNavDivs = [...this.sideNav[0].children].filter(el => {
return el.tagName === 'DIV' && !el.classList.contains('hidden');
@ -144,7 +113,6 @@ this.SideNav = new class {
return;
}
AccountBox.close();
this.toggleArrow(0);
this.toggleFlex(1, callback);
return this.focusInput();
}
@ -152,9 +120,7 @@ this.SideNav = new class {
init() {
this.sideNav = $('.sidebar');
this.flexNav = this.sideNav.find('.flex-nav');
this.arrow = this.sideNav.children('.arrow');
this.setFlex('');
this.arrowBindHover();
this.initiated = true;
if (this.openQueue.length > 0) {
this.openQueue.forEach((item) => {

@ -169,41 +169,6 @@ Template.popover.events({
RocketChat.callbacks.run('userStatusManuallySet', e.currentTarget.dataset.status);
popover.close();
},
'click [data-type="open"]'(e) {
const data = e.currentTarget.dataset;
switch (data.id) {
case 'account':
SideNav.setFlex('accountFlex');
SideNav.openFlex();
FlowRouter.go('account');
break;
case 'logout':
const user = Meteor.user();
Meteor.logout(() => {
RocketChat.callbacks.run('afterLogoutCleanUp', user);
Meteor.call('logoutCleanUp', user);
FlowRouter.go('home');
});
break;
case 'administration':
SideNav.setFlex('adminFlex');
SideNav.openFlex();
FlowRouter.go('admin-info');
break;
}
if (data.href) {
FlowRouter.go(data.href);
}
if (data.sideNav) {
SideNav.setFlex(data.sideNav);
SideNav.openFlex();
}
popover.close();
},
'click [data-type="sidebar-item"]'(e, instance) {
popover.close();
const { rid, name, template } = instance.data.data;

Loading…
Cancel
Save