From 44db9ad033d1b0829f2d24eb6299eb839673c431 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Thu, 23 Jan 2020 11:00:50 -0500 Subject: [PATCH] Moves TemplateListItem to a functional component --- .../TemplateList/TemplateListItem.jsx | 185 +++++++++--------- 1 file changed, 89 insertions(+), 96 deletions(-) diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx index bba635470f..51bb28c28b 100644 --- a/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateListItem.jsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React from 'react'; import { Link } from 'react-router-dom'; import { DataListItem, @@ -22,7 +22,6 @@ import ListActionButton from '@components/ListActionButton'; import VerticalSeparator from '@components/VerticalSeparator'; import { Sparkline } from '@components/Sparkline'; import { toTitleCase } from '@util/strings'; - import styled from 'styled-components'; const rightStyle = ` @@ -51,110 +50,104 @@ const LeftDataListCell = styled(DataListCell)` } } `; + const RightDataListCell = styled(DataListCell)` ${rightStyle} `; + const RightActionButtonCell = styled(ActionButtonCell)` ${rightStyle} `; -class TemplateListItem extends Component { - render() { - const { i18n, template, isSelected, onSelect } = this.props; - const canLaunch = template.summary_fields.user_capabilities.start; - const missingResourceIcon = - template.type === 'job_template' && - (!template.summary_fields.project || - (!template.summary_fields.inventory && - !template.ask_inventory_on_launch)); +function TemplateListItem({ i18n, template, isSelected, onSelect }) { + const canLaunch = template.summary_fields.user_capabilities.start; - return ( - - - - - + const missingResourceIcon = + template.type === 'job_template' && + (!template.summary_fields.project || + (!template.summary_fields.inventory && + !template.ask_inventory_on_launch)); + + return ( + + + + + + + + {template.name} + + + {missingResourceIcon && ( - - {template.name} - + + + - {missingResourceIcon && ( - - - - - - )} - , - - {toTitleCase(template.type)} - , - - - , - - {canLaunch && template.type === 'job_template' && ( - - - {({ handleLaunch }) => ( - - - - )} - - - )} - {template.summary_fields.user_capabilities.edit && ( - - - - - - )} - , - ]} - /> - - - ); - } + )} + , + + {toTitleCase(template.type)} + , + + + , + + {canLaunch && template.type === 'job_template' && ( + + + {({ handleLaunch }) => ( + + + + )} + + + )} + {template.summary_fields.user_capabilities.edit && ( + + + + + + )} + , + ]} + /> + + + ); } + export { TemplateListItem as _TemplateListItem }; export default withI18n()(TemplateListItem);