From c8c3f161f19691f9f4952691a5fe50b7e4e1441e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20D=C4=99bi=C5=84ski?= Date: Tue, 7 May 2024 13:13:45 +0200 Subject: [PATCH] IBX-8254: Added check if relation is accessible --- .../tab/relations/table_relations.html.twig | 68 +++++++++++-------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/bundle/Resources/views/themes/admin/content/tab/relations/table_relations.html.twig b/src/bundle/Resources/views/themes/admin/content/tab/relations/table_relations.html.twig index 2bdd347e32..73b3d87243 100644 --- a/src/bundle/Resources/views/themes/admin/content/tab/relations/table_relations.html.twig +++ b/src/bundle/Resources/views/themes/admin/content/tab/relations/table_relations.html.twig @@ -6,36 +6,46 @@ {% if relations is not empty %} {% for relation in relations %} {% set body_row_cols = [] %} - {% set destination = relation.destinationContentInfo %} - - {% set col_raw %} - {% if destination.mainLocationId is not null %} - + {% if relation.isAccessible %} + {% set destination = relation.destinationContentInfo %} + {% set col_raw %} + {% if destination.mainLocationId is not null %} + + {{ ibexa_content_name(destination) }} + + {% else %} {{ ibexa_content_name(destination) }} - - {% else %} - {{ ibexa_content_name(destination) }} - {% endif %} - {% endset %} - {% set body_row_cols = body_row_cols|merge([{ - content: col_raw, - raw: true, - }]) %} - - {% set body_row_cols = body_row_cols|merge([ - { content: content_types[destination.contentTypeId].name }, - ]) %} - - {% set col_raw %} - {{ macros.relation_type(relation) }} - {% if (relation.relationFieldDefinitionName) %} - ({{ relation.relationFieldDefinitionName }}) - {% endif %} - {% endset %} - {% set body_row_cols = body_row_cols|merge([{ - content: col_raw, - raw: true, - }]) %} + {% endif %} + {% endset %} + {% set body_row_cols = body_row_cols|merge([{ + content: col_raw, + raw: true, + }]) %} + + {% set body_row_cols = body_row_cols|merge([ + { content: content_types[destination.contentTypeId].name }, + ]) %} + + {% set col_raw %} + {{ macros.relation_type(relation) }} + {% if (relation.relationFieldDefinitionName) %} + ({{ relation.relationFieldDefinitionName }}) + {% endif %} + {% endset %} + {% set body_row_cols = body_row_cols|merge([{ + content: col_raw, + raw: true, + }]) %} + {% else %} + {% set body_row_cols = body_row_cols|merge([{ + attr: { colspan: 8 }, + content: 'dashboard.table.relation.unauthorized'|trans({ + '%module%': relation.unauthorizedRelation.module, + '%function%': relation.unauthorizedRelation.function, + '%contentId%': relation.unauthorizedRelation.payload.contentId, + })|desc('You do not have the \'%function%\' \'%module%\' permission for content ID: %contentId%'), + }]) %} + {% endif %} {% set body_rows = body_rows|merge([{ cols: body_row_cols }]) %} {% endfor %}