feat: add projects view tabs.

This commit is contained in:
elforjani13
2022-06-12 09:43:19 +02:00
parent a44f548ff9
commit 4eac2239b1
4 changed files with 29 additions and 10 deletions

View File

@@ -54,6 +54,13 @@ function ProjectsDataTable({
// Handle cell click. // Handle cell click.
const handleCellClick = (cell, event) => {}; const handleCellClick = (cell, event) => {};
// Handle edit project.
const handleEditProject = (project) => {
openDialog('project-form', {
projectId: project.id,
});
};
// Handle new task button click. // Handle new task button click.
const handleNewTaskButtonClick = () => { const handleNewTaskButtonClick = () => {
openDialog('task-form'); openDialog('task-form');
@@ -82,6 +89,7 @@ function ProjectsDataTable({
onColumnResizing={handleColumnResizing} onColumnResizing={handleColumnResizing}
size={projectsTableSize} size={projectsTableSize}
payload={{ payload={{
onEdit: handleEditProject,
onNewTask: handleNewTaskButtonClick, onNewTask: handleNewTaskButtonClick,
}} }}
/> />

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { DashboardPageContent, DashboardContentTable } from 'components'; import { DashboardPageContent, DashboardContentTable } from 'components';
import ProjectsActionsBar from './ProjectsActionsBar'; import ProjectsActionsBar from './ProjectsActionsBar';
// import ProjectsViewTabs from './ProjectsViewTabs'; import ProjectsViewTabs from './ProjectsViewTabs';
import ProjectsDataTable from './ProjectsDataTable'; import ProjectsDataTable from './ProjectsDataTable';
import withProjects from './withProjects'; import withProjects from './withProjects';
@@ -38,7 +38,7 @@ function ProjectsList({
> >
<ProjectsActionsBar /> <ProjectsActionsBar />
<DashboardPageContent> <DashboardPageContent>
{/* <ProjectsViewTabs /> */} <ProjectsViewTabs />
<DashboardContentTable> <DashboardContentTable>
<ProjectsDataTable /> <ProjectsDataTable />
</DashboardContentTable> </DashboardContentTable>

View File

@@ -1,21 +1,27 @@
//@ts-nocheck
import React from 'react'; import React from 'react';
import { useResourceViews, useResourceMeta } from 'hooks/query';
import DashboardInsider from '../../../components/Dashboard/DashboardInsider'; import DashboardInsider from '../../../components/Dashboard/DashboardInsider';
const ProjectsListContext = React.createContext();
const ProjectsListContext = React.createContext({});
/** /**
* Projects list data provider. * Projects list data provider.
* @returns * @returns
*/ */
function ProjectsListProvider({ query, tableStateChanged, ...props }) { function ProjectsListProvider({ query, tableStateChanged, ...props }) {
// provider payload. // Fetch accounts resource views and fields.
const { data: projectsViews, isLoading: isViewsLoading } =
useResourceViews('projects');
const provider = {}; // provider payload.
const provider = {
projectsViews,
};
return ( return (
<DashboardInsider <DashboardInsider
// loading={} // loading={isViewsLoading}
name={'projects'} name={'projects'}
> >
<ProjectsListContext.Provider value={provider} {...props} /> <ProjectsListContext.Provider value={provider} {...props} />

View File

@@ -1,3 +1,4 @@
//@ts-nocheck
import React from 'react'; import React from 'react';
import { Alignment, Navbar, NavbarGroup } from '@blueprintjs/core'; import { Alignment, Navbar, NavbarGroup } from '@blueprintjs/core';
@@ -5,6 +6,7 @@ import { DashboardViewsTabs } from 'components';
import withProjects from './withProjects'; import withProjects from './withProjects';
import withProjectsActions from './withProjectsActions'; import withProjectsActions from './withProjectsActions';
import { useProjectsListContext } from './ProjectsListProvider';
import { compose, transfromViewsToTabs } from 'utils'; import { compose, transfromViewsToTabs } from 'utils';
@@ -19,8 +21,11 @@ function ProjectsViewTabs({
// #withProjectsActions // #withProjectsActions
setProjectsTableState, setProjectsTableState,
}) { }) {
// Projects list context.
const { projectsViews } = useProjectsListContext();
// Projects views. // Projects views.
const tabs = transfromViewsToTabs([]); const tabs = transfromViewsToTabs(projectsViews);
// Handle tab change. // Handle tab change.
const handleTabsChange = (viewSlug) => { const handleTabsChange = (viewSlug) => {
@@ -32,7 +37,7 @@ function ProjectsViewTabs({
<NavbarGroup align={Alignment.LEFT}> <NavbarGroup align={Alignment.LEFT}>
<DashboardViewsTabs <DashboardViewsTabs
currentViewSlug={projectsCurrentView} currentViewSlug={projectsCurrentView}
resourceName={''} resourceName={'projects'}
tabs={tabs} tabs={tabs}
onChange={handleTabsChange} onChange={handleTabsChange}
/> />
@@ -46,4 +51,4 @@ export default compose(
projectsCurrentView: projectsTableState?.viewSlug, projectsCurrentView: projectsTableState?.viewSlug,
})), })),
withProjectsActions, withProjectsActions,
)(); )(ProjectsViewTabs);