Skip to content
Snippets Groups Projects
Commit 1296fd5f authored by Takumaru Sekine's avatar Takumaru Sekine Committed by Yas Naoi
Browse files

Issue #3353930 by yas, sekinet, Ryo Yamashita: Remove an "Edit" menu item from...

Issue #3353930 by yas, sekinet, Ryo Yamashita: Remove an "Edit" menu item from the Operations links in the OpenStack server group list view of SPA
parent 8d4ed1a1
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,13 @@ export const DONT_SHOW_OPERATIONS_ENTITY_TYPE_LIST = [
'k8s_node', 'k8s_event', 'openstack_template_version'
];
/**
* Entity type that displays only Delete in operation links in ListView.
*/
export const DELETE_ONLY_OPERATIONS_ENTITY_TYPE_LIST = [
'openstack_server_group'
];
/**
* The list of actions in the ListView.
*/
......
import { DONT_SHOW_OPERATIONS_ENTITY_TYPE_LIST, ROUTE_URL } from 'constant/others/other';
import { DONT_SHOW_OPERATIONS_ENTITY_TYPE_LIST, DELETE_ONLY_OPERATIONS_ENTITY_TYPE_LIST, ROUTE_URL } from 'constant/others/other';
import CloudContext from 'model/CloudContext';
import DataColumn from 'model/DataColumn';
import DataRecord from 'model/DataRecord';
......@@ -59,6 +59,24 @@ const updateAndDeleteData = (dataRecord: DataRecord, action: string, cloudContex
window.location.href = `${ROUTE_URL}/${urlParts}/${dataRecord.id}/${action}`;
}
/**
* Wrapper of Dropdown default item.
* @param dataRecord Data record of the element.
* @param entityId Entity id.
* @param cloudContextList CloudContext list.
*/
const DropdownDefaultItem = (dataRecord: DataRecord, entityId: string, cloudContextList: CloudContext[]) => {
// Entity that does not display Edit on Dropdown displays Delete by default.
const defaultItems = !DELETE_ONLY_OPERATIONS_ENTITY_TYPE_LIST.includes(entityId)
? { label: 'Edit', action: 'edit' }
: { label: 'Delete', action: 'delete' };
return <button type="button" className="dropdown-toggle links ripple-effect" onClick={(e) => {
e.preventDefault();
updateAndDeleteData(dataRecord, defaultItems.action, cloudContextList);
}}>{Drupal.t(defaultItems.label)}</button>;
}
/**
* Row data of DataTable.
* Note: The OperationLinks column is added.
......@@ -106,14 +124,13 @@ const DataTableRowWithOperationLinks = ({ dataRecord, dataColumnList, className,
<div className="dropbutton-wrapper dropbutton-multiple">
<div className="dropbutton-widget">
<Dropdown as={ButtonGroup} className="custom-dropdown">
<button type="button" className="dropdown-toggle links ripple-effect" onClick={(e) => {
e.preventDefault();
updateAndDeleteData(dataRecord, 'edit', cloudContextList);
}}>{Drupal.t('Edit')}</button>
{DropdownDefaultItem(dataRecord, dataRecord.entityTypeId, cloudContextList)}
<button type="button" className="uparrow" data-bs-toggle="dropdown" aria-expanded="false">
<span className="caret"></span>
</button>
{!DELETE_ONLY_OPERATIONS_ENTITY_TYPE_LIST.includes(dataRecord.entityTypeId) &&
<button type="button" className="uparrow" data-bs-toggle="dropdown" aria-expanded="false">
<span className="caret"></span>
</button>
}
<ul data-drupal-selector="edit-entities-1-operations-data"
className="dropbutton dropdown-menu"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment