Skip to content
Open
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/Controller/LocationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function swapAction(Request $request): Response
$currentLocation = $data->getCurrentLocation();
$newLocation = $data->getNewLocation();

$childCount = $this->locationService->getLocationChildCount($currentLocation);
$childCount = $this->locationService->getLocationChildCount($currentLocation, 1);
$contentType = $newLocation->getContent()->getContentType();

if (!$contentType->isContainer && $childCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void
->end()
->end()
->end()
->arrayNode('query_subtree')
->children()
->integerNode('limit')
->info('Limit the total count of items queried for when calculating the the number of direct children a node has. -1 for no limit. Default is 500 for performance reasons.')
->defaultValue(500)
->isRequired()
->end()
->end()
->end()
->end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ parameters:

# Subtree Operations
ibexa.site_access.config.admin_group.subtree_operations.copy_subtree.limit: 100
ibexa.site_access.config.admin_group.subtree_operations.query_subtree.limit: 500

# Notifications
ibexa.site_access.config.admin_group.notification_count.interval: 30000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}]) %}

{% set body_row_cols = body_row_cols|merge([
{ content: location.childCount },
{ content: (location.childCount > sub_item_query_limit) ? (location.childCount -1) ~ '+' : location.childCount },
]) %}

{% set body_rows = body_rows|merge([{ cols: body_row_cols }]) %}
Expand Down
16 changes: 13 additions & 3 deletions src/lib/Form/TrashLocationOptionProvider/HasChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Ibexa\AdminUi\Specification\Location\HasChildren as HasChildrenSpec;
use Ibexa\Contracts\Core\Repository\LocationService;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -23,10 +24,14 @@ final class HasChildren implements TrashLocationOptionProvider
/** @var \Symfony\Contracts\Translation\TranslatorInterface */
private $translator;

public function __construct(LocationService $locationService, TranslatorInterface $translator)
/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
private $configResolver;

public function __construct(LocationService $locationService, TranslatorInterface $translator, ConfigResolverInterface $configResolver)
{
$this->locationService = $locationService;
$this->translator = $translator;
$this->configResolver = $configResolver;
}

public function supports(Location $location): bool
Expand All @@ -36,10 +41,15 @@ public function supports(Location $location): bool

public function addOptions(FormInterface $form, Location $location): void
{
$childCount = $this->locationService->getLocationChildCount($location);
$limit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');

$useLimit = $limit > 0;
$childCount = $this->locationService->getLocationChildCount($location, $useLimit ? $limit + 1 : null);

$translatorParameters = [
'%children_count%' => $childCount,
'%children_count%' => ($useLimit && $childCount >= $limit) ?
sprintf('%d+', $limit) :
$childCount,
'%content%' => $location->getContent()->getName(),
];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Specification/Location/HasChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(LocationService $locationService)
*/
public function isSatisfiedBy($item): bool
{
$childCount = $this->locationService->getLocationChildCount($item);
$childCount = $this->locationService->getLocationChildCount($item, 1);

return 0 < $childCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function isSatisfiedBy($item): bool
return false;
}

return $this->copyLimit >= $this->locationService->getSubtreeSize($item);
return $this->copyLimit >= $this->locationService->getSubtreeSize($item, $this->copyLimit + 1);
}

private function isContainer(Location $location): bool
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Tab/LocationView/LocationsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,18 @@ public function getTemplateParameters(array $contextParameters = []): array
);
}

$subItemQueryLimit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');
if ($subItemQueryLimit <= 0) {
$subItemQueryLimit = null;
}

$viewParameters = [
'pager' => $pagination,
'pager_options' => [
'pageParameter' => sprintf('[%s]', self::PAGINATION_PARAM_NAME),
],
'locations' => $locations,
'sub_item_query_limit' => $subItemQueryLimit,
'form_content_location_add' => $formLocationAdd->createView(),
'form_content_location_remove' => $formLocationRemove->createView(),
'form_content_location_swap' => $formLocationSwap->createView(),
Expand Down
14 changes: 12 additions & 2 deletions src/lib/UI/Module/Subitems/ContentViewParameterSupplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Contracts\Rest\Output\Visitor;
use Ibexa\Core\MVC\Symfony\View\ContentView;
use Ibexa\Core\Query\QueryFactoryInterface;
Expand Down Expand Up @@ -69,6 +70,8 @@ class ContentViewParameterSupplier

private SearchService $searchService;

private ConfigResolverInterface $configResolver;

public function __construct(
Visitor $outputVisitor,
JsonOutputGenerator $outputGenerator,
Expand All @@ -81,7 +84,8 @@ public function __construct(
ContentTypeMappings $contentTypeMappings,
UserSettingService $userSettingService,
QueryFactoryInterface $queryFactory,
SearchService $searchService
SearchService $searchService,
ConfigResolverInterface $configResolver
) {
$this->outputVisitor = $outputVisitor;
$this->outputGenerator = $outputGenerator;
Expand All @@ -95,6 +99,7 @@ public function __construct(
$this->userSettingService = $userSettingService;
$this->queryFactory = $queryFactory;
$this->searchService = $searchService;
$this->configResolver = $configResolver;
}

/**
Expand Down Expand Up @@ -185,7 +190,12 @@ private function createRestLocation(Location $location): RestLocation
{
return new RestLocation(
$location,
$this->locationService->getLocationChildCount($location)
$this->locationService->getLocationChildCount(
$location,
// For the sub items module we only ever use the count to determine if there are children (0 or 1+),
// hence setting a limit of 1 is sufficient here.
1
)
);
}

Expand Down
13 changes: 11 additions & 2 deletions src/lib/UI/Value/ValueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup;
use Ibexa\Contracts\Core\Repository\Values\User\Policy;
use Ibexa\Contracts\Core\Repository\Values\User\RoleAssignment;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface;
use Ibexa\Core\Repository\LocationResolver\LocationResolver;

Expand Down Expand Up @@ -74,6 +75,9 @@ class ValueFactory
/** @var \Ibexa\Core\Repository\LocationResolver\LocationResolver */
protected $locationResolver;

/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
protected $configResolver;

/**
* @param \Ibexa\Contracts\Core\Repository\UserService $userService
* @param \Ibexa\Contracts\Core\Repository\LanguageService $languageService
Expand All @@ -86,6 +90,7 @@ class ValueFactory
* @param \Ibexa\AdminUi\UI\Dataset\DatasetFactory $datasetFactory
* @param \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider
* @param \Ibexa\Core\Repository\LocationResolver\LocationResolver $locationResolver
* @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver
*/
public function __construct(
UserService $userService,
Expand All @@ -98,7 +103,8 @@ public function __construct(
PathService $pathService,
DatasetFactory $datasetFactory,
UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider,
LocationResolver $locationResolver
LocationResolver $locationResolver,
ConfigResolverInterface $configResolver
) {
$this->userService = $userService;
$this->languageService = $languageService;
Expand All @@ -111,6 +117,7 @@ public function __construct(
$this->datasetFactory = $datasetFactory;
$this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider;
$this->locationResolver = $locationResolver;
$this->configResolver = $configResolver;
}

/**
Expand Down Expand Up @@ -237,9 +244,11 @@ public function createLocation(Location $location): UIValue\Content\Location
{
$translations = $location->getContent()->getVersionInfo()->languageCodes;
$target = (new Target\Version())->deleteTranslations($translations);
$limit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');
$useLimit = $limit > 0;

return new UIValue\Content\Location($location, [
'childCount' => $this->locationService->getLocationChildCount($location),
'childCount' => $this->locationService->getLocationChildCount($location, $useLimit ? $limit + 1 : null),
'pathLocations' => $this->pathService->loadPathLocations($location),
'userCanManage' => $this->permissionResolver->canUser(
'content',
Expand Down
Loading