-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-4125: Optimized Dashboard tabs (#2075)
- Loading branch information
Showing
13 changed files
with
361 additions
and
169 deletions.
There are no files selected for viewing
This file contains 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 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 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,24 @@ | ||
<?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\QueryType; | ||
|
||
use EzSystems\EzPlatformAdminUiBundle\DependencyInjection\Configuration\Parser\SubtreePath; | ||
|
||
final class ContentLocationSubtreeQueryType extends LocationSubtreeQueryType | ||
{ | ||
public static function getName(): string | ||
{ | ||
return 'IbexaAdminUi:ContentLocationSubtree'; | ||
} | ||
|
||
protected function getSubtreePathFromConfiguration(): string | ||
{ | ||
return $this->configResolver->getParameter(SubtreePath::CONTENT_SUBTREE_PATH); | ||
} | ||
} |
This file contains 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,75 @@ | ||
<?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\QueryType; | ||
|
||
use eZ\Publish\API\Repository\PermissionResolver; | ||
use eZ\Publish\API\Repository\Values\Content\LocationQuery; | ||
use eZ\Publish\API\Repository\Values\Content\Query; | ||
use eZ\Publish\Core\MVC\ConfigResolverInterface; | ||
use eZ\Publish\Core\QueryType\OptionsResolverBasedQueryType; | ||
use eZ\Publish\Core\QueryType\QueryType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
abstract class LocationSubtreeQueryType extends OptionsResolverBasedQueryType implements QueryType | ||
{ | ||
protected const OWNED_OPTION_NAME = 'owned'; | ||
protected const SUBTREE_OPTION_NAME = 'subtree'; | ||
|
||
/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ | ||
protected $configResolver; | ||
|
||
/** @var \eZ\Publish\API\Repository\PermissionResolver */ | ||
private $permissionResolver; | ||
|
||
public function __construct( | ||
ConfigResolverInterface $configResolver, | ||
PermissionResolver $permissionResolver | ||
) { | ||
$this->configResolver = $configResolver; | ||
$this->permissionResolver = $permissionResolver; | ||
} | ||
|
||
public function doGetQuery(array $parameters): LocationQuery | ||
{ | ||
$subtreeCriterion = new Query\Criterion\Subtree($parameters[self::SUBTREE_OPTION_NAME]); | ||
|
||
$ownerId = $parameters[self::OWNED_OPTION_NAME] | ||
? $this->permissionResolver->getCurrentUserReference()->getUserId() | ||
: null; | ||
|
||
if ($ownerId !== null) { | ||
$filter = new Query\Criterion\LogicalAnd([ | ||
$subtreeCriterion, | ||
new Query\Criterion\UserMetadata( | ||
Query\Criterion\UserMetadata::OWNER, | ||
Query\Criterion\Operator::EQ, | ||
$ownerId | ||
), | ||
]); | ||
} else { | ||
$filter = $subtreeCriterion; | ||
} | ||
|
||
return new LocationQuery([ | ||
'filter' => $filter, | ||
'sortClauses' => [new Query\SortClause\DateModified(Query::SORT_DESC)], | ||
]); | ||
} | ||
|
||
protected function configureOptions(OptionsResolver $optionsResolver): void | ||
{ | ||
$optionsResolver->setDefined([self::SUBTREE_OPTION_NAME, self::OWNED_OPTION_NAME]); | ||
$optionsResolver->setAllowedTypes(self::SUBTREE_OPTION_NAME, 'string'); | ||
$optionsResolver->setAllowedTypes(self::OWNED_OPTION_NAME, 'bool'); | ||
$optionsResolver->setDefault(self::SUBTREE_OPTION_NAME, $this->getSubtreePathFromConfiguration()); | ||
$optionsResolver->setDefault(self::OWNED_OPTION_NAME, false); | ||
} | ||
|
||
abstract protected function getSubtreePathFromConfiguration(): string; | ||
} |
This file contains 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,24 @@ | ||
<?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\QueryType; | ||
|
||
use EzSystems\EzPlatformAdminUiBundle\DependencyInjection\Configuration\Parser\SubtreePath; | ||
|
||
final class MediaLocationSubtreeQueryType extends LocationSubtreeQueryType | ||
{ | ||
public static function getName(): string | ||
{ | ||
return 'IbexaAdminUi:MediaLocationSubtree'; | ||
} | ||
|
||
protected function getSubtreePathFromConfiguration(): string | ||
{ | ||
return $this->configResolver->getParameter(SubtreePath::MEDIA_SUBTREE_PATH); | ||
} | ||
} |
This file contains 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,42 @@ | ||
<?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\Tab\Dashboard; | ||
|
||
use eZ\Publish\API\Repository\SearchService; | ||
use eZ\Publish\Core\QueryType\QueryType; | ||
use EzSystems\EzPlatformAdminUi\Tab\AbstractTab; | ||
use EzSystems\EzPlatformAdminUi\Tab\OrderedTabInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
abstract class AbstractContentTab extends AbstractTab implements OrderedTabInterface | ||
{ | ||
/** @var \Ibexa\AdminUi\Tab\Dashboard\PagerLocationToDataMapper */ | ||
protected $pagerLocationToDataMapper; | ||
|
||
/** @var \eZ\Publish\API\Repository\SearchService */ | ||
protected $searchService; | ||
|
||
/** @var \Ibexa\AdminUi\QueryType\ContentLocationSubtreeQueryType */ | ||
protected $contentLocationSubtreeQueryType; | ||
|
||
public function __construct( | ||
Environment $twig, | ||
TranslatorInterface $translator, | ||
PagerLocationToDataMapper $pagerLocationToDataMapper, | ||
SearchService $searchService, | ||
QueryType $contentLocationSubtreeQueryType | ||
) { | ||
parent::__construct($twig, $translator); | ||
|
||
$this->pagerLocationToDataMapper = $pagerLocationToDataMapper; | ||
$this->searchService = $searchService; | ||
$this->contentLocationSubtreeQueryType = $contentLocationSubtreeQueryType; | ||
} | ||
} |
This file contains 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,42 @@ | ||
<?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\Tab\Dashboard; | ||
|
||
use eZ\Publish\API\Repository\SearchService; | ||
use eZ\Publish\Core\QueryType\QueryType; | ||
use EzSystems\EzPlatformAdminUi\Tab\AbstractTab; | ||
use EzSystems\EzPlatformAdminUi\Tab\OrderedTabInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
use Twig\Environment; | ||
|
||
abstract class AbstractMediaTab extends AbstractTab implements OrderedTabInterface | ||
{ | ||
/** @var \Ibexa\AdminUi\Tab\Dashboard\PagerLocationToDataMapper */ | ||
protected $pagerLocationToDataMapper; | ||
|
||
/** @var \eZ\Publish\API\Repository\SearchService */ | ||
protected $searchService; | ||
|
||
/** @var \Ibexa\AdminUi\QueryType\MediaLocationSubtreeQueryType */ | ||
protected $mediaLocationSubtreeQueryType; | ||
|
||
public function __construct( | ||
Environment $twig, | ||
TranslatorInterface $translator, | ||
PagerLocationToDataMapper $pagerLocationToDataMapper, | ||
SearchService $searchService, | ||
QueryType $mediaLocationSubtreeQueryType | ||
) { | ||
parent::__construct($twig, $translator); | ||
|
||
$this->pagerLocationToDataMapper = $pagerLocationToDataMapper; | ||
$this->searchService = $searchService; | ||
$this->mediaLocationSubtreeQueryType = $mediaLocationSubtreeQueryType; | ||
} | ||
} |
This file contains 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.