mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
Adds Proptypes to AddDropDownButton Component
Also refactors to use the url that is passed in as the key for the link. This means that we don't have to pass in a key value.
This commit is contained in:
parent
d91aa8c6cf
commit
95cdddd670
@ -1,5 +1,6 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Dropdown, DropdownPosition } from '@patternfly/react-core';
|
||||
import { ToolbarAddButton } from '@components/PaginatedDataList';
|
||||
|
||||
@ -30,7 +31,7 @@ function AddDropDownButton({ dropdownItems }) {
|
||||
dropdownItems={dropdownItems.map(item => (
|
||||
<Link
|
||||
className="pf-c-dropdown__menu-item"
|
||||
key={item.key}
|
||||
key={item.url}
|
||||
to={item.url}
|
||||
>
|
||||
{item.label}
|
||||
@ -41,5 +42,14 @@ function AddDropDownButton({ dropdownItems }) {
|
||||
);
|
||||
}
|
||||
|
||||
AddDropDownButton.propTypes = {
|
||||
dropdownItems: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
label: PropTypes.string.isRequired,
|
||||
url: PropTypes.string.isRequired,
|
||||
})
|
||||
).isRequired,
|
||||
};
|
||||
|
||||
export { AddDropDownButton as _AddDropDownButton };
|
||||
export default AddDropDownButton;
|
||||
|
||||
@ -152,12 +152,10 @@ class InventoriesList extends Component {
|
||||
key="add"
|
||||
dropdownItems={[
|
||||
{
|
||||
key: 'inventory',
|
||||
label: i18n._(t`Inventory`),
|
||||
url: `${match.url}/inventory/add/`,
|
||||
},
|
||||
{
|
||||
key: 'smart-inventory',
|
||||
label: i18n._(t`Smart Inventory`),
|
||||
url: `${match.url}/smart_inventory/add/`,
|
||||
},
|
||||
|
||||
@ -166,12 +166,10 @@ class TemplatesList extends Component {
|
||||
key="add"
|
||||
dropdownItems={[
|
||||
{
|
||||
key: 'template',
|
||||
label: i18n._(t`Template`),
|
||||
url: `${match.url}/template/add/`,
|
||||
},
|
||||
{
|
||||
key: 'workflow_template',
|
||||
label: i18n._(t`Workflow Template`),
|
||||
url: `${match.url}/_workflow/add/`,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user