mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Add label to show isolated group
Add label to show isolated group. See: https://tower-mockups.testing.ansible.com/patternfly/instance-groups/instance-groups/
This commit is contained in:
@@ -2,8 +2,8 @@ import React, { useCallback } from 'react';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useHistory } from 'react-router-dom';
|
||||||
import { Button } from '@patternfly/react-core';
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { Button, Label } from '@patternfly/react-core';
|
||||||
|
|
||||||
import AlertModal from '../../../components/AlertModal';
|
import AlertModal from '../../../components/AlertModal';
|
||||||
import { CardBody, CardActionsRow } from '../../../components/Card';
|
import { CardBody, CardActionsRow } from '../../../components/Card';
|
||||||
@@ -46,12 +46,28 @@ function InstanceGroupDetails({ instanceGroup, i18n }) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const verifyIsIsolated = item => {
|
||||||
|
if (item.is_isolated) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{item.name}
|
||||||
|
<span css="margin-left: 12px">
|
||||||
|
<Label aria-label={i18n._(t`isolated instance`)}>
|
||||||
|
{i18n._(t`Isolated`)}
|
||||||
|
</Label>
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <>{item.name}</>;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<DetailList>
|
<DetailList>
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Name`)}
|
label={i18n._(t`Name`)}
|
||||||
value={name}
|
value={verifyIsIsolated(instanceGroup)}
|
||||||
dataCy="instance-group-detail-name"
|
dataCy="instance-group-detail-name"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const instanceGroups = [
|
|||||||
policy_instance_percentage: 50,
|
policy_instance_percentage: 50,
|
||||||
percent_capacity_remaining: 60,
|
percent_capacity_remaining: 60,
|
||||||
is_containerized: false,
|
is_containerized: false,
|
||||||
|
is_isolated: false,
|
||||||
created: '2020-07-21T18:41:02.818081Z',
|
created: '2020-07-21T18:41:02.818081Z',
|
||||||
modified: '2020-07-24T20:32:03.121079Z',
|
modified: '2020-07-24T20:32:03.121079Z',
|
||||||
summary_fields: {
|
summary_fields: {
|
||||||
@@ -40,6 +41,7 @@ const instanceGroups = [
|
|||||||
policy_instance_percentage: 0,
|
policy_instance_percentage: 0,
|
||||||
percent_capacity_remaining: 0,
|
percent_capacity_remaining: 0,
|
||||||
is_containerized: true,
|
is_containerized: true,
|
||||||
|
is_isolated: false,
|
||||||
created: '2020-07-21T18:41:02.818081Z',
|
created: '2020-07-21T18:41:02.818081Z',
|
||||||
modified: '2020-07-24T20:32:03.121079Z',
|
modified: '2020-07-24T20:32:03.121079Z',
|
||||||
summary_fields: {
|
summary_fields: {
|
||||||
@@ -67,7 +69,11 @@ describe('<InstanceGroupDetails/>', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expectDetailToMatch(wrapper, 'Name', instanceGroups[0].name);
|
|
||||||
|
expect(wrapper.find('Detail[label="Name"]').text()).toEqual(
|
||||||
|
expect.stringContaining(instanceGroups[0].name)
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Detail[label="Name"]')).toHaveLength(1);
|
||||||
expectDetailToMatch(wrapper, 'Type', `Instance group`);
|
expectDetailToMatch(wrapper, 'Type', `Instance group`);
|
||||||
const dates = wrapper.find('UserDateDetail');
|
const dates = wrapper.find('UserDateDetail');
|
||||||
expect(dates).toHaveLength(2);
|
expect(dates).toHaveLength(2);
|
||||||
@@ -144,4 +150,18 @@ describe('<InstanceGroupDetails/>', () => {
|
|||||||
|
|
||||||
expect(wrapper.find('Button[aria-label="Edit"]').length).toBe(0);
|
expect(wrapper.find('Button[aria-label="Edit"]').length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should display isolated label', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<InstanceGroupDetails
|
||||||
|
instanceGroup={{ ...instanceGroups[0], is_isolated: true }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
wrapper.update();
|
||||||
|
expect(
|
||||||
|
wrapper.find('Label[aria-label="isolated instance"]').prop('children')
|
||||||
|
).toEqual('Isolated');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ import { Link } from 'react-router-dom';
|
|||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
import {
|
import {
|
||||||
Badge as PFBadge,
|
Badge as PFBadge,
|
||||||
Progress,
|
|
||||||
ProgressMeasureLocation,
|
|
||||||
ProgressSize,
|
|
||||||
Button,
|
Button,
|
||||||
DataListAction as _DataListAction,
|
DataListAction as _DataListAction,
|
||||||
DataListCheck,
|
DataListCheck,
|
||||||
DataListItem,
|
DataListItem,
|
||||||
DataListItemRow,
|
|
||||||
DataListItemCells,
|
DataListItemCells,
|
||||||
|
DataListItemRow,
|
||||||
|
Label,
|
||||||
|
Progress,
|
||||||
|
ProgressMeasureLocation,
|
||||||
|
ProgressSize,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { PencilAltIcon } from '@patternfly/react-icons';
|
import { PencilAltIcon } from '@patternfly/react-icons';
|
||||||
@@ -112,6 +113,13 @@ function InstanceGroupListItem({
|
|||||||
<b>{instanceGroup.name}</b>
|
<b>{instanceGroup.name}</b>
|
||||||
</Link>
|
</Link>
|
||||||
</span>
|
</span>
|
||||||
|
{instanceGroup.is_isolated ? (
|
||||||
|
<span css="margin-left: 12px">
|
||||||
|
<Label aria-label={i18n._(t`isolated instance`)}>
|
||||||
|
{i18n._(t`Isolated`)}
|
||||||
|
</Label>
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
|
|
||||||
<DataListCell
|
<DataListCell
|
||||||
|
|||||||
Reference in New Issue
Block a user