mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: add project ability.
This commit is contained in:
@@ -19,6 +19,7 @@ export const AbilitySubject = {
|
||||
SubscriptionBilling: 'SubscriptionBilling',
|
||||
CreditNote: 'CreditNote',
|
||||
VendorCredit: 'VendorCredit',
|
||||
Project:'Project'
|
||||
};
|
||||
|
||||
export const ItemAction = {
|
||||
@@ -73,7 +74,7 @@ export const CreditNoteAction = {
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
Refund: 'Refund'
|
||||
Refund: 'Refund',
|
||||
};
|
||||
|
||||
export const VendorCreditAction = {
|
||||
@@ -81,7 +82,7 @@ export const VendorCreditAction = {
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
Refund: 'Refund'
|
||||
Refund: 'Refund',
|
||||
};
|
||||
export const BillAction = {
|
||||
View: 'View',
|
||||
@@ -141,6 +142,13 @@ export const CashflowAction = {
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const ProjectAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const ReportsAction = {
|
||||
ALL: 'all',
|
||||
READ_BALANCE_SHEET: 'read-balance-sheet',
|
||||
|
||||
@@ -4,4 +4,5 @@ export const Features = {
|
||||
Warehouses: 'warehouses',
|
||||
Branches: 'branches',
|
||||
ManualJournal: 'manualJournal',
|
||||
Projects:'Projects'
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
ManualJournalAction,
|
||||
ExpenseAction,
|
||||
CashflowAction,
|
||||
ProjectAction,
|
||||
PreferencesAbility,
|
||||
SubscriptionBillingAbility,
|
||||
} from '@/constants/abilityOption';
|
||||
@@ -554,6 +555,10 @@ export const SidebarMenu = [
|
||||
text: 'Projects',
|
||||
href: '/projects',
|
||||
type: ISidebarMenuItemType.Link,
|
||||
permission: {
|
||||
subject: AbilitySubject.Project,
|
||||
ability: ProjectAction.View,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -565,6 +570,10 @@ export const SidebarMenu = [
|
||||
text: <T id={'projects.label.new_project'} />,
|
||||
type: ISidebarMenuItemType.Dialog,
|
||||
dialogName: 'project-form',
|
||||
permission: {
|
||||
subject: AbilitySubject.Project,
|
||||
ability: ProjectAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
text: <T id={'projects.label.new_time_entry'} />,
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from '@blueprintjs/core';
|
||||
import {
|
||||
Icon,
|
||||
Can,
|
||||
AdvancedFilterPopover,
|
||||
DashboardActionViewsList,
|
||||
DashboardFilterButton,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
FormattedMessage as T,
|
||||
DashboardActionsBar,
|
||||
} from '@/components';
|
||||
import { ProjectAction, AbilitySubject } from '@/constants/abilityOption';
|
||||
|
||||
import withProjects from './withProjects';
|
||||
import withProjectsActions from './withProjectsActions';
|
||||
@@ -75,12 +77,14 @@ function ProjectsActionsBar({
|
||||
onChange={handleTabChange}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="plus" />}
|
||||
text={<T id={'projects.label.new_project'} />}
|
||||
onClick={handleNewProjectBtnClick}
|
||||
/>
|
||||
<Can I={ProjectAction.Create} a={AbilitySubject.Project}>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="plus" />}
|
||||
text={<T id={'projects.label.new_project'} />}
|
||||
onClick={handleNewProjectBtnClick}
|
||||
/>
|
||||
</Can>
|
||||
{/* AdvancedFilterPopover */}
|
||||
|
||||
<Button
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Button, Intent } from '@blueprintjs/core';
|
||||
import { EmptyStatus, FormattedMessage as T } from '@/components';
|
||||
import { EmptyStatus, Can, FormattedMessage as T } from '@/components';
|
||||
import { ProjectAction, AbilitySubject } from '@/constants/abilityOption';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
@@ -24,16 +25,18 @@ function ProjectsEmptyStatus({
|
||||
}
|
||||
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>
|
||||
<Can I={ProjectAction.Create} a={AbilitySubject.Project}>
|
||||
<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>
|
||||
</Can>
|
||||
</React.Fragment>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -13,10 +13,12 @@ import {
|
||||
import {
|
||||
Icon,
|
||||
FormatDate,
|
||||
Can,
|
||||
Choose,
|
||||
If,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { ProjectAction, AbilitySubject } from '@/constants/abilityOption';
|
||||
import { safeCallback, firstLettersArgs, calculateStatus } from '@/utils';
|
||||
|
||||
/**
|
||||
@@ -81,37 +83,46 @@ export const ActionsMenu = ({
|
||||
text={intl.get('view_details')}
|
||||
onClick={safeCallback(onViewDetails, original)}
|
||||
/>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={intl.get('projects.action.edit_project')}
|
||||
onClick={safeCallback(onEdit, original)}
|
||||
/>
|
||||
<MenuItem
|
||||
icon={<Icon icon="plus" />}
|
||||
text={intl.get('projects.action.new_task')}
|
||||
onClick={safeCallback(onNewTask, original)}
|
||||
/>
|
||||
|
||||
<MenuItem text={'Status'} icon={<Icon icon="plus" />}>
|
||||
<If condition={original.status !== 'InProgress'}>
|
||||
<MenuItem
|
||||
text={'InProgress'}
|
||||
onClick={safeCallback(onStatus, original)}
|
||||
/>
|
||||
</If>
|
||||
<If condition={original.status !== 'Closed'}>
|
||||
<MenuItem text={'Closed'} onClick={safeCallback(onStatus, original)} />
|
||||
</If>
|
||||
</MenuItem>
|
||||
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('projects.action.delete_project')}
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
<Can I={ProjectAction.Edit} a={AbilitySubject.Project}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
icon={<Icon icon="pen-18" />}
|
||||
text={intl.get('projects.action.edit_project')}
|
||||
onClick={safeCallback(onEdit, original)}
|
||||
/>
|
||||
</Can>
|
||||
<Can I={ProjectAction.Create} a={AbilitySubject.Project}>
|
||||
<MenuItem
|
||||
icon={<Icon icon="plus" />}
|
||||
text={intl.get('projects.action.new_task')}
|
||||
onClick={safeCallback(onNewTask, original)}
|
||||
/>
|
||||
</Can>
|
||||
<Can I={ProjectAction.View} a={AbilitySubject.Project}>
|
||||
<MenuItem text={'Status'} icon={<Icon icon="plus" />}>
|
||||
<If condition={original.status !== 'InProgress'}>
|
||||
<MenuItem
|
||||
text={'InProgress'}
|
||||
onClick={safeCallback(onStatus, original)}
|
||||
/>
|
||||
</If>
|
||||
<If condition={original.status !== 'Closed'}>
|
||||
<MenuItem
|
||||
text={'Closed'}
|
||||
onClick={safeCallback(onStatus, original)}
|
||||
/>
|
||||
</If>
|
||||
</MenuItem>
|
||||
</Can>
|
||||
<Can I={ProjectAction.Delete} a={AbilitySubject.Project}>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
text={intl.get('projects.action.delete_project')}
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
</Can>
|
||||
</Menu>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user