mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
Moves TemplateListItem to a functional component
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
DataListItem,
|
DataListItem,
|
||||||
@@ -22,7 +22,6 @@ import ListActionButton from '@components/ListActionButton';
|
|||||||
import VerticalSeparator from '@components/VerticalSeparator';
|
import VerticalSeparator from '@components/VerticalSeparator';
|
||||||
import { Sparkline } from '@components/Sparkline';
|
import { Sparkline } from '@components/Sparkline';
|
||||||
import { toTitleCase } from '@util/strings';
|
import { toTitleCase } from '@util/strings';
|
||||||
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const rightStyle = `
|
const rightStyle = `
|
||||||
@@ -51,17 +50,18 @@ const LeftDataListCell = styled(DataListCell)`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const RightDataListCell = styled(DataListCell)`
|
const RightDataListCell = styled(DataListCell)`
|
||||||
${rightStyle}
|
${rightStyle}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const RightActionButtonCell = styled(ActionButtonCell)`
|
const RightActionButtonCell = styled(ActionButtonCell)`
|
||||||
${rightStyle}
|
${rightStyle}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
class TemplateListItem extends Component {
|
function TemplateListItem({ i18n, template, isSelected, onSelect }) {
|
||||||
render() {
|
|
||||||
const { i18n, template, isSelected, onSelect } = this.props;
|
|
||||||
const canLaunch = template.summary_fields.user_capabilities.start;
|
const canLaunch = template.summary_fields.user_capabilities.start;
|
||||||
|
|
||||||
const missingResourceIcon =
|
const missingResourceIcon =
|
||||||
template.type === 'job_template' &&
|
template.type === 'job_template' &&
|
||||||
(!template.summary_fields.project ||
|
(!template.summary_fields.project ||
|
||||||
@@ -110,11 +110,7 @@ class TemplateListItem extends Component {
|
|||||||
>
|
>
|
||||||
{toTitleCase(template.type)}
|
{toTitleCase(template.type)}
|
||||||
</RightDataListCell>,
|
</RightDataListCell>,
|
||||||
<RightDataListCell
|
<RightDataListCell css="flex: 1;" righthalf="true" key="sparkline">
|
||||||
css="flex: 1;"
|
|
||||||
righthalf="true"
|
|
||||||
key="sparkline"
|
|
||||||
>
|
|
||||||
<Sparkline jobs={template.summary_fields.recent_jobs} />
|
<Sparkline jobs={template.summary_fields.recent_jobs} />
|
||||||
</RightDataListCell>,
|
</RightDataListCell>,
|
||||||
<RightActionButtonCell
|
<RightActionButtonCell
|
||||||
@@ -127,10 +123,7 @@ class TemplateListItem extends Component {
|
|||||||
<Tooltip content={i18n._(t`Launch Template`)} position="top">
|
<Tooltip content={i18n._(t`Launch Template`)} position="top">
|
||||||
<LaunchButton resource={template}>
|
<LaunchButton resource={template}>
|
||||||
{({ handleLaunch }) => (
|
{({ handleLaunch }) => (
|
||||||
<ListActionButton
|
<ListActionButton variant="plain" onClick={handleLaunch}>
|
||||||
variant="plain"
|
|
||||||
onClick={handleLaunch}
|
|
||||||
>
|
|
||||||
<RocketIcon />
|
<RocketIcon />
|
||||||
</ListActionButton>
|
</ListActionButton>
|
||||||
)}
|
)}
|
||||||
@@ -155,6 +148,6 @@ class TemplateListItem extends Component {
|
|||||||
</DataListItem>
|
</DataListItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
export { TemplateListItem as _TemplateListItem };
|
export { TemplateListItem as _TemplateListItem };
|
||||||
export default withI18n()(TemplateListItem);
|
export default withI18n()(TemplateListItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user