mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge branch 'featrue/roles-permission' of https://github.com/bigcapitalhq/client into featrue/roles-permission
This commit is contained in:
@@ -115,6 +115,7 @@ export const Cashflow_Abilities = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Report_Abilities = {
|
export const Report_Abilities = {
|
||||||
|
ALL:'all',
|
||||||
READ_BALANCE_SHEET: 'read-balance-sheet',
|
READ_BALANCE_SHEET: 'read-balance-sheet',
|
||||||
READ_TRIAL_BALANCE_SHEET: 'read-trial-balance-sheet',
|
READ_TRIAL_BALANCE_SHEET: 'read-trial-balance-sheet',
|
||||||
READ_PROFIT_LOSS: 'read-profit-loss',
|
READ_PROFIT_LOSS: 'read-profit-loss',
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
Manual_Journal_Abilities,
|
Manual_Journal_Abilities,
|
||||||
Expense_Abilities,
|
Expense_Abilities,
|
||||||
Item_Abilities,
|
Item_Abilities,
|
||||||
|
Report_Abilities,
|
||||||
} from '../common/abilityOption';
|
} from '../common/abilityOption';
|
||||||
|
|
||||||
export const accountsReceivable = [
|
export const accountsReceivable = [
|
||||||
@@ -135,6 +136,8 @@ export const financialAccounting = [
|
|||||||
<T id={'show_financial_reports_about_your_organization'} />
|
<T id={'show_financial_reports_about_your_organization'} />
|
||||||
),
|
),
|
||||||
link: '/financial-reports',
|
link: '/financial-reports',
|
||||||
|
subject: AbilitySubject.Report,
|
||||||
|
ability: Report_Abilities.ALL,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import { useAbilityContext } from '../../hooks';
|
import { useAbilityContext } from '../../hooks';
|
||||||
|
|
||||||
function useFilterFinancialReports(financial) {
|
function useFilterFinancialReports(financialSection) {
|
||||||
const ability = useAbilityContext();
|
const ability = useAbilityContext();
|
||||||
|
|
||||||
const seaction = financial
|
const section = financialSection
|
||||||
.map((seaction) => {
|
.map((section) => {
|
||||||
const reports = seaction.reports.filter((report) => {
|
const reports = section.reports.filter((report) => {
|
||||||
return ability.can(report.ability, report.subject);
|
return ability.can(report.ability, report.subject);
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sectionTitle: seaction.sectionTitle,
|
sectionTitle: section.sectionTitle,
|
||||||
reports,
|
reports,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(({ reports }) => !isEmpty(reports));
|
.filter(({ reports }) => !isEmpty(reports));
|
||||||
|
|
||||||
return seaction;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useFilterFinancialReports;
|
export default useFilterFinancialReports;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
|
|||||||
import { For } from 'components';
|
import { For } from 'components';
|
||||||
|
|
||||||
import 'style/pages/FinancialStatements/FinancialSheets.scss';
|
import 'style/pages/FinancialStatements/FinancialSheets.scss';
|
||||||
|
import { useFilterShortcutBoxesSection } from './components';
|
||||||
|
|
||||||
function ShortcutBox({ title, link, description }) {
|
function ShortcutBox({ title, link, description }) {
|
||||||
return (
|
return (
|
||||||
@@ -27,5 +28,6 @@ function ShortcutBoxes({ sectionTitle, shortcuts }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ShortcutBoxesSection({ section }) {
|
export default function ShortcutBoxesSection({ section }) {
|
||||||
return <For render={ShortcutBoxes} of={section} />;
|
const BoxSection = useFilterShortcutBoxesSection(section);
|
||||||
|
return <For render={ShortcutBoxes} of={BoxSection} />;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/containers/Homepage/components.js
Normal file
18
src/containers/Homepage/components.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { isEmpty } from 'lodash';
|
||||||
|
import { useAbilityContext } from '../../hooks';
|
||||||
|
|
||||||
|
export const useFilterShortcutBoxesSection = (section) => {
|
||||||
|
const ability = useAbilityContext();
|
||||||
|
|
||||||
|
return section
|
||||||
|
.map(({ sectionTitle, shortcuts }) => {
|
||||||
|
const shortcut = shortcuts.filter((shortcuts) => {
|
||||||
|
return ability.can(shortcuts.ability, shortcuts.subject);
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
sectionTitle: sectionTitle,
|
||||||
|
shortcuts: shortcut,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(({ shortcuts }) => !isEmpty(shortcuts));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user