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

Feature/dev 1165 edit element additional toolbar menu #13847

Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
11152b8
WIP on additional menu in the toolbar
i-just Jul 31, 2023
f61f17c
refactor additional menu WIP
i-just Aug 2, 2023
93994f1
use anchor tag as default
i-just Aug 2, 2023
6d5924b
edit user to use the additional menu, not its own version
i-just Aug 2, 2023
c832d97
tweaks to support grouping - tbc
i-just Aug 2, 2023
b7c6c6e
asset additional components + cleanup
i-just Aug 16, 2023
28e9777
include additional menu btn in a slideout
i-just Aug 16, 2023
566bcf1
rename event
i-just Aug 16, 2023
1542d86
make formsubmit links work
i-just Aug 16, 2023
26e052b
compiled assets
i-just Aug 16, 2023
e5ece99
define menu component event needs to know the element
i-just Aug 16, 2023
cb18318
ensure formsubmit class only for action component
i-just Aug 16, 2023
34ca512
formsubmit - allow use of btn data-form
i-just Aug 16, 2023
c23a6c1
edit user - move compiling actions to user element
i-just Aug 16, 2023
a0ae6c5
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
i-just Aug 16, 2023
f2fde24
WIP formsubmit() in a disclosureMenu in a slideoout
i-just Aug 18, 2023
5f8ccf0
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
i-just Sep 26, 2023
6295d4a
formsubmit() in a disclosureMenu in a slideoout
i-just Sep 26, 2023
718a08c
cleanup
i-just Sep 26, 2023
bb04f44
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
i-just Sep 27, 2023
c540530
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
i-just Oct 19, 2023
dbc3eaa
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
i-just Oct 19, 2023
dff4811
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
brandonkelly Oct 19, 2023
c0bc5a1
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
brandonkelly Oct 30, 2023
3b13f70
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
brandonkelly Nov 1, 2023
a02ffa3
Merge branch '5.0' into feature/dev-1165-edit-element-additional-tool…
brandonkelly Nov 2, 2023
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
62 changes: 44 additions & 18 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
@@ -871,7 +871,9 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
$statusLabel = $user->archived ? Craft::t('app', 'Archived') : Craft::t('app', 'Disabled');
if (Craft::$app->getElements()->canSave($user)) {
$statusActions[] = [
'action' => 'users/enable-user',
'data' => [
'action' => 'users/enable-user',
],
'label' => Craft::t('app', 'Enable'),
];
}
@@ -883,20 +885,26 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
if ($user->email) {
if ($user->pending || $canAdministrateUsers) {
$statusActions[] = [
'action' => 'users/send-activation-email',
'data' => [
'action' => 'users/send-activation-email',
],
'label' => Craft::t('app', 'Send activation email'),
];
}
if ($canAdministrateUsers) {
// Only need to show the "Copy activation URL" option if they don't have a password
if (!$user->password) {
$statusActions[] = [
'id' => 'copy-passwordreset-url',
'options' => [
'id' => 'copy-passwordreset-url',
],
'label' => Craft::t('app', 'Copy activation URL…'),
];
}
$statusActions[] = [
'action' => 'users/activate-user',
'data' => [
'action' => 'users/activate-user',
],
'label' => Craft::t('app', 'Activate account'),
];
}
@@ -906,7 +914,9 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
$statusLabel = Craft::t('app', 'Suspended');
if (Craft::$app->getUsers()->canSuspend($currentUser, $user)) {
$statusActions[] = [
'action' => 'users/unsuspend-user',
'data' => [
'action' => 'users/unsuspend-user',
],
'label' => Craft::t('app', 'Unsuspend'),
];
}
@@ -924,7 +934,9 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
)
) {
$statusActions[] = [
'action' => 'users/unlock-user',
'data' => [
'action' => 'users/unlock-user',
],
'label' => Craft::t('app', 'Unlock'),
];
}
@@ -934,12 +946,16 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array

if (!$isCurrentUser) {
$statusActions[] = [
'action' => 'users/send-password-reset-email',
'data' => [
'action' => 'users/send-password-reset-email',
],
'label' => Craft::t('app', 'Send password reset email'),
];
if ($canAdministrateUsers) {
$statusActions[] = [
'id' => 'copy-passwordreset-url',
'options' => [
'id' => 'copy-passwordreset-url',
],
'label' => Craft::t('app', 'Copy password reset URL…'),
];
}
@@ -950,20 +966,26 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
if (!$isCurrentUser) {
if (Craft::$app->getUsers()->canImpersonate($currentUser, $user)) {
$sessionActions[] = [
'action' => 'users/impersonate',
'data' => [
'action' => 'users/impersonate',
],
'label' => $name
? Craft::t('app', 'Sign in as {user}', ['user' => $user->getName()])
: Craft::t('app', 'Sign in as user'),
];
$sessionActions[] = [
'id' => 'copy-impersonation-url',
'options' => [
'id' => 'copy-impersonation-url',
],
'label' => Craft::t('app', 'Copy impersonation URL…'),
];
}

if (Craft::$app->getUsers()->canSuspend($currentUser, $user) && $user->active && !$user->suspended) {
$destructiveActions[] = [
'action' => 'users/suspend-user',
'data' => [
'action' => 'users/suspend-user',
],
'label' => Craft::t('app', 'Suspend'),
];
}
@@ -973,15 +995,19 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
if (!$user->admin || $currentUser->admin) {
if (($isCurrentUser || $canAdministrateUsers) && ($user->active || $user->pending)) {
$destructiveActions[] = [
'action' => 'users/deactivate-user',
'data' => [
'action' => 'users/deactivate-user',
'confirm' => Craft::t('app', 'Deactivating a user revokes their ability to sign in. Are you sure you want to continue?'),
],
'label' => Craft::t('app', 'Deactivate…'),
'confirm' => Craft::t('app', 'Deactivating a user revokes their ability to sign in. Are you sure you want to continue?'),
];
}

if ($isCurrentUser || $currentUser->can('deleteUsers')) {
$destructiveActions[] = [
'id' => 'delete-btn',
'options' => [
'id' => 'delete-btn',
],
'label' => Craft::t('app', 'Delete…'),
];
}
@@ -998,15 +1024,15 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
]);
$this->trigger(self::EVENT_REGISTER_USER_ACTIONS, $event);

$actions = array_filter([
$additionalMenuComponents = array_filter(array_merge(
$event->statusActions,
$event->miscActions,
$event->sessionActions,
array_map(function(array $action): array {
$action['destructive'] = true;
$action['data']['destructive'] = true;
return $action;
}, $event->destructiveActions),
]);
));

// Set the appropriate page title
// ---------------------------------------------------------------------
@@ -1186,7 +1212,7 @@ public function actionEditUser(mixed $userId = null, ?User $user = null, ?array
'user',
'isNewUser',
'statusLabel',
'actions',
'additionalMenuComponents',
'languageOptions',
'localeOptions',
'userLanguage',
42 changes: 0 additions & 42 deletions src/templates/users/_edit.twig
Original file line number Diff line number Diff line change
@@ -49,48 +49,6 @@
</div>
</div>
{% endif %}

{% if actions|length %}
<div>
{{ forms.button({
class: 'menubtn',
attributes: {
id: 'additional-menu-btn',
title: 'Actions'|t('app'),
aria: {
label: 'Actions'|t('app'),
},
data: {
icon: 'settings',
},
},
spinner: true,
}) }}
<div class="menu">
{% for actionList in actions %}
{% if not loop.first %}<hr>{% endif %}
<ul>
{% for actionItem in actionList %}
<li>
{{ tag('a', {
id: actionItem.id ?? false,
class: [
(actionItem.action ?? false) ? 'formsubmit',
(actionItem.destructive ?? false) ? 'error',
]|filter,
data: {
action: actionItem.action ?? false,
confirm: actionItem.confirm ?? false,
},
text: actionItem.label,
}) }}
</li>
{% endfor %}
</ul>
{% endfor %}
</div>
</div>
{% endif %}
{% endblock %}

{% block content %}