Skip to content
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

IBX-9619: Reworked draft list action #1480

Draft
wants to merge 23 commits into
base: 4.6
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1770e03
Added DraftListActionMenuBuilder
ciastektk Feb 26, 2025
cc5a892
[DI] Added service definition
ciastektk Feb 26, 2025
06e228d
Added const with event identifier
ciastektk Feb 26, 2025
4bb351c
[Translations] Extracted translations
ciastektk Feb 26, 2025
a3c8efb
Added action_list.html.twig
ciastektk Feb 26, 2025
d352e85
Used KNP menu to render actions for draft list
ciastektk Feb 26, 2025
e6b7e5d
Fixed cs
ciastektk Feb 26, 2025
8cc2c4e
Updated action_list twig
OstafinL Feb 26, 2025
a764e48
Fixed cs
ciastektk Feb 27, 2025
ac71c01
Added ContentAwareActionItemFactory
ciastektk Mar 6, 2025
e6b52ac
Added AbstractActionBuilder
ciastektk Mar 6, 2025
9225eff
Removed CONTENT_DRAFT_LIST_ACTION const from ConfigureMenuEvent
ciastektk Mar 6, 2025
f4b8c1d
Reworked DraftListActionMenuBuilder
ciastektk Mar 6, 2025
4234594
Added VersionListActionMenuBuilder
ciastektk Mar 6, 2025
1ed9c85
Reworked table template for version list
ciastektk Mar 6, 2025
e760bff
Added support for own classess in action_list.html.twig
ciastektk Mar 6, 2025
c9c40ec
Dropped extra comma from AbstracActionBuilder constructor
ciastektk Mar 6, 2025
24a1feb
Dropped ContentAwareActionItemFactory
ciastektk Mar 10, 2025
bc1ce70
Reworked AbstractActionBuilder
ciastektk Mar 10, 2025
7ff64bc
[DI] dropped service definition
ciastektk Mar 10, 2025
b242bd0
Extracted translations
ciastektk Mar 10, 2025
63a581b
Fixed rendering action list for published content
ciastektk Mar 11, 2025
3484e81
Marked AbstractActionBuilder::createEditDraftAction as protected
ciastektk Mar 11, 2025
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
1 change: 1 addition & 0 deletions src/bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ imports:
- { resource: services/controller_argument_resolvers.yaml }
- { resource: services/controllers.yaml }
- { resource: services/tabs.yaml }
- { resource: services/action_menu.yaml }
- { resource: services/menu.yaml }
- { resource: services/pagination.yaml }
- { resource: services/ui_config/* }
Expand Down
13 changes: 13 additions & 0 deletions src/bundle/Resources/config/services/action_menu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: true

Ibexa\AdminUi\Menu\Action\DraftListActionMenuBuilder:
tags:
- { name: knp_menu.menu_builder, method: build, alias: ibexa.admin_ui.action.draft_list }

Ibexa\AdminUi\Menu\Action\VersionListActionMenuBuilder:
tags:
- { name: knp_menu.menu_builder, method: build, alias: ibexa.admin_ui.action.version_list }
26 changes: 26 additions & 0 deletions src/bundle/Resources/translations/ibexa_action_menu.en.xliff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="9a3c440d94f09d2b4bbddb67d0394ca555f8bd3f" resname="draft_list__action__content_edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: draft_list__action__content_edit</note>
</trans-unit>
<trans-unit id="3574634178fbd999f1dc70abc2bb1af1adb0a5fa" resname="version_list__action__content_edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: version_list__action__content_edit</note>
</trans-unit>
<trans-unit id="1a76a5a34ec8f37aa0af6fb321aa10b4b1a4f321" resname="version_list__action__restore_version">
<source>Restore archived version</source>
<target state="new">Restore archived version</target>
<note>key: version_list__action__restore_version</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 0 additions & 5 deletions src/bundle/Resources/translations/ibexa_dashboard.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
<target state="new">Can't fetch contributor</target>
<note>key: dashboard.table.contributor.not_found</note>
</trans-unit>
<trans-unit id="93a5fc53032106ea0ae1658261fd187e5c9c6a94" resname="dashboard.table.draft.edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: dashboard.table.draft.edit</note>
</trans-unit>
<trans-unit id="5c6a58e397b164610db6371fe26b4e79aa3962f8" resname="dashboard.table.draft.unauthorized">
<source>You do not have the '%function%' '%module%' permission for content ID: %contentId%</source>
<target state="new">You do not have the '%function%' '%module%' permission for content ID: %contentId%</target>
Expand Down
5 changes: 0 additions & 5 deletions src/bundle/Resources/translations/ibexa_drafts.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
<target state="new">Drafts</target>
<note>key: drafts.list</note>
</trans-unit>
<trans-unit id="7a00fa1045089ab6b05a30314644f3f53477ecbf" resname="drafts.list.action.edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: drafts.list.action.edit</note>
</trans-unit>
<trans-unit id="887b9056de68ebd1c33c43af14093c2cafb38c5d" resname="drafts.list.action.remove">
<source>Remove</source>
<target state="new">Remove</target>
Expand Down
10 changes: 0 additions & 10 deletions src/bundle/Resources/translations/messages.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,6 @@
<target state="new">Swap the Content item at this Location with another</target>
<note>key: tab.locations.swap_with_another</note>
</trans-unit>
<trans-unit id="d2e707023baa6830915c5d12b915974d627522e4" resname="tab.versions.table.action.archived.edit">
<source>Restore archived version</source>
<target state="new">Restore archived version</target>
<note>key: tab.versions.table.action.archived.edit</note>
</trans-unit>
<trans-unit id="97721a4a6c33834bb6421c29ef72e8654f39a4ab" resname="tab.versions.table.action.draft.edit">
<source>Edit</source>
<target state="new">Edit</target>
<note>key: tab.versions.table.action.draft.edit</note>
</trans-unit>
<trans-unit id="a602612589c6e902caaf8acf1fd51fcd215955f1" resname="tab.versions.table.author.not_found">
<source>Can't fetch contributor</source>
<target state="new">Can't fetch contributor</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,13 @@
]) %}

{% set col_raw %}
{{ ibexa_render_component_group('content-drafts-list-actions', { version_info: row.versionInfo }) }}
<button
class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text mx-2 ibexa-btn--content-draft-edit"
title="{{ 'drafts.list.action.edit'|trans|desc('Edit') }}"
data-content-id="{{ row.versionInfo.contentInfo.id }}"
data-language-code="{{ row.versionInfo.initialLanguageCode }}"
data-content-draft-edit-url="{{ path(content_draft_edit_url, {
'contentId': row.versionInfo.contentInfo.id,
'versionNo': row.versionInfo.versionNo,
'language': row.versionInfo.initialLanguageCode
}) }}"
data-version-has-conflict-url="{{ path('ibexa.version.has_no_conflict', {
'contentId': row.versionInfo.contentInfo.id,
'versionNo': row.versionInfo.versionNo,
'languageCode': row.versionInfo.initialLanguageCode
}) }}"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--edit">
<use xlink:href="{{ ibexa_icon_path('edit') }}"></use>
</svg>
</button>
{% set draft_action_list = knp_menu_get(
'ibexa.admin_ui.action.draft_list',
[],
{ versionInfo: row.versionInfo}) %}
{{ knp_menu_render(draft_action_list, {
template: '@ibexadesign/ui/action_list.html.twig',
}) }}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
has_action_btns: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@
</thead>
<tbody class="ibexa-table__body">
{% for version in versions %}
{% set edit_url = content_is_user is defined and content_is_user ?
path('ibexa.user.update', {
'contentId': version.contentInfo.id,
'versionNo': version.versionNo,
'language': version.initialLanguageCode,
}) : path('ibexa.content.draft.edit', {
'contentId': version.contentInfo.id,
'versionNo': version.versionNo,
'language': version.initialLanguageCode,
'locationId': location.id ?? null
})
%}

{% set custom_columns %}
{% block custom_columns %}{% endblock %}
{% endset %}
Expand Down Expand Up @@ -102,51 +89,23 @@
content: version.modificationDate|ibexa_full_datetime,
} %}

{% if have_actions %}
{% set version_action_list = knp_menu_get(
'ibexa.admin_ui.action.version_list',
[],
{
versionInfo: version,
isDraftConflict: is_draft_conflict,
locationId: location.id ?? null
})
%}

{% if have_actions or version_action_list != null %}
{% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { has_action_btns: true } %}
{% block action_btns_content %}
{{ custom_actions_column }}
{% if is_draft_conflict %}
<a
href="{{ edit_url }}"
class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text"
title="{{ 'tab.versions.table.action.draft.edit'|trans|desc('Edit') }}"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--edit">
<use xlink:href="{{ ibexa_icon_path('edit') }}"></use>
</svg>
</a>
{% elseif is_draft %}
<button
data-content-draft-edit-url="{{ edit_url }}"
data-version-has-conflict-url="{{ path('ibexa.version.has_no_conflict', {
'contentId': version.contentInfo.id,
'versionNo': version.versionNo,
'languageCode': version.initialLanguageCode
}) }}"
data-content-id="{{ version.contentInfo.id }}"
data-language-code="{{ version.initialLanguageCode }}"
class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text mx-2 ibexa-btn--content-draft-edit"
title="{{ 'tab.versions.table.action.draft.edit'|trans|desc('Edit') }}"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--edit">
<use xlink:href="{{ ibexa_icon_path('edit') }}"></use>
</svg>
</button>
{% endif %}
{% if is_archived %}
<button
class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text mx-2 ibexa-btn--content-edit"
title="{{ 'tab.versions.table.action.archived.edit'|trans|desc('Restore archived version') }}"
data-content-id="{{ version.contentInfo.id }}"
data-version-no="{{ version.versionNo }}"
data-language-code="{{ version.initialLanguageCode }}"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--edit">
<use xlink:href="{{ ibexa_icon_path('archive-restore') }}"></use>
</svg>
</button>
{% endif %}
{{ knp_menu_render(version_action_list, {
template: '@ibexadesign/ui/action_list.html.twig',
}) }}
{% endblock %}
{% endembed %}
{% endif %}
Expand Down
24 changes: 24 additions & 0 deletions src/bundle/Resources/views/themes/admin/ui/action_list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% import "@ibexadesign/ui/component/macros.html.twig" as html %}

{% for action in item.children %}
{% set element = action.uri ? 'a' : 'button' %}
{% set classess = {
class: 'btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text' ~ ' ' ~ action.attributes.class|default('')
} %}

{% set attr = {
title: action.label
}|merge(action.attributes, classess) %}

{% if action.uri %}
{% set attr = attr|merge({ href: action.uri })%}
{% else %}
{% set attr = attr|merge({ type: 'button' })%}
{% endif %}

<{{ element }} {{ html.attributes(attr) }}>
<svg class="ibexa-icon ibexa-icon--small">
<use xlink:href="{{ ibexa_icon_path(action.extras.icon) }}"></use>
</svg>
</{{ element }}>
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,13 @@
]) %}

{% set col_raw %}
{{ ibexa_render_component_group('content-drafts-list-actions', { version_info: row.versionInfo }) }}
<button
class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text mx-2 ibexa-btn--content-draft-edit"
title="{{ 'dashboard.table.draft.edit'|trans|desc('Edit') }}"
data-content-draft-edit-url="{{ path(content_draft_edit_url, {
'contentId': row.versionInfo.contentInfo.id,
'versionNo': row.versionInfo.versionNo,
'language': row.versionInfo.initialLanguageCode
}) }}"
data-version-has-conflict-url="{{ path('ibexa.version.has_no_conflict', {
'contentId': row.versionInfo.contentInfo.id,
'versionNo': row.versionInfo.versionNo,
'languageCode': row.versionInfo.initialLanguageCode
}) }}"
data-content-id="{{ row.versionInfo.contentInfo.id }}"
data-language-code="{{ row.versionInfo.initialLanguageCode }}"
>
<svg class="ibexa-icon ibexa-icon--small ibexa-icon--edit">
<use xlink:href="{{ ibexa_icon_path('edit') }}"></use>
</svg>
</button>
{% set draft_action_list = knp_menu_get(
'ibexa.admin_ui.action.draft_list',
[],
{ versionInfo: row.versionInfo}) %}
{{ knp_menu_render(draft_action_list, {
template: '@ibexadesign/ui/action_list.html.twig',
}) }}
{% endset %}
{% set body_row_cols = body_row_cols|merge([{
has_action_btns: true,
Expand Down
Loading
Loading