- Organize database seeds.

- Optimize design dashboard top bar.
This commit is contained in:
Ahmed Bouhuolia
2020-03-26 22:34:02 +02:00
parent a399052a30
commit d695188d3a
18 changed files with 121 additions and 45 deletions

View File

@@ -51,9 +51,7 @@ function AccountsDataTable({
]);
});
useEffect(() => {
fetchHook.execute();
}, [filterConditions]);
useEffect(() => { fetchHook.execute(); }, [filterConditions]);
// Refetch accounts list after custom view id change.
useEffect(() => {
@@ -64,20 +62,13 @@ function AccountsDataTable({
changeCurrentView(customViewId);
setTopbarEditView(customViewId);
}
if (customViewId && viewMeta) {
changePageSubtitle(viewMeta.name);
} else {
changePageSubtitle('');
}
changePageSubtitle((customViewId && viewMeta) ? viewMeta.name : '');
}, [customViewId]);
useEffect(
() => () => {
// Clear page subtitle when unmount the page.
changePageSubtitle('');
},
[]
);
useEffect(() => () => {
// Clear page subtitle when unmount the page.
changePageSubtitle('');
}, []);
const handleEditAccount = account => () => {
openDialog('account-form', { action: 'edit', id: account.id });
@@ -91,12 +82,10 @@ function AccountsDataTable({
<MenuDivider />
<MenuItem
text='Inactivate Account'
onClick={() => onInactiveAccount(account)}
/>
onClick={() => onInactiveAccount(account)} />
<MenuItem
text='Delete Account'
onClick={() => onDeleteAccount(account)}
/>
onClick={() => onDeleteAccount(account)} />
</Menu>
);

View File

@@ -14,18 +14,29 @@ import Icon from 'components/Icon';
import { Link } from 'react-router-dom';
import { compose } from 'utils';
import AccountsConnect from 'connectors/Accounts.connector';
import DashboardConnect from 'connectors/Dashboard.connector';
function AccountsViewsTabs({ views }) {
function AccountsViewsTabs({
views,
setTopbarEditView,
}) {
const history = useHistory();
const { custom_view_id: customViewId } = useParams();
const handleClickNewView = () => {
setTopbarEditView(null);
history.push('/dashboard/custom_views/accounts/new');
};
const handleViewLinkClick = () => {
setTopbarEditView(customViewId);
}
const tabs = views.map(view => {
const baseUrl = '/dashboard/accounts';
const link = (
<Link to={`${baseUrl}/${view.id}/custom_view`}>{view.name}</Link>
<Link
to={`${baseUrl}/${view.id}/custom_view`}
onClick={handleViewLinkClick}
>{view.name}</Link>
);
return <Tab id={`custom_view_${view.id}`} title={link} />;
});
@@ -52,4 +63,7 @@ function AccountsViewsTabs({ views }) {
);
}
export default compose(AccountsConnect)(AccountsViewsTabs);
export default compose(
AccountsConnect,
DashboardConnect,
)(AccountsViewsTabs);

View File

@@ -25,6 +25,14 @@ function DashboardTopbar({
const handlerClickEditView = () => {
history.push(`/dashboard/custom_views/${editViewId}/edit`)
}
const maybleRenderPageSubtitle = pageSubtitle && (<h3>{ pageSubtitle }</h3>);
const maybeRenderEditViewBtn = (pageSubtitle && editViewId) && (
<Button
className={Classes.MINIMAL + ' button--view-edit'}
icon={<Icon icon="pen" iconSize={13} />}
onClick={handlerClickEditView} />
);
return (
<div class="dashboard__topbar">
<div class="dashboard__topbar-left">
@@ -39,17 +47,8 @@ function DashboardTopbar({
<div class="dashboard__title">
<h1>{ pageTitle }</h1>
{ pageSubtitle && (
<>
<span class="sep"></span>
<h3>{ pageSubtitle }</h3>
<Button
className="button--view-edit"
icon={<Icon icon="pen" />}
onClick={handlerClickEditView} />
</>
)}
{maybleRenderPageSubtitle}
{maybeRenderEditViewBtn}
</div>
<div class="dashboard__breadcrumbs">

View File

@@ -74,5 +74,9 @@ export default {
"archive": {
path: ['M464 32H48C21.5 32 0 53.5 0 80v80c0 8.8 7.2 16 16 16h16v272c0 17.7 14.3 32 32 32h384c17.7 0 32-14.3 32-32V176h16c8.8 0 16-7.2 16-16V80c0-26.5-21.5-48-48-48zm-32 400H80V176h352v256zm32-304H48V80h416v48zM204 272h104c6.6 0 12-5.4 12-12v-24c0-6.6-5.4-12-12-12H204c-6.6 0-12 5.4-12 12v24c0 6.6 5.4 12 12 12'],
viewBox: '0 0 512 512',
},
"pen": {
path: ['M493.26 56.26l-37.51-37.51C443.25 6.25 426.87 0 410.49 0s-32.76 6.25-45.25 18.74l-74.49 74.49L256 127.98 12.85 371.12.15 485.34C-1.45 499.72 9.88 512 23.95 512c.89 0 1.79-.05 2.69-.15l114.14-12.61L384.02 256l34.74-34.74 74.49-74.49c25-25 25-65.52.01-90.51zM118.75 453.39l-67.58 7.46 7.53-67.69 231.24-231.24 31.02-31.02 60.14 60.14-31.02 31.02-231.33 231.33zm340.56-340.57l-44.28 44.28-60.13-60.14 44.28-44.28c4.08-4.08 8.84-4.69 11.31-4.69s7.24.61 11.31 4.69l37.51 37.51c6.24 6.25 6.24 16.4 0 22.63z'],
viewBox: '0 0 512 512',
}
}

View File

@@ -41,7 +41,7 @@ export default createReducer(initialState, {
},
[t.SET_TOPBAR_EDIT_VIEW]: (state, action) => {
state.topbarEditViewId = action.id;
state.topbarEditViewId = action.id;
}
});

View File

@@ -162,22 +162,34 @@
font-weight: 100;
margin: 0;
}
.sep{
margin-left: 12px;
margin-right: 12px;
color: #999;
border-left: 1px solid #d9d9d9;
width: 1px;
height: 25px;
}
h3{
border-left: 1px solid #d9d9d9;
padding-left: 10px;
font-size: 16px;
font-weight: 300;
color: #777;
margin: 0;
margin: 0 0 0 12px;
padding-top: 4px;
padding-bottom: 4px;
}
.button--view-edit{
svg{
color: #929699;
}
&:hover,
&:focus{
svg{
color: #5c7080;
}
}
}
}
&__subtitle{
}
&-content{