Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8109: [ALW] folders management #1254

Merged
merged 7 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bundle/Resources/public/img/icons/about.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/bundle/Resources/public/img/icons/approved.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/bundle/Resources/public/img/icons/create.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/bundle/Resources/public/img/icons/notice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/bundle/Resources/public/img/icons/options.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ const getContentTypeName = (contentTypeIdentifier) => {
return contentTypesDataMap[contentTypeIdentifier].name;
};

const getContentTypeData = (contentTypeIdentifier) => {
if (!contentTypesDataMap) {
contentTypesDataMap = createContentTypeDataMap();
}

return contentTypesDataMap[contentTypeIdentifier] ?? null;
};

const getContentTypeIconUrlByHref = (contentTypeHref) => {
if (!contentTypesDataMapByHref) {
contentTypesDataMapByHref = createContentTypeDataMapByHref();
Expand Down Expand Up @@ -97,4 +105,12 @@ const getContentTypeDataByHref = (contentTypeHref) => {
return contentTypesDataMapByHref[contentTypeHref];
};

export { getContentTypeIconUrl, getContentTypeName, getContentTypeIconUrlByHref, getContentTypeDataByHref, getContentTypeNameByHref };
export {
createContentTypeDataMapByHref,
getContentTypeIconUrl,
getContentTypeName,
getContentTypeData,
getContentTypeIconUrlByHref,
getContentTypeDataByHref,
getContentTypeNameByHref,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { document: doc } = window;
import { getRootDOMElement } from './context.helper';

const NOTIFICATION_INFO_LABEL = 'info';
const NOTIFICATION_SUCCESS_LABEL = 'success';
Expand All @@ -16,9 +16,10 @@ const NOTIFICATION_ERROR_LABEL = 'error';
* @param {Object} detail.rawPlaceholdersMap
*/
const showNotification = (detail) => {
const rootDOMElement = getRootDOMElement();
const event = new CustomEvent('ibexa-notify', { detail });

doc.body.dispatchEvent(event);
rootDOMElement.dispatchEvent(event);
};

/**
Expand Down
11 changes: 11 additions & 0 deletions src/bundle/Resources/public/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ $ibexa-font-family:
sans-serif !default;
$ibexa-font-family-headings: 'Work Sans', sans-serif;

//Ibexa z-index
$ibexa-backdrop-zindex: 2175;
$ibexa-modal-zindex: 2180;
$ibexa-popover-zindex: 2185;

// boostrap variables
$white: $ibexa-color-white;
$gray-100: $ibexa-color-light-300;
Expand Down Expand Up @@ -319,6 +324,12 @@ $modal-content-border-radius: $ibexa-border-radius;
$modal-inner-padding: calculateRem(24px);
$modal-footer-padding: calculateRem(24px) 0;
$modal-footer-border-width: 0;
$zindex-modal-backdrop: $ibexa-backdrop-zindex;
$zindex-modal: $ibexa-modal-zindex;

//Popover
$zindex-popover: $ibexa-popover-zindex;

//Components
$border-radius: $ibexa-border-radius;

Expand Down
1 change: 1 addition & 0 deletions src/bundle/Resources/public/scss/mixins/_modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
cursor: pointer;
opacity: 1;
border: none;
background: transparent;

.ibexa-icon {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.m-ud {
position: fixed;
z-index: 99999;
z-index: 2100;
top: 0;
left: 0;
height: 100vh;
Expand Down
8 changes: 8 additions & 0 deletions src/bundle/ui-dev/src/modules/common/icon/inculdedIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import PropTypes from 'prop-types';

import About from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/about.svg';
import AboutInfo from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/about-info.svg';
import Approved from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/approved.svg';
import Article from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/article.svg';
import Back from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/back.svg';
import Blog from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/blog.svg';
import BlogPost from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/blog_post.svg';
import CaretDown from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/caret-down.svg';
import CaretUp from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/caret-up.svg';
import Create from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/create.svg';
import Checkmark from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/checkmark.svg';
import ContentTree from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/content-tree.svg';
import Date from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/date.svg';
Expand All @@ -21,6 +23,8 @@ import Form from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/form.svg
import Gallery from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/gallery.svg';
import Image from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/image.svg';
import LandingPage from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/landing_page.svg';
import Notice from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/notice.svg';
import Options from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/options.svg';
import Place from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/place.svg';
import Product from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/product.svg';
import Search from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/search.svg';
Expand All @@ -39,10 +43,12 @@ import Warning from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/warni
const iconsMap = {
about: About,
'about-info': AboutInfo,
approved: Approved,
article: Article,
back: Back,
blog: Blog,
blog_post: BlogPost,
create: Create,
'caret-down': CaretDown,
'caret-up': CaretUp,
checkmark: Checkmark,
Expand All @@ -57,6 +63,8 @@ const iconsMap = {
gallery: Gallery,
image: Image,
landing_page: LandingPage,
notice: Notice,
options: Options,
place: Place,
product: Product,
search: Search,
Expand Down
22 changes: 16 additions & 6 deletions src/bundle/ui-dev/src/modules/common/popup/popup.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
import Icon from '../icon/icon';

import { createCssClassNames } from '@ibexa-admin-ui/src/bundle/ui-dev/src/modules/common/helpers/css.class.names';
import { getTranslator, getBootstrap } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper';
import {
getTranslator,
getBootstrap,
getRootDOMElement,
} from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper';

const CLASS_NON_SCROLLABLE = 'ibexa-non-scrollable';
const CLASS_MODAL_OPEN = 'modal-open';
Expand Down Expand Up @@ -32,13 +36,14 @@ const Popup = ({
extraClasses,
showTooltip,
}) => {
const rootDOMElement = getRootDOMElement();
const modalRef = useRef(null);
const Translator = getTranslator();
const bootstrap = getBootstrap();

useEffect(() => {
document.body.classList.toggle(CLASS_MODAL_OPEN, isVisible);
document.body.classList.toggle(CLASS_NON_SCROLLABLE, isVisible);
rootDOMElement.classList.toggle(CLASS_MODAL_OPEN, isVisible);
rootDOMElement.classList.toggle(CLASS_NON_SCROLLABLE, isVisible);

if (isVisible) {
showPopup();
Expand All @@ -58,14 +63,19 @@ const Popup = ({
const closeBtnLabel = Translator.trans(/*@Desc("Close")*/ 'popup.close.label', {}, 'ibexa_universal_discovery_widget');
const hidePopup = () => {
bootstrap.Modal.getOrCreateInstance(modalRef.current).hide();
document.body.classList.remove(CLASS_MODAL_OPEN, CLASS_NON_SCROLLABLE);
rootDOMElement.classList.remove(CLASS_MODAL_OPEN, CLASS_NON_SCROLLABLE);
};
const showPopup = () => {
const bootstrapModal = bootstrap.Modal.getOrCreateInstance(modalRef.current, {
...MODAL_CONFIG,
keyboard: !noKeyboard,
focus: hasFocus,
});
const initializedBackdropRootElement = bootstrapModal._backdrop._config.rootElement;

if (initializedBackdropRootElement !== rootDOMElement) {
bootstrapModal._backdrop._config.rootElement = rootDOMElement;
}

bootstrapModal.show();
};
Expand Down Expand Up @@ -97,14 +107,14 @@ const Popup = ({
<div className={`modal-dialog c-popup__dialog ${MODAL_SIZE_CLASS[size]}`} role="dialog">
<div className="modal-content c-popup__content">
{noHeader
? renderCloseBtn
? renderCloseBtn()
: title && (
<div className="modal-header c-popup__header">
<h3 className="modal-title c-popup__headline" title={showTooltip ? title : null}>
<span className="c-popup__title">{title}</span>
{subtitle && <span className="c-popup__subtitle">{subtitle}</span>}
</h3>
{renderCloseBtn}
{renderCloseBtn()}
</div>
)}
<div className="modal-body c-popup__body">{children}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default class UploadPopupModule extends Component {
super(props);

this.refTooltip = React.createRef();
this.rootNode = getRootDOMElement();
this.rootDOMElement = getRootDOMElement();
}

componentDidMount() {
this.rootNode.classList.add(CLASS_SCROLL_DISABLED);
this.rootDOMElement.classList.add(CLASS_SCROLL_DISABLED);
parseTooltips(this.refTooltip.current);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
{},
Expand Down Expand Up @@ -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',
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 MINIMUM_ITEMS_COUNT_FOR_SEARCH_TO_APPEAR = 10;

Expand Down Expand Up @@ -63,7 +67,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -42,7 +47,7 @@ const ContentMetaPreview = () => {
parseTooltip(refContentMetaPreview.current);
});

if (!markedLocationId || markedLocationId === 1 || !locationData) {
if (!markedLocationId || markedLocationId === SYSTEM_ROOT_LOCATION_ID || !locationData) {
return null;
}

Expand Down
Loading
Loading