Skip to content

feature-cfm291-bulkActions #198

Merged
merged 15 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,11 @@ msgstr "Active, Cannot Be Disabled"
msgid "plugin.inactive"
msgstr "Inactive"

msgid "record"
msgstr "Record"

msgid "report.for"
msgstr "Report for "

msgid "table.list"
msgstr "{0} List"
18 changes: 15 additions & 3 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ msgstr "Add"
msgid "add.a"
msgstr "Add a New {0}"

msgid "add.bulk"
msgstr "Bulk add"

msgid "add.member"
msgstr "Add member: "

msgid "apply"
msgstr "Apply"

msgid "autocomplete.pager.show.more"
msgstr "show more"

Expand Down Expand Up @@ -69,6 +69,12 @@ msgstr "Assign"
msgid "any"
msgstr "Any"

msgid "bulk.actions"
msgstr "Bulk Actions"

msgid "bulk.add"
msgstr "Bulk add"

msgid "cancel"
msgstr "Cancel"

Expand Down Expand Up @@ -171,6 +177,9 @@ msgstr "Display records"
msgid "page.goto"
msgstr "Go to page"

msgid "pick"
msgstr "Pick"

msgid "previous"
msgstr "Previous"

Expand Down Expand Up @@ -210,6 +219,9 @@ msgstr "Search"
msgid "search.global"
msgstr "Global Search"

msgid "select.prompt"
msgstr "Please select..."

msgid "skip_to_content"
msgstr "Skip to main content"

Expand Down
9 changes: 9 additions & 0 deletions app/resources/locales/en_US/result.po
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ msgstr "External Identity status recalculated from {0} to {1}"
msgid "ExternalIdentitySources.synced"
msgstr "External Identity Source sync complete"

msgid "failed"
msgstr "failed"

msgid "Groups.added"
msgstr "Group {0} created"

Expand Down Expand Up @@ -154,6 +157,9 @@ msgstr "Created new External Identity via Pipeline {0} ({1}) using Source {2} ({
msgid "Pipelines.started"
msgstr "Pipeline {0} ({1}) started for EIS {2} ({3}) source key {4}"

msgid "removed"
msgstr "removed"

msgid "saved"
msgstr "Saved"

Expand Down Expand Up @@ -190,3 +196,6 @@ msgstr "Database connection established"

msgid "test.mail.ok"
msgstr "Test message sent"

msgid "updated"
msgstr "updated"
11 changes: 10 additions & 1 deletion app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,21 @@ public function beforeFilter(EventInterface $event) {
}

if(Configure::read('debug')) {
// For testing purposes throw an error, but in production we want to
// For testing purposes, throw an error, but in production we want to
// redirect to /login
if($request->is('ajax') || $request->is('restful')) {
// Permission denied
throw new ForbiddenException(__d('error', 'perm'));
}
$controller->Flash->error("Authorization Failed (RegistryAuthComponent)");
return $controller->redirect("/");
}
}

if($request->is('ajax') || $request->is('restful')) {
// Permission denied
throw new ForbiddenException(__d('error', 'perm'));
}

// No authentication, redirect to login

Expand Down
76 changes: 76 additions & 0 deletions app/src/Lib/Enum/BulkActionEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* COmanage Registry Bulk Action Enum
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

namespace App\Lib\Enum;

class BulkActionEnum extends StandardEnum {
public const Delete = 'delete';
public const PromoteToOwner = 'owner';

/**
* Return action to request http method
*
* @param string $action
*
* @return string
* @since COmanage Registry v5.0.0
*/

public static function actionToMethod(string $action) : string
{
return match($action) {
'delete' => 'delete',
'owner' => 'post',
default => 'get'
};
}

/**
* Return actions to request http methods
*
* @param array $actions
*
* @return array
* @since COmanage Registry v5.0.0
*/

public static function actionsToMethods() : array
{
$ret = [];
foreach (self::getConstValues() as $act) {
$ret[$act] = match($act) {
'delete' => 'delete',
'owner' => 'post',
default => 'get'
};
}

return $ret;
}
}
39 changes: 39 additions & 0 deletions app/src/Lib/Enum/StandardEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,43 @@ public static function getConstValues() : array {

return array_values($consts);
}

/**
* Get the Keys for the constants in the Enumeration in Humanized form.
*
* @since COmanage Registry v5.0.0
* @return array Array of enumeration keys
*/

public static function getConstHumanized() : array {
// Get the keys for this enum
$reflect = new ReflectionClass(get_called_class());

$consts = $reflect->getConstants();

return collection(array_keys($consts))->map(
fn($key) => Inflector::humanize(Inflector::underscore($key))
)->toList();
}

/**
* Reverse the Const. The key is now the value is the humanized form
* of the key. Ideal for Select elements
*
* @since COmanage Registry v5.0.0
* @return array
*/

public static function getHumanized() : array {
// Get the keys for this enum
$reflect = new ReflectionClass(get_called_class());

$consts = $reflect->getConstants();

$humanized = collection(array_keys($consts))->map(
fn($key) => Inflector::humanize(Inflector::underscore($key))
)->toList();

return array_combine(array_values($consts), $humanized);
}
}
10 changes: 9 additions & 1 deletion app/src/View/Helper/VueHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ class VueHelper extends Helper {
'login',
'primary',
'datepicker.hour',
'status',
'unverified'
],
'information' => [
'global.value.none',
'datepicker.hour'
'datepicker.hour',
'record',
'report.for'
],
'operation' => [
'add',
Expand All @@ -65,6 +68,11 @@ class VueHelper extends Helper {
'autocomplete.people.label',
'autocomplete.people.placeholder',
'close'
],
'result' => [
'failed',
'removed',
'updated'
]
];

Expand Down
14 changes: 7 additions & 7 deletions app/templates/GroupMembers/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

use App\Lib\Enum\BulkActionEnum;

$indexColumns = [
'name' => [
'type' => 'link',
Expand Down Expand Up @@ -83,13 +85,11 @@ $topLinks = [
*/
];

/*
// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
$bulkActions = [
// TODO: develop bulk actions. For now, use a placeholder.
'delete' => true
];
*/

// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
// The array should contain a list of actions to be made available.
$bulkActions = [BulkActionEnum::Delete];


$subnav = [
'name' => 'group',
Expand Down
13 changes: 6 additions & 7 deletions app/templates/Groups/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

use App\Lib\Enum\BulkActionEnum;

$indexColumns = [
'name' => [
'type' => 'link'
Expand Down Expand Up @@ -73,10 +75,7 @@ $rowActions = [
]
];

/*
// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
$bulkActions = [
// TODO: develop bulk actions. For now, use a placeholder.
'delete' => true
];
*/

// When the $bulkActions variable exists in a columns.inc config, the "Bulk edit" switch will appear in the index.
// The array should contain a list of actions to be made available.
$bulkActions = [BulkActionEnum::Delete];
5 changes: 4 additions & 1 deletion app/templates/Notifications/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ if($vv_action == 'view') {
]
]);
} else {
print $this->Field->control('status');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'status'
]]);
}

print $this->element('form/listItem', [
Expand Down
Loading