mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Merge pull request #149 from marshmalien/org-details-ig-show-more-less
Update Org Details UX layout
This commit is contained in:
@@ -4,16 +4,18 @@ import PropTypes from 'prop-types';
|
|||||||
import { Chip } from '@patternfly/react-core';
|
import { Chip } from '@patternfly/react-core';
|
||||||
import './basicChip.scss';
|
import './basicChip.scss';
|
||||||
|
|
||||||
const BasicChip = ({ text }) => (
|
const BasicChip = ({ children, onToggle, isOverflowChip }) => (
|
||||||
<Chip
|
<Chip
|
||||||
className="awx-c-chip--basic"
|
className="awx-c-chip--basic"
|
||||||
|
onClick={onToggle}
|
||||||
|
isOverflowChip={isOverflowChip}
|
||||||
>
|
>
|
||||||
{text}
|
{children}
|
||||||
</Chip>
|
</Chip>
|
||||||
);
|
);
|
||||||
|
|
||||||
BasicChip.propTypes = {
|
BasicChip.propTypes = {
|
||||||
text: PropTypes.string.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BasicChip;
|
export default BasicChip;
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
margin-bottom: 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;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,11 @@ class OrganizationDetail extends Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
instanceGroups: [],
|
instanceGroups: [],
|
||||||
|
isToggleOpen: false,
|
||||||
error: false
|
error: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.handleChipToggle = this.handleChipToggle.bind(this);
|
||||||
this.loadInstanceGroups = this.loadInstanceGroups.bind(this);
|
this.loadInstanceGroups = this.loadInstanceGroups.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +59,12 @@ class OrganizationDetail extends Component {
|
|||||||
this.loadInstanceGroups();
|
this.loadInstanceGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleChipToggle = () => {
|
||||||
|
this.setState((prevState) => ({
|
||||||
|
isToggleOpen: !prevState.isToggleOpen
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
async loadInstanceGroups () {
|
async loadInstanceGroups () {
|
||||||
const {
|
const {
|
||||||
api,
|
api,
|
||||||
@@ -78,6 +86,7 @@ class OrganizationDetail extends Component {
|
|||||||
const {
|
const {
|
||||||
error,
|
error,
|
||||||
instanceGroups,
|
instanceGroups,
|
||||||
|
isToggleOpen,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -90,6 +99,26 @@ class OrganizationDetail extends Component {
|
|||||||
},
|
},
|
||||||
match
|
match
|
||||||
} = this.props;
|
} = 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 (
|
return (
|
||||||
<I18n>
|
<I18n>
|
||||||
@@ -104,24 +133,6 @@ class OrganizationDetail extends Component {
|
|||||||
label={i18n._(t`Description`)}
|
label={i18n._(t`Description`)}
|
||||||
value={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
|
<Detail
|
||||||
label={i18n._(t`Ansible Environment`)}
|
label={i18n._(t`Ansible Environment`)}
|
||||||
value={custom_virtualenv}
|
value={custom_virtualenv}
|
||||||
@@ -134,6 +145,20 @@ class OrganizationDetail extends Component {
|
|||||||
label={i18n._(t`Last Modified`)}
|
label={i18n._(t`Last Modified`)}
|
||||||
value={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>
|
||||||
<div style={{ display: 'flex', flexDirection: 'row-reverse', marginTop: '20px' }}>
|
<div style={{ display: 'flex', flexDirection: 'row-reverse', marginTop: '20px' }}>
|
||||||
<Link to={`/organizations/${match.params.id}/edit`}>
|
<Link to={`/organizations/${match.params.id}/edit`}>
|
||||||
|
|||||||
Reference in New Issue
Block a user