mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: dashboard back link in expand mode.
This commit is contained in:
38
client/src/components/Dashboard/DashboardBackLink.js
Normal file
38
client/src/components/Dashboard/DashboardBackLink.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import withBreadcrumbs from 'react-router-breadcrumbs-hoc';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import routes from 'routes/dashboard';
|
||||
import { If, Icon } from 'components';
|
||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||
import { compose } from 'utils';
|
||||
|
||||
function DashboardBackLink({ dashboardBackLink, breadcrumbs }) {
|
||||
const history = useHistory();
|
||||
const crumb = breadcrumbs[breadcrumbs.length - 2];
|
||||
|
||||
const handleClick = (event) => {
|
||||
const url =
|
||||
typeof dashboardBackLink === 'string'
|
||||
? dashboardBackLink
|
||||
: crumb.match.url;
|
||||
history.push(url);
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
return (
|
||||
<If condition={dashboardBackLink && crumb}>
|
||||
<div class="dashboard__back-link">
|
||||
<a href="#no-link" onClick={handleClick}>
|
||||
<Icon icon={'arrow-left'} iconSize={18} /> Back to list.
|
||||
</a>
|
||||
</div>
|
||||
</If>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withBreadcrumbs(routes),
|
||||
withDashboard(({ dashboardBackLink }) => ({
|
||||
dashboardBackLink,
|
||||
})),
|
||||
)(DashboardBackLink);
|
||||
@@ -9,7 +9,7 @@ import withBreadcrumbs from 'react-router-breadcrumbs-hoc';
|
||||
import routes from 'routes/dashboard';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
function DashboardBreadcrumbs( {breadcrumbs }){
|
||||
function DashboardBreadcrumbs({ breadcrumbs }){
|
||||
const history = useHistory();
|
||||
|
||||
return(
|
||||
|
||||
@@ -13,6 +13,7 @@ import { FormattedMessage as T } from 'react-intl';
|
||||
|
||||
import DashboardTopbarUser from 'components/Dashboard/TopbarUser';
|
||||
import DashboardBreadcrumbs from 'components/Dashboard/DashboardBreadcrumbs';
|
||||
import DashboardBackLink from 'components/Dashboard/DashboardBackLink';
|
||||
import { Icon, Hint, If } from 'components';
|
||||
|
||||
import withSearch from 'containers/GeneralSearch/withSearch';
|
||||
@@ -114,6 +115,8 @@ function DashboardTopbar({
|
||||
<div class="dashboard__breadcrumbs">
|
||||
<DashboardBreadcrumbs />
|
||||
</div>
|
||||
|
||||
<DashboardBackLink />
|
||||
</div>
|
||||
|
||||
<div class="dashboard__topbar-right">
|
||||
|
||||
Reference in New Issue
Block a user