mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Merge pull request #149 from marshmalien/org-details-ig-show-more-less
Update Org Details UX layout
This commit is contained in:
commit
2062124a92
@ -4,16 +4,18 @@ import PropTypes from 'prop-types';
|
||||
import { Chip } from '@patternfly/react-core';
|
||||
import './basicChip.scss';
|
||||
|
||||
const BasicChip = ({ text }) => (
|
||||
const BasicChip = ({ children, onToggle, isOverflowChip }) => (
|
||||
<Chip
|
||||
className="awx-c-chip--basic"
|
||||
onClick={onToggle}
|
||||
isOverflowChip={isOverflowChip}
|
||||
>
|
||||
{text}
|
||||
{children}
|
||||
</Chip>
|
||||
);
|
||||
|
||||
BasicChip.propTypes = {
|
||||
text: PropTypes.string.isRequired,
|
||||
children: PropTypes.node.isRequired,
|
||||
};
|
||||
|
||||
export default BasicChip;
|
||||
|
||||
@ -4,7 +4,15 @@
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.pf-c-button {
|
||||
&.pf-c-chip {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
&.pf-m-overflow {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
&:not(.pf-m-overflow) .pf-c-button {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,9 +47,11 @@ class OrganizationDetail extends Component {
|
||||
|
||||
this.state = {
|
||||
instanceGroups: [],
|
||||
isToggleOpen: false,
|
||||
error: false
|
||||
};
|
||||
|
||||
this.handleChipToggle = this.handleChipToggle.bind(this);
|
||||
this.loadInstanceGroups = this.loadInstanceGroups.bind(this);
|
||||
}
|
||||
|
||||
@ -57,6 +59,12 @@ class OrganizationDetail extends Component {
|
||||
this.loadInstanceGroups();
|
||||
}
|
||||
|
||||
handleChipToggle = () => {
|
||||
this.setState((prevState) => ({
|
||||
isToggleOpen: !prevState.isToggleOpen
|
||||
}));
|
||||
}
|
||||
|
||||
async loadInstanceGroups () {
|
||||
const {
|
||||
api,
|
||||
@ -78,6 +86,7 @@ class OrganizationDetail extends Component {
|
||||
const {
|
||||
error,
|
||||
instanceGroups,
|
||||
isToggleOpen,
|
||||
} = this.state;
|
||||
|
||||
const {
|
||||
@ -90,6 +99,26 @@ class OrganizationDetail extends Component {
|
||||
},
|
||||
match
|
||||
} = this.props;
|
||||
const showOverflowChipAfter = 5;
|
||||
|
||||
const instanceGroupChips = instanceGroups.slice(0, isToggleOpen
|
||||
? instanceGroups.length : showOverflowChipAfter)
|
||||
.map(instanceGroup => (
|
||||
<BasicChip
|
||||
key={instanceGroup.id}
|
||||
>
|
||||
{instanceGroup.name}
|
||||
</BasicChip>
|
||||
));
|
||||
|
||||
const overflowChip = (instanceGroups.length > showOverflowChipAfter) ? (
|
||||
<BasicChip
|
||||
isOverflowChip
|
||||
onToggle={this.handleChipToggle}
|
||||
>
|
||||
{isToggleOpen ? 'Show less' : `${(instanceGroups.length - showOverflowChipAfter).toString()} more`}
|
||||
</BasicChip>
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<I18n>
|
||||
@ -104,24 +133,6 @@ class OrganizationDetail extends Component {
|
||||
label={i18n._(t`Description`)}
|
||||
value={description}
|
||||
/>
|
||||
{(instanceGroups && instanceGroups.length > 0) && (
|
||||
<TextContent style={detailWrapperStyle}>
|
||||
<Text
|
||||
component={TextVariants.h6}
|
||||
style={detailLabelStyle}
|
||||
>
|
||||
<Trans>Instance Groups</Trans>
|
||||
</Text>
|
||||
<div style={detailValueStyle}>
|
||||
{instanceGroups.map(instanceGroup => (
|
||||
<BasicChip
|
||||
key={instanceGroup.id}
|
||||
text={instanceGroup.name}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</TextContent>
|
||||
)}
|
||||
<Detail
|
||||
label={i18n._(t`Ansible Environment`)}
|
||||
value={custom_virtualenv}
|
||||
@ -134,6 +145,20 @@ class OrganizationDetail extends Component {
|
||||
label={i18n._(t`Last Modified`)}
|
||||
value={modified}
|
||||
/>
|
||||
{(instanceGroups && instanceGroups.length > 0) && (
|
||||
<TextContent style={{ display: 'flex', gridColumn: '1 / -1' }}>
|
||||
<Text
|
||||
component={TextVariants.h6}
|
||||
style={detailLabelStyle}
|
||||
>
|
||||
<Trans>Instance Groups</Trans>
|
||||
</Text>
|
||||
<div style={detailValueStyle}>
|
||||
{instanceGroupChips}
|
||||
{overflowChip}
|
||||
</div>
|
||||
</TextContent>
|
||||
)}
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'row-reverse', marginTop: '20px' }}>
|
||||
<Link to={`/organizations/${match.params.id}/edit`}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user