Skip to content

Commit

Permalink
Added user profile link in sub-items list
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Dec 4, 2023
1 parent a2f154a commit 9bf5cc5
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/routing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/services/ui_config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
16 changes: 8 additions & 8 deletions src/bundle/Resources/public/js/scripts/widgets/flatpickr.js
Original file line number Diff line number Diff line change
@@ -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);
30 changes: 29 additions & 1 deletion src/bundle/ui-dev/src/modules/common/user-name/user.name.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<a href={profileUrl} className="c-user-name ibexa-user-name">
<span className="c-user-name__thumbnail ibexa-user-name__thumbnail">
<Thumbnail
thumbnailData={{ mimeType: thumbnail.mimeType, resource: thumbnail.uri }}
iconExtraClasses="ibexa-icon--small-medium"
/>
</span>
<span className="c-user-name__text ibexa-user-name__text">{name}</span>
</a>
);
}

const UserName = ({ name, thumbnail }) => {
return (
<div className="c-user-name ibexa-user-name">
<span className="c-user-name__thumbnail ibexa-user-name__thumbnail">
Expand All @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ export default class TableViewItemComponent extends PureComponent {

return (
<div className="c-table-view-item__text-wrapper">
<UserName name={this.getName(this.props.item.content._info.owner)} thumbnail={owner.thumbnail} />
<UserName
userId={owner.id}
name={this.getName(owner)}
thumbnail={owner.thumbnail}
contentType={owner.content._type.identifier}
/>
</div>
);
}
Expand All @@ -300,7 +305,12 @@ export default class TableViewItemComponent extends PureComponent {

return (
<div className="c-table-view-item__text-wrapper">
<UserName name={this.getName(creator)} thumbnail={creator.thumbnail} />
<UserName
userId={creator.id}
name={this.getName(creator)}
thumbnail={creator.thumbnail}
contentType={creator.content._type.identifier}
/>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
33 changes: 33 additions & 0 deletions src/lib/UI/Config/Provider/UserProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\UI\Config\Provider;

use Ibexa\AdminUi\UserProfile\UserProfileConfiguration;
use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface;

final class UserProfile implements ProviderInterface
{
private UserProfileConfiguration $configuration;

public function __construct(UserProfileConfiguration $configuration)
{
$this->configuration = $configuration;
}

/**
* @return array<string, mixed>
*/
public function getConfig(): array
{
return [
'enabled' => $this->configuration->isEnabled(),
'content_types' => $this->configuration->getContentTypes(),
];
}
}

0 comments on commit 9bf5cc5

Please sign in to comment.