From db58d01258d05e1fba727663e727687c8ba6651e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Mon, 18 Mar 2024 11:48:17 +0100 Subject: [PATCH] moved to helpers --- .../components/breadcrumbs/breadcrumbs.helpers.js | 9 +++++++++ .../components/breadcrumbs/breadcrumbs.js | 9 ++------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.helpers.js diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.helpers.js b/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.helpers.js new file mode 100644 index 0000000000..6e4ddc66c7 --- /dev/null +++ b/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.helpers.js @@ -0,0 +1,9 @@ +export const getLoadedLocationsLimitedMap = (loadedLocationsFullMap, activeLocationId) => { + const itemIndex = loadedLocationsFullMap.findIndex(({ parentLocationId }) => parentLocationId === activeLocationId); + + if (itemIndex === -1) { + return []; + } + + return loadedLocationsFullMap.slice(0, itemIndex + 1); +}; diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.js b/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.js index 8091ca6cd2..8e89b6e312 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/components/breadcrumbs/breadcrumbs.js @@ -2,15 +2,10 @@ import React, { useContext, useState, useMemo, useEffect, useCallback } from 're import Icon from '../../../common/icon/icon'; +import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; import { createCssClassNames } from '../../../common/helpers/css.class.names'; +import { getLoadedLocationsLimitedMap } from './breadcrumbs.helpers'; import { LoadedLocationsMapContext, MarkedLocationIdContext, GridActiveLocationIdContext } from '../../universal.discovery.module'; -import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; - -const getLoadedLocationsLimitedMap = (loadedLocationsFullMap, activeLocationId) => { - const itemIndex = loadedLocationsFullMap.findIndex(({ parentLocationId }) => parentLocationId === activeLocationId); - - return loadedLocationsFullMap.slice(0, itemIndex + 1); -}; const Breadcrumbs = () => { const Translator = getTranslator();