chore(Sidebar): docs.

This commit is contained in:
a.bouhuolia
2022-04-23 00:23:46 +02:00
parent 5cbb3c84e6
commit 87758bf773
2 changed files with 14 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ SidebarMenuItem.ItemTypes = [
ISidebarMenuItemType.Overlay, ISidebarMenuItemType.Overlay,
ISidebarMenuItemType.Dialog, ISidebarMenuItemType.Dialog,
]; ];
/** /**
* Detarmines which sidebar menu item type should display. * Detarmines which sidebar menu item type should display.
* @returns {JSX.Element} * @returns {JSX.Element}

View File

@@ -53,10 +53,14 @@ export function getMainSidebarMenu() {
return R.compose(removeSidebarOverlayChildren)(SidebarMenu); return R.compose(removeSidebarOverlayChildren)(SidebarMenu);
} }
/**
* Predicates whether the sidebar item has feature ability.
*/
function useFilterSidebarItemFeaturePredicater() { function useFilterSidebarItemFeaturePredicater() {
const { featureCan } = useFeatureCan(); const { featureCan } = useFeatureCan();
return { return {
// Returns false if the item has `feature` prop and that feature has no ability.
predicate: (item) => { predicate: (item) => {
if (item.feature && !featureCan(item.feature)) { if (item.feature && !featureCan(item.feature)) {
return false; return false;
@@ -66,10 +70,14 @@ function useFilterSidebarItemFeaturePredicater() {
}; };
} }
/**
* Predicates whether the sidebar item has permissio ability.
*/
function useFilterSidebarItemAbilityPredicater() { function useFilterSidebarItemAbilityPredicater() {
const ability = useAbilityContext(); const ability = useAbilityContext();
return { return {
// Retruns false if the item has `permission` prop and that permission has no ability.
predicate: (item) => { predicate: (item) => {
if ( if (
item.permission && item.permission &&
@@ -114,7 +122,7 @@ function useFilterSidebarItemSubscriptionPredicater() {
/** /**
* Filters sidebar menu items based on ability of the item permission. * Filters sidebar menu items based on ability of the item permission.
* @param {*} menu * @param {} menu
* @returns {} * @returns {}
*/ */
function useFilterSidebarMenuAbility(menu) { function useFilterSidebarMenuAbility(menu) {
@@ -189,6 +197,9 @@ function useBindSidebarItemDialogClick() {
}; };
} }
/**
* Binds click action for the sidebar overlay item.
*/
function useBindSidebarItemOverlayClick() { function useBindSidebarItemOverlayClick() {
const { toggleSidebarSubmenu, closeSidebarSubmenu } = const { toggleSidebarSubmenu, closeSidebarSubmenu } =
useSidebarSubmnuActions(); useSidebarSubmnuActions();
@@ -209,9 +220,7 @@ function useBindSidebarItemOverlayClick() {
} }
/** /**
* * Binds click action of the given sidebar menu for each item based on item type.
* @param {} menu
* @returns {}
*/ */
function useBindSidebarItemClick(menu) { function useBindSidebarItemClick(menu) {
const { bindOnClick: bindLinkClickEvt } = useBindSidebarItemLinkClick(); const { bindOnClick: bindLinkClickEvt } = useBindSidebarItemLinkClick();