feat: add empty status & fix edit project.

This commit is contained in:
elforjani13
2022-07-15 20:46:04 +02:00
parent 709e06a646
commit 50c905eabb
6 changed files with 57 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import React from 'react';
import moment from 'moment'; import moment from 'moment';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { Formik } from 'formik'; import { Formik } from 'formik';
import { Intent } from '@blueprintjs/core';
import { AppToaster } from 'components'; import { AppToaster } from 'components';
import ProjectFormContent from './ProjectFormContent'; import ProjectFormContent from './ProjectFormContent';
import { CreateProjectFormSchema } from './ProjectForm.schema'; import { CreateProjectFormSchema } from './ProjectForm.schema';

View File

@@ -65,6 +65,7 @@ function ProjectFormFields() {
<FFormGroup <FFormGroup
label={intl.get('projects.dialog.project_name')} label={intl.get('projects.dialog.project_name')}
name={'name'} name={'name'}
labelInfo={<FieldRequiredHint />}
> >
<FInputGroup name="name" /> <FInputGroup name="name" />
</FFormGroup> </FFormGroup>
@@ -96,6 +97,7 @@ function ProjectFormFields() {
<FFormGroup <FFormGroup
name={'cost_estimate'} name={'cost_estimate'}
label={intl.get('projects.dialog.cost_estimate')} label={intl.get('projects.dialog.cost_estimate')}
labelInfo={<FieldRequiredHint />}
> >
<ControlGroup> <ControlGroup>
<InputPrependText text={'USD'} /> <InputPrependText text={'USD'} />

View File

@@ -6,6 +6,7 @@ import { DataTable } from 'components';
import { TABLES } from 'common/tables'; import { TABLES } from 'common/tables';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows'; import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton'; import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import ProjectsEmptyStatus from './ProjectsEmptyStatus';
import { useProjectsListContext } from './ProjectsListProvider'; import { useProjectsListContext } from './ProjectsListProvider';
import { useMemorizedColumnsWidths } from 'hooks'; import { useMemorizedColumnsWidths } from 'hooks';
import { useProjectsListColumns, ActionsMenu } from './components'; import { useProjectsListColumns, ActionsMenu } from './components';
@@ -76,6 +77,11 @@ function ProjectsDataTable({
}); });
}; };
// Display project empty status instead of the table.
if (isEmptyStatus) {
return <ProjectsEmptyStatus />;
}
return ( return (
<ProjectsTable <ProjectsTable
columns={columns} columns={columns}
@@ -97,7 +103,7 @@ function ProjectsDataTable({
payload={{ payload={{
onViewDetails: handleViewDetailProject, onViewDetails: handleViewDetailProject,
onEdit: handleEditProject, onEdit: handleEditProject,
onDelete:handleDeleteProject, onDelete: handleDeleteProject,
onNewTask: handleNewTaskButtonClick, onNewTask: handleNewTaskButtonClick,
}} }}
/> />

View File

@@ -0,0 +1,43 @@
import React from 'react';
import { Button, Intent } from '@blueprintjs/core';
import { EmptyStatus, FormattedMessage as T } from 'components';
import withDialogActions from 'containers/Dialog/withDialogActions';
import { compose } from 'utils';
function ProjectsEmptyStatus({
// #withDialogActions
openDialog,
}) {
// Handle new project button click.
const handleNewProjectClick = () => {
openDialog('project-form', {});
};
return (
<EmptyStatus
title={<T id="projects.empty_status.title" />}
description={
<p>
<T id="projects.empty_status.description" />
</p>
}
action={
<React.Fragment>
<Button
intent={Intent.PRIMARY}
large={true}
onClick={handleNewProjectClick}
>
<T id="projects.empty_status.action" />
</Button>
<Button intent={Intent.NONE} large={true}>
<T id={'learn_more'} />
</Button>
</React.Fragment>
}
/>
);
}
export default compose(withDialogActions)(ProjectsEmptyStatus);

View File

@@ -84,7 +84,7 @@ export function useProject(projectId, props, requestProps) {
[t.PROJECT, projectId], [t.PROJECT, projectId],
{ method: 'get', url: `projects/${projectId}`, ...requestProps }, { method: 'get', url: `projects/${projectId}`, ...requestProps },
{ {
select: (res) => res.data.projects, select: (res) => res.data.project,
defaultData: {}, defaultData: {},
...props, ...props,
}, },

View File

@@ -2061,6 +2061,9 @@
"projects.dialog.edit_success_message": "The project has been edited successfully.", "projects.dialog.edit_success_message": "The project has been edited successfully.",
"projects.alert.delete_message": "The deleted project has been deleted successfully.", "projects.alert.delete_message": "The deleted project has been deleted successfully.",
"projects.alert.once_delete_this_project": "Once you delete this project, you won't be able to restore it later. Are you sure you want to delete this project?", "projects.alert.once_delete_this_project": "Once you delete this project, you won't be able to restore it later. Are you sure you want to delete this project?",
"projects.empty_status.title":"",
"projects.empty_status.description":"",
"projects.empty_status.action":"New Project",
"project_task.dialog.new_task": "New Task", "project_task.dialog.new_task": "New Task",
"project_task.dialog.task_name": "Task Name", "project_task.dialog.task_name": "Task Name",
"project_task.dialog.estimated_hours": "Estimate Hours", "project_task.dialog.estimated_hours": "Estimate Hours",