diff --git a/src/bundle/Resources/public/js/scripts/helpers/context.helper.js b/src/bundle/Resources/public/js/scripts/helpers/context.helper.js index 66166aab15..736f0cf298 100644 --- a/src/bundle/Resources/public/js/scripts/helpers/context.helper.js +++ b/src/bundle/Resources/public/js/scripts/helpers/context.helper.js @@ -8,6 +8,10 @@ const restInfo = { siteaccess: document.querySelector('meta[name="SiteAccess"]')?.content, }; +export const SYSTEM_ROOT_LOCATION_ID = 1; +export const SYSTEM_ROOT_LOCATION_PATH = `/${SYSTEM_ROOT_LOCATION_ID}/`; +export const SYSTEM_ROOT_LOCATION = { pathString: SYSTEM_ROOT_LOCATION_PATH }; + export const setRestInfo = ({ instanceUrl, accessToken, token, siteaccess }) => { restInfo.instanceUrl = instanceUrl ?? restInfo.instanceUrl; restInfo.accessToken = accessToken ?? restInfo.accessToken; diff --git a/src/bundle/ui-dev/src/modules/content-tree/components/list-item/list.item.component.js b/src/bundle/ui-dev/src/modules/content-tree/components/list-item/list.item.component.js index 1061141f49..341bb2f5ae 100644 --- a/src/bundle/ui-dev/src/modules/content-tree/components/list-item/list.item.component.js +++ b/src/bundle/ui-dev/src/modules/content-tree/components/list-item/list.item.component.js @@ -4,7 +4,11 @@ import Icon from '../../../common/icon/icon'; import { showWarningNotification } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/notification.helper'; import { getContentTypeIconUrl } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/content.type.helper'; -import { getTranslator, getAdminUiConfig } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; +import { + getTranslator, + getAdminUiConfig, + SYSTEM_ROOT_LOCATION_ID, +} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; class ListItem extends Component { constructor(props) { @@ -124,7 +128,7 @@ class ListItem extends Component { }; if (!this.state.isLoading || this.props.subitems.length) { - if (locationId === 1) { + if (locationId === SYSTEM_ROOT_LOCATION_ID) { iconAttrs.customPath = getContentTypeIconUrl('folder'); } else { iconAttrs.customPath = getContentTypeIconUrl(contentTypeIdentifier) || getContentTypeIconUrl('file'); @@ -184,7 +188,7 @@ class ListItem extends Component { renderItemLabel() { const { href, name, locationId, indent, onClick } = this.props; - if (locationId === 1) { + if (locationId === SYSTEM_ROOT_LOCATION_ID) { return null; } 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 ba3bd7475a..8b6b767630 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,7 +2,7 @@ import React, { useContext, useState, useMemo, useEffect, useCallback, useRef } import Icon from '../../../common/icon/icon'; -import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; +import { getTranslator, SYSTEM_ROOT_LOCATION_ID } 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'; @@ -69,7 +69,7 @@ const Breadcrumbs = () => { {hiddenItems.map((item) => { const locationId = item.parentLocationId; const locationName = - locationId === 1 + locationId === SYSTEM_ROOT_LOCATION_ID ? Translator.trans( /*@Desc("Root Location")*/ 'breadcrumbs.root_location', {}, @@ -124,7 +124,7 @@ const Breadcrumbs = () => { {visibleItems.map((item, index) => { const locationId = item.parentLocationId; const locationName = - locationId === 1 + locationId === SYSTEM_ROOT_LOCATION_ID ? Translator.trans( /*@Desc("Root Location")*/ 'breadcrumbs.root_location', {}, diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-widget/content.create.widget.js b/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-widget/content.create.widget.js index 6aedf2dcf3..56b6437527 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-widget/content.create.widget.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/components/content-create-widget/content.create.widget.js @@ -17,7 +17,11 @@ import { } from '../../universal.discovery.module'; import { parse as parseTooltip } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper'; -import { getAdminUiConfig, getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; +import { + getAdminUiConfig, + getTranslator, + SYSTEM_ROOT_LOCATION_ID, +} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; const ContentCreateWidget = () => { const Translator = getTranslator(); @@ -61,7 +65,7 @@ const ContentCreateWidget = () => { setFilterQuery(query); }; const updateSelectedLanguage = (value) => setSelectedLanguage(value); - const isConfirmDisabled = !selectedContentType || !selectedLanguage || markedLocationId === 1; + const isConfirmDisabled = !selectedContentType || !selectedLanguage || markedLocationId === SYSTEM_ROOT_LOCATION_ID; const createContent = () => { setContentOnTheFlyData({ locationId: markedLocationId, diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/content.meta.preview.module.js b/src/bundle/ui-dev/src/modules/universal-discovery/content.meta.preview.module.js index e9242e944d..d7ee80c8d0 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/content.meta.preview.module.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/content.meta.preview.module.js @@ -16,7 +16,12 @@ import { import { formatShortDateTime } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/timezone.helper'; import { parse as parseTooltip } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper'; -import { getTranslator, getRouting, getAdminUiConfig } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; +import { + getTranslator, + getRouting, + getAdminUiConfig, + SYSTEM_ROOT_LOCATION_ID, +} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; const ContentMetaPreview = () => { const Translator = getTranslator(); @@ -42,7 +47,7 @@ const ContentMetaPreview = () => { parseTooltip(refContentMetaPreview.current); }); - if (!markedLocationId || markedLocationId === 1 || !locationData) { + if (!markedLocationId || markedLocationId === SYSTEM_ROOT_LOCATION_ID || !locationData) { return null; } diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js index 9a8741982f..f2a5bd63e4 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js @@ -18,7 +18,11 @@ import { parse as parseTooltips, hideAll as hideAllTooltips, } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper'; -import { getAdminUiConfig, getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; +import { + getAdminUiConfig, + getTranslator, + SYSTEM_ROOT_LOCATION_ID, +} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; const { document } = window; @@ -409,7 +413,11 @@ const UniversalDiscoveryModule = (props) => { }, [currentView]); useEffect(() => { - if (!props.startingLocationId || props.startingLocationId === 1 || props.startingLocationId === props.rootLocationId) { + if ( + !props.startingLocationId || + props.startingLocationId === SYSTEM_ROOT_LOCATION_ID || + props.startingLocationId === props.rootLocationId + ) { return; }