From 95cdddd6706e7640ab4ca9489840ae33ca57659f Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Mon, 11 Nov 2019 14:00:06 -0500 Subject: [PATCH] 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. --- .../AddDropDownButton/AddDropDownButton.jsx | 12 +++++++++++- .../Inventory/InventoryList/InventoryList.jsx | 2 -- .../screens/Template/TemplateList/TemplateList.jsx | 2 -- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx b/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx index 9296fc1f17..288a30733f 100644 --- a/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx +++ b/awx/ui_next/src/components/AddDropDownButton/AddDropDownButton.jsx @@ -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 => ( {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; diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx index da87e832b9..59e63a9b35 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryList/InventoryList.jsx @@ -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/`, }, diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx index 8e04c480f5..7a087f88fe 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx @@ -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/`, },