Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1c607f5f
Unverified
Commit
1c607f5f
authored
7 months ago
by
Lucas Hedding
Browse files
Options
Downloads
Patches
Plain Diff
hide some un-usable operations
parent
fcece3bb
No related branches found
No related tags found
1 merge request
!9940
Resolve #3091490 "Hide unusable workspace operations"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/workspaces/src/WorkspaceListBuilder.php
+27
-4
27 additions, 4 deletions
core/modules/workspaces/src/WorkspaceListBuilder.php
with
27 additions
and
4 deletions
core/modules/workspaces/src/WorkspaceListBuilder.php
+
27
−
4
View file @
1c607f5f
...
...
@@ -56,8 +56,17 @@ class WorkspaceListBuilder extends EntityListBuilder {
* The workspace repository service.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
* @param \Drupal\workspaces\WorkspaceAssociationInterface $workspace_association
* The workspace association service.
*/
public
function
__construct
(
EntityTypeInterface
$entity_type
,
EntityStorageInterface
$storage
,
WorkspaceManagerInterface
$workspace_manager
,
WorkspaceRepositoryInterface
$workspace_repository
,
RendererInterface
$renderer
)
{
public
function
__construct
(
EntityTypeInterface
$entity_type
,
EntityStorageInterface
$storage
,
WorkspaceManagerInterface
$workspace_manager
,
WorkspaceRepositoryInterface
$workspace_repository
,
RendererInterface
$renderer
,
protected
WorkspaceAssociationInterface
$workspaceAssociation
,
)
{
parent
::
__construct
(
$entity_type
,
$storage
);
$this
->
workspaceManager
=
$workspace_manager
;
$this
->
workspaceRepository
=
$workspace_repository
;
...
...
@@ -73,7 +82,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
$container
->
get
(
'entity_type.manager'
)
->
getStorage
(
$entity_type
->
id
()),
$container
->
get
(
'workspaces.manager'
),
$container
->
get
(
'workspaces.repository'
),
$container
->
get
(
'renderer'
)
$container
->
get
(
'renderer'
),
$container
->
get
(
'workspaces.association'
),
);
}
...
...
@@ -156,7 +166,7 @@ public function getDefaultOperations(EntityInterface $entity) {
];
}
if
(
!
$entity
->
hasParent
(
))
{
if
(
$this
->
isPublishable
(
$entity
))
{
$operations
[
'publish'
]
=
[
'title'
=>
$this
->
t
(
'Publish content'
),
// The 'Publish' operation should be the default one for the currently
...
...
@@ -168,7 +178,7 @@ public function getDefaultOperations(EntityInterface $entity) {
),
];
}
else
{
else
if
(
$entity
->
hasParent
())
{
/** @var \Drupal\workspaces\WorkspaceInterface $parent */
$parent
=
$entity
->
parent
->
entity
;
$operations
[
'merge'
]
=
[
...
...
@@ -399,4 +409,17 @@ protected function offCanvasRender(array &$build) {
unset
(
$build
[
'pager'
]);
}
/**
* Determine if an workspace should be publishable.
*
* @param \Drupal\workspaces\WorkspaceInterface $workspace
*
* @return bool
*/
protected
function
isPublishable
(
WorkspaceInterface
$workspace
):
bool
{
return
!
$workspace
->
hasParent
()
&&
$this
->
workspaceAssociation
->
getTrackedEntities
(
$workspace
->
id
())
!==
[]
&&
$this
->
storage
->
getQuery
()
->
condition
(
'parent'
,
$workspace
->
id
())
->
accessCheck
(
FALSE
)
->
count
()
->
execute
()
===
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment