-
Notifications
You must be signed in to change notification settings - Fork 2
NGSTACK-991 add better visibility info for content and its locations #8
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
Merged
pspanja
merged 18 commits into
1.6
from
NGSTACK-991-add-better-visibility-info-for-content-and-its-locations
Oct 24, 2025
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dc5e0c1
NGSTACK-991 add last modification date and user who did it to adminUI…
3a9ae4a
NGSTACK-991 add info about locations visibility to adminUI content fu…
8387fed
NGSTACK-991 update logic in 'VisibilityInfo' controller and add trans…
73608b0
NGSTACK-991 add 'Last modified' message to translation file and updat…
8405bc2
NGSTACK-991 update 'location_view' twig template to show full-width i…
8740dbc
NGSTACK-991 delete 'visibility_info' twig template since its not used…
b7f4bff
NGSTACK-991 update 'VisibilityInfo' with defining a route for it and …
d945d4f
NGSTACK-991 update 'location_view' twig template to wrap call to 'Vis…
45604da
NGSTACK-991 add JS script to dynamically load visibility info about l…
c69101f
NGSTACK-991 update logic in 'VisibilityInfo' controller for determini…
62b1764
NGSTACK-991 separate counting for locations hidden by ancestor and ex…
d556d34
NGSTACK-991 make the 'last modified info' be in one line and remove p…
5724026
NGSTACK-991 change the functionality of the label below the location'…
78e39ad
NGSTACK-991 make be array and collect all messages and implode them …
1afe8f0
NGSTACK-991 add svg icon to label below location visibility toggle
62b873f
NGSTACK-991 inject IconPathResolverInterface into VisibilityInfo cont…
8be8329
NGSTACK-991 rename variable 'extraContent' to 'extraLines' and refact…
875436f
NGSTACK-991 always show tooltip for some location if its parent is in…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Netgen\Bundle\IbexaAdminUIExtraBundle\Controller\Content; | ||
|
|
||
| use Ibexa\Contracts\AdminUi\Controller\Controller; | ||
| use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class LastModifiedInfo extends Controller | ||
| { | ||
| public function __invoke(Content $content): Response | ||
| { | ||
| $lastContributor = $content->getVersionInfo()->getCreator(); | ||
|
|
||
| return $this->render( | ||
| '@NetgenIbexaAdminUIExtra/themes/ngadmin/ui/last_modified_info.html.twig', | ||
| [ | ||
| 'last_contributor_name' => $lastContributor->getName(), | ||
| 'content_info' => $content->getContentInfo(), | ||
| ], | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Netgen\Bundle\IbexaAdminUIExtraBundle\Controller\Content; | ||
|
|
||
| use Ibexa\Contracts\AdminUi\Controller\Controller; | ||
| use Ibexa\Contracts\Core\Repository\ContentService; | ||
| use Ibexa\Contracts\Core\Repository\Exceptions\BadStateException; | ||
| use Ibexa\Contracts\Core\Repository\LocationService; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
|
||
| use function implode; | ||
|
|
||
| class VisibilityInfo extends Controller | ||
| { | ||
| public function __construct( | ||
| private readonly LocationService $locationService, | ||
| private readonly TranslatorInterface $translator, | ||
| private readonly ContentService $contentService, | ||
| ) {} | ||
|
|
||
| public function __invoke(int $contentId, Request $request): Response | ||
| { | ||
| $iconPath = $request->attributes->get('iconPath') ?? $request->query->get('iconPath'); | ||
|
|
||
| $content = $this->contentService->loadContent($contentId); | ||
|
|
||
| $extraContent = []; | ||
| if ($content->getContentInfo()->isHidden() === true) { | ||
| $extraContent[] = $this->translator->trans('content.visibility.content_hidden', [], 'locationview'); | ||
| } | ||
|
|
||
| try { | ||
| $locations = $this->locationService->loadLocations($content->getContentInfo()); | ||
|
|
||
| $explicitlyHiddenLocations = 0; | ||
| $hiddenByAncestorLocations = 0; | ||
| foreach ($locations as $location) { | ||
| if ($location->explicitlyHidden) { | ||
| $explicitlyHiddenLocations++; | ||
| } | ||
|
|
||
| if ($location->isInvisible() && $location->getParentLocation()?->isInvisible()) { | ||
| $hiddenByAncestorLocations++; | ||
| } | ||
| } | ||
|
|
||
| $explicitlyHiddenLocationsMessage = ''; | ||
pspanja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| $hiddenByAncestorLocationsMessage = ''; | ||
| if (count($locations) === 1) { | ||
| if ($explicitlyHiddenLocations !== 0) { | ||
| $explicitlyHiddenLocationsMessage = $this->translator->trans('content.visibility.location_hidden', [], 'locationview'); | ||
| } | ||
|
|
||
| if ($hiddenByAncestorLocations !== 0) { | ||
| $hiddenByAncestorLocationsMessage = $this->translator->trans('content.visibility.location_hidden_by_ancestor', [], 'locationview'); | ||
| } | ||
| } else { | ||
| if ($explicitlyHiddenLocations !== 0) { | ||
| $explicitlyHiddenLocationsMessage = $this->translator->trans( | ||
| 'content.visibility.locations_hidden', | ||
| [ | ||
| '%hidden%' => $explicitlyHiddenLocations, | ||
| '%total%' => count($locations), | ||
| ], | ||
| 'locationview', | ||
| ); | ||
| } | ||
|
|
||
| if ($hiddenByAncestorLocations !== 0) { | ||
| $hiddenByAncestorLocationsMessage = $this->translator->trans( | ||
| 'content.visibility.locations_hidden_by_ancestor', | ||
| [ | ||
| '%hidden%' => $hiddenByAncestorLocations, | ||
| '%total%' => count($locations), | ||
| ], | ||
| 'locationview', | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if ($explicitlyHiddenLocationsMessage !== '') { | ||
| $extraContent[] = $explicitlyHiddenLocationsMessage; | ||
| } | ||
|
|
||
| if ($hiddenByAncestorLocationsMessage !== '') { | ||
| $extraContent[] = $hiddenByAncestorLocationsMessage; | ||
| } | ||
| } catch (BadStateException $e) { | ||
| $extraContent[] = $this->translator->trans('content.visibility.cannot_fetch_locations', [], 'locationview'); | ||
| } | ||
|
|
||
| if ($extraContent === []) { | ||
| return new Response('', Response::HTTP_NO_CONTENT); | ||
| } | ||
|
|
||
| return $this->render('@IbexaAdminUi/themes/admin/ui/component/alert/alert.html.twig', | ||
| [ | ||
| 'type' => 'info', | ||
| 'title' => $this->translator->trans('content.visibility.info', [], 'locationview'), | ||
| 'extra_content' => implode('<br>', $extraContent), | ||
| 'icon_path' => $iconPath, | ||
| 'class' => 'mt-4', | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
bundle/Resources/public/js/scripts/admin.content.location.visibility_info.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| (function (global, doc, ibexa) { | ||
| "use strict"; | ||
| const SELECTOR_VISIBILITY_ALERT_WRAPPER = '#ng-visibility-alert'; | ||
| const handleRefreshError = () => {} | ||
| const handleRefreshResponse = (response) => { | ||
| if (response.status === 204) { | ||
| return { isEmpty: true }; | ||
| } | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(response.statusText); | ||
| } | ||
|
|
||
| return response.text().then((html) => ({ isEmpty: false, html })); | ||
| }; | ||
| const updateAlertContent = (wrapper, { isEmpty, html }) => { | ||
| wrapper.innerHTML = isEmpty ? '' : html; | ||
| }; | ||
| const refreshAlert = (wrapper, url) => { | ||
| const request = new Request(url, { | ||
| method: 'GET', | ||
| credentials: 'same-origin', | ||
| headers: { 'X-Requested-With': 'XMLHttpRequest' }, | ||
| }); | ||
|
|
||
| fetch(request) | ||
| .then(handleRefreshResponse) | ||
| .then(updateAlertContent.bind(null, wrapper)) | ||
| .catch(handleRefreshError); | ||
| }; | ||
| const onReady = () => { | ||
| const wrapper = doc.querySelector(SELECTOR_VISIBILITY_ALERT_WRAPPER); | ||
| if (!wrapper) { | ||
| return; | ||
| } | ||
|
|
||
| const url = wrapper.dataset.url; | ||
| if (!url) { | ||
| return; | ||
| } | ||
|
|
||
| doc.body.addEventListener( | ||
| 'ibexa-content-tree-refresh', | ||
| refreshAlert.bind(null, wrapper, url), | ||
| false | ||
| ); | ||
| }; | ||
|
|
||
| if (doc.readyState === 'loading') { | ||
| doc.addEventListener('DOMContentLoaded', onReady); | ||
| } else { | ||
| onReady(); | ||
| } | ||
| })(window, window.document, window.ibexa); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.