feat: fix accounts issue.

This commit is contained in:
Ahmed Bouhuolia
2020-06-25 13:43:47 +02:00
parent 6074134a53
commit 111aa83908
46 changed files with 797 additions and 345 deletions

View File

@@ -8,15 +8,10 @@ import DialogsContainer from 'components/DialogsContainer';
import PreferencesContent from 'components/Preferences/PreferencesContent';
import PreferencesSidebar from 'components/Preferences/PreferencesSidebar';
import Search from 'containers/GeneralSearch/Search';
import withDashboard from 'containers/Dashboard/withDashboard';
import { compose } from 'utils';
function Dashboard({ sidebarExpended }) {
export default function Dashboard() {
return (
<div className={classNames('dashboard', {
'has-mini-sidebar': !sidebarExpended,
})}>
<div className={classNames('dashboard')}>
<Switch>
<Route path="/preferences">
<Sidebar />
@@ -35,9 +30,3 @@ function Dashboard({ sidebarExpended }) {
</div>
);
}
export default compose(
withDashboard(({ sidebarExpended }) => ({
sidebarExpended,
})),
)(Dashboard);

View File

@@ -0,0 +1,79 @@
import React, { useState, useMemo } from 'react';
import { FormattedMessage as T } from 'react-intl';
import PropTypes from 'prop-types';
import { Button, Tabs, Tab, Tooltip, Position } from '@blueprintjs/core';
import { If, Icon } from 'components';
export default function DashboardViewsTabs({
tabs,
allTab = true,
newViewTab = true,
onNewViewTabClick,
onChange,
onTabClick,
}) {
const [currentView, setCurrentView] = useState(0);
const handleClickNewView = () => {
onNewViewTabClick && onNewViewTabClick();
};
const handleTabClick = (viewId) => {
onTabClick && onTabClick(viewId);
};
const mappedTabs = useMemo(
() => tabs.map((tab) => ({ ...tab, onTabClick: handleTabClick })),
[tabs],
);
const handleViewLinkClick = () => {
onNewViewTabClick && onNewViewTabClick();
};
const handleTabsChange = (viewId) => {
setCurrentView(viewId);
onChange && onChange(viewId);
};
return (
<Tabs
id="navbar"
large={true}
selectedTabId={currentView}
className="tabs--dashboard-views"
onChange={handleTabsChange}
>
{allTab && (
<Tab id={0} title={<T id={'all'} />} onClick={handleViewLinkClick} />
)}
{mappedTabs.map((tab) => (
<Tab id={tab.id} title={tab.name} onClick={handleTabClick} />
))}
<If condition={newViewTab}>
<Tooltip
content={<T id={'create_a_new_view'} />}
position={Position.RIGHT}
>
<Button
className="button--new-view"
icon={<Icon icon="plus" />}
onClick={handleClickNewView}
minimal={true}
/>
</Tooltip>
</If>
</Tabs>
);
}
DashboardViewsTabs.propTypes = {
tabs: PropTypes.array.isRequired,
allTab: PropTypes.bool,
newViewTab: PropTypes.bool,
onNewViewTabClick: PropTypes.func,
onChange: PropTypes.func,
onTabClick: PropTypes.func,
};