From 9bf5cc51e46b655cf06e58b185ca920a55d26516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 4 Dec 2023 08:05:59 +0100 Subject: [PATCH] Added user profile link in sub-items list --- src/bundle/Resources/config/routing.yaml | 2 +- .../config/services/ui_config/common.yaml | 4 +++ .../public/js/scripts/widgets/flatpickr.js | 16 ++++----- .../src/modules/common/user-name/user.name.js | 30 ++++++++++++++++- .../table-view/table.view.item.component.js | 14 ++++++-- .../sub-items/services/sub.items.service.js | 12 +++++++ src/lib/UI/Config/Provider/UserProfile.php | 33 +++++++++++++++++++ 7 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 src/lib/UI/Config/Provider/UserProfile.php diff --git a/src/bundle/Resources/config/routing.yaml b/src/bundle/Resources/config/routing.yaml index f78903efba..4ce446cd2d 100644 --- a/src/bundle/Resources/config/routing.yaml +++ b/src/bundle/Resources/config/routing.yaml @@ -681,7 +681,7 @@ ibexa.user.profile.view: controller: Ibexa\Bundle\AdminUi\Controller\User\ProfileController::viewAction methods: ['GET'] options: - exposed: true + expose: true ibexa.user.profile.edit: path: /user/profile/{userId}/edit diff --git a/src/bundle/Resources/config/services/ui_config/common.yaml b/src/bundle/Resources/config/services/ui_config/common.yaml index 06d8621f62..b7dd3d4d38 100644 --- a/src/bundle/Resources/config/services/ui_config/common.yaml +++ b/src/bundle/Resources/config/services/ui_config/common.yaml @@ -134,3 +134,7 @@ services: $resultLimit: '%ibexa.site_access.config.default.search.suggestion.result_limit%' tags: - { name: ibexa.admin_ui.config.provider, key: 'suggestions' } + + Ibexa\AdminUi\UI\Config\Provider\UserProfile: + tags: + - { name: ibexa.admin_ui.config.provider, key: 'userProfile' } diff --git a/src/bundle/Resources/public/js/scripts/widgets/flatpickr.js b/src/bundle/Resources/public/js/scripts/widgets/flatpickr.js index 333a02c805..22fafa7e85 100644 --- a/src/bundle/Resources/public/js/scripts/widgets/flatpickr.js +++ b/src/bundle/Resources/public/js/scripts/widgets/flatpickr.js @@ -1,8 +1,8 @@ -import flatpickrLanguages from '../../../../../../../../../../public/bundles/ibexaadminuiassets/vendors/flatpickr/dist/l10n'; - -(function (global, doc, ibexa, flatpickr) { - const { backOfficeLanguage } = ibexa.adminUiConfig; - const flatpickrLanguage = flatpickrLanguages[backOfficeLanguage] ?? flatpickrLanguages.default; - - flatpickr.localize(flatpickrLanguage); -})(window, window.document, window.ibexa, window.flatpickr); +// import flatpickrLanguages from '../../../../../../../../../../public/bundles/ibexaadminuiassets/vendors/flatpickr/dist/l10n'; +// +// (function (global, doc, ibexa, flatpickr) { +// const { backOfficeLanguage } = ibexa.adminUiConfig; +// const flatpickrLanguage = flatpickrLanguages[backOfficeLanguage] ?? flatpickrLanguages.default; +// +// flatpickr.localize(flatpickrLanguage); +// })(window, window.document, window.ibexa, window.flatpickr); diff --git a/src/bundle/ui-dev/src/modules/common/user-name/user.name.js b/src/bundle/ui-dev/src/modules/common/user-name/user.name.js index b2eb5452aa..d2add4450c 100644 --- a/src/bundle/ui-dev/src/modules/common/user-name/user.name.js +++ b/src/bundle/ui-dev/src/modules/common/user-name/user.name.js @@ -2,8 +2,34 @@ import React from 'react'; import PropTypes from 'prop-types'; import Thumbnail from '../thumbnail/thumbnail'; +const { Routing, ibexa } = window; + +const isUserProfileEnabled = (contentType) => { + const config = ibexa.adminUiConfig.userProfile; + if (config.enabled) { + return config.contentType.contains(contentType); + } + + return false; +}; + +const UserName = ({ userId, name, thumbnail, contentType }) => { + if (isUserProfileEnabled(contentType)) { + const profileUrl = Routing.generate('ibexa.user.profile.view', { userId: userId }); + + return ( + + + + + {name} + + ); + } -const UserName = ({ name, thumbnail }) => { return (
@@ -18,11 +44,13 @@ const UserName = ({ name, thumbnail }) => { }; UserName.propTypes = { + userId: PropTypes.string.isRequired, name: PropTypes.string.isRequired, thumbnail: PropTypes.shape({ mimeType: PropTypes.string.isRequired, uri: PropTypes.string.isRequired, }).isRequired, + contentType: PropTypes.string.isRequired, }; export default UserName; diff --git a/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js b/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js index 2bebedcc18..6c7ae2adc6 100644 --- a/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js +++ b/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js @@ -286,7 +286,12 @@ export default class TableViewItemComponent extends PureComponent { return (
- +
); } @@ -300,7 +305,12 @@ export default class TableViewItemComponent extends PureComponent { return (
- +
); } diff --git a/src/bundle/ui-dev/src/modules/sub-items/services/sub.items.service.js b/src/bundle/ui-dev/src/modules/sub-items/services/sub.items.service.js index ed2870528e..f5488c29da 100644 --- a/src/bundle/ui-dev/src/modules/sub-items/services/sub.items.service.js +++ b/src/bundle/ui-dev/src/modules/sub-items/services/sub.items.service.js @@ -67,22 +67,34 @@ export const loadLocation = ({ token, siteaccess }, { locationId = 2, limit = 10 remoteId mainLanguageCode owner { + id name thumbnail { uri alternativeText mimeType } + content { + _type { + identifier + } + } } currentVersion { versionNumber creator { + id name thumbnail { uri alternativeText mimeType } + content { + _type { + identifier + } + } } languageCodes } diff --git a/src/lib/UI/Config/Provider/UserProfile.php b/src/lib/UI/Config/Provider/UserProfile.php new file mode 100644 index 0000000000..760e98f9c4 --- /dev/null +++ b/src/lib/UI/Config/Provider/UserProfile.php @@ -0,0 +1,33 @@ +configuration = $configuration; + } + + /** + * @return array + */ + public function getConfig(): array + { + return [ + 'enabled' => $this->configuration->isEnabled(), + 'content_types' => $this->configuration->getContentTypes(), + ]; + } +}