{
- const toggle = e => {
- if (!isKebabified && (!element || !element.current.contains(e.target))) {
- setIsOpen(false);
- }
- };
-
- document.addEventListener('click', toggle, false);
- return () => {
- document.removeEventListener('click', toggle);
- };
- }, [isKebabified]);
-
- if (isKebabified) {
- return (
-
- {dropdownItems.map(item => (
-
- {item.title}
-
- ))}
-
- );
- }
-
- return (
-
- setIsOpen(prevState => !prevState)}
- >
- {i18n._(t`Add`)}
-
- }
- dropdownItems={dropdownItems.map(item => (
-
- {item.title}
-
- ))}
- />
-
- );
-}
-
-AddDropdown.propTypes = {
- dropdownItems: arrayOf(
- shape({
- label: string.isRequired,
- onAdd: func.isRequired,
- key: string.isRequired,
- })
- ).isRequired,
-};
-
-export { AddDropdown as _AddDropdown };
-export default withI18n()(AddDropdown);
diff --git a/awx/ui_next/src/screens/Inventory/shared/AddDropdown.test.jsx b/awx/ui_next/src/screens/Inventory/shared/AddDropdown.test.jsx
deleted file mode 100644
index 39b291bc8f..0000000000
--- a/awx/ui_next/src/screens/Inventory/shared/AddDropdown.test.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import React from 'react';
-import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
-import AddDropdown from './AddDropdown';
-
-describe('', () => {
- let wrapper;
- let dropdownToggle;
- const dropdownItems = [
- {
- onAdd: () => {},
- title: 'Add existing group',
- label: 'group',
- key: 'existing',
- },
- {
- onAdd: () => {},
- title: 'Add new group',
- label: 'group',
- key: 'new',
- },
- ];
-
- beforeEach(() => {
- wrapper = mountWithContexts();
- dropdownToggle = wrapper.find('DropdownToggle button');
- });
-
- test('should initially render a closed dropdown', () => {
- expect(wrapper.find('DropdownItem').length).toBe(0);
- });
-
- test('should render two dropdown items', () => {
- dropdownToggle.simulate('click');
- expect(wrapper.find('DropdownItem').length).toBe(2);
- });
-
- test('should close when button re-clicked', () => {
- dropdownToggle.simulate('click');
- expect(wrapper.find('DropdownItem').length).toBe(2);
- dropdownToggle.simulate('click');
- expect(wrapper.find('DropdownItem').length).toBe(0);
- });
-});
diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
index a40def657d..e88e6ce4db 100644
--- a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
+++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
@@ -1,9 +1,8 @@
import React, { Fragment, useEffect, useState, useCallback } from 'react';
-import { useLocation } from 'react-router-dom';
+import { useLocation, Link } from 'react-router-dom';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
-import { Card } from '@patternfly/react-core';
-
+import { Card, DropdownItem } from '@patternfly/react-core';
import {
JobTemplatesAPI,
UnifiedJobTemplatesAPI,
@@ -17,6 +16,7 @@ import PaginatedDataList, {
} from '../../../components/PaginatedDataList';
import useRequest, { useDeleteItems } from '../../../util/useRequest';
import { getQSConfig, parseQueryString } from '../../../util/qs';
+import { toTitleCase } from '../../../util/strings';
import useWsTemplates from '../../../util/useWsTemplates';
import AddDropDownButton from '../../../components/AddDropDownButton';
import TemplateListItem from './TemplateListItem';
@@ -32,7 +32,6 @@ const QS_CONFIG = getQSConfig('template', {
function TemplateList({ i18n }) {
const location = useLocation();
-
const [selected, setSelected] = useState([]);
const {
@@ -134,24 +133,36 @@ function TemplateList({ i18n }) {
jtActions && Object.prototype.hasOwnProperty.call(jtActions, 'POST');
const canAddWFJT =
wfjtActions && Object.prototype.hasOwnProperty.call(wfjtActions, 'POST');
- const addButtonOptions = [];
+ const addTempate = toTitleCase(i18n._(t`Add Job Template`));
+ const addWFTemplate = toTitleCase(i18n._(t`Add Workflow Template`));
+ const addDropDownButton = [];
if (canAddJT) {
- addButtonOptions.push({
- label: i18n._(t`Job Template`),
- url: `/templates/job_template/add/`,
- });
+ addDropDownButton.push(
+
+ {addTempate}
+
+ );
}
-
if (canAddWFJT) {
- addButtonOptions.push({
- label: i18n._(t`Workflow Template`),
- url: `/templates/workflow_job_template/add/`,
- });
+ addDropDownButton.push(
+
+ {addWFTemplate}
+
+ );
}
-
const addButton = (
-
+
);
return (