From d695188d3a7028ec8897a4adbe4b89b9d7798435 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 26 Mar 2020 22:34:02 +0200 Subject: [PATCH] - Organize database seeds. - Optimize design dashboard top bar. --- .../components/Accounts/AccountsDataTable.js | 27 +++++---------- .../components/Accounts/AccountsViewsTabs.js | 20 +++++++++-- .../components/Dashboard/DashboardTopbar.js | 21 ++++++------ client/src/static/json/icons.js | 4 +++ .../src/store/dashboard/dashboard.reducer.js | 2 +- client/src/style/pages/dashboard.scss | 34 +++++++++++++------ .../20190423085240_create_resources_table.js | 4 +++ .../20190822214242_create_users_table.js | 4 +++ .../20190822214304_create_accounts_table.js | 4 +++ ...190822214904_create_account_types_table.js | 4 +++ ...0822214905_create_resource_fields_table.js | 4 +++ ...20190822214905_create_views_roles_table.js | 4 +++ .../20190822214905_create_views_table.js | 4 +++ ...account_types.js => seed_account_types.js} | 0 .../seeds/{accounts.js => seed_accounts.js} | 0 .../seeds/{users.js => seed_users.js} | 0 server/src/database/seeds/seed_views.js | 15 ++++++++ server/src/database/seeds/seed_views_roles.js | 15 ++++++++ 18 files changed, 121 insertions(+), 45 deletions(-) rename server/src/database/seeds/{account_types.js => seed_account_types.js} (100%) rename server/src/database/seeds/{accounts.js => seed_accounts.js} (100%) rename server/src/database/seeds/{users.js => seed_users.js} (100%) create mode 100644 server/src/database/seeds/seed_views.js create mode 100644 server/src/database/seeds/seed_views_roles.js diff --git a/client/src/components/Accounts/AccountsDataTable.js b/client/src/components/Accounts/AccountsDataTable.js index 8b2c45559..2e9a60a00 100644 --- a/client/src/components/Accounts/AccountsDataTable.js +++ b/client/src/components/Accounts/AccountsDataTable.js @@ -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({ onInactiveAccount(account)} - /> + onClick={() => onInactiveAccount(account)} /> onDeleteAccount(account)} - /> + onClick={() => onDeleteAccount(account)} /> ); diff --git a/client/src/components/Accounts/AccountsViewsTabs.js b/client/src/components/Accounts/AccountsViewsTabs.js index ee0dd5570..7f489bd4e 100644 --- a/client/src/components/Accounts/AccountsViewsTabs.js +++ b/client/src/components/Accounts/AccountsViewsTabs.js @@ -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 = ( - {view.name} + {view.name} ); return ; }); @@ -52,4 +63,7 @@ function AccountsViewsTabs({ views }) { ); } -export default compose(AccountsConnect)(AccountsViewsTabs); +export default compose( + AccountsConnect, + DashboardConnect, +)(AccountsViewsTabs); diff --git a/client/src/components/Dashboard/DashboardTopbar.js b/client/src/components/Dashboard/DashboardTopbar.js index b26191566..f889b0a35 100644 --- a/client/src/components/Dashboard/DashboardTopbar.js +++ b/client/src/components/Dashboard/DashboardTopbar.js @@ -25,6 +25,14 @@ function DashboardTopbar({ const handlerClickEditView = () => { history.push(`/dashboard/custom_views/${editViewId}/edit`) } + + const maybleRenderPageSubtitle = pageSubtitle && (

{ pageSubtitle }

); + const maybeRenderEditViewBtn = (pageSubtitle && editViewId) && ( +