mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 19:37:38 -02:30
add ArrayDetail
This commit is contained in:
35
awx/ui_next/src/components/DetailList/ArrayDetail.jsx
Normal file
35
awx/ui_next/src/components/DetailList/ArrayDetail.jsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import 'styled-components/macro';
|
||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { TextListItemVariants } from '@patternfly/react-core';
|
||||||
|
import { DetailName, DetailValue } from './Detail';
|
||||||
|
|
||||||
|
const Value = styled(DetailValue)`
|
||||||
|
margin-top: var(--pf-global--spacer--xs);
|
||||||
|
padding: var(--pf-global--spacer--xs);
|
||||||
|
border: 1px solid var(--pf-global--BorderColor--100);
|
||||||
|
max-height: 5.5em;
|
||||||
|
overflow: auto;
|
||||||
|
`;
|
||||||
|
|
||||||
|
function ArrayDetail({ label, value, dataCy }) {
|
||||||
|
const labelCy = dataCy ? `${dataCy}-label` : null;
|
||||||
|
const valueCy = dataCy ? `${dataCy}-value` : null;
|
||||||
|
|
||||||
|
const vals = Array.isArray(value) ? value : [value];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div css="grid-column: span 2">
|
||||||
|
<DetailName component={TextListItemVariants.dt} data-cy={labelCy}>
|
||||||
|
{label}
|
||||||
|
</DetailName>
|
||||||
|
<Value component={TextListItemVariants.dd} data-cy={valueCy}>
|
||||||
|
{vals.map(v => (
|
||||||
|
<div>{v}</div>
|
||||||
|
))}
|
||||||
|
</Value>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ArrayDetail;
|
||||||
@@ -11,7 +11,7 @@ const DetailList = ({ children, stacked, ...props }) => (
|
|||||||
export default styled(DetailList)`
|
export default styled(DetailList)`
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
align-items: center;
|
align-items: start;
|
||||||
${props =>
|
${props =>
|
||||||
props.stacked
|
props.stacked
|
||||||
? `
|
? `
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export { default as Detail, DetailName, DetailValue } from './Detail';
|
|||||||
export { default as DeletedDetail } from './DeletedDetail';
|
export { default as DeletedDetail } from './DeletedDetail';
|
||||||
export { default as UserDateDetail } from './UserDateDetail';
|
export { default as UserDateDetail } from './UserDateDetail';
|
||||||
export { default as DetailBadge } from './DetailBadge';
|
export { default as DetailBadge } from './DetailBadge';
|
||||||
|
export { default as ArrayDetail } from './ArrayDetail';
|
||||||
/*
|
/*
|
||||||
NOTE: ObjectDetail cannot be imported here, as it causes circular
|
NOTE: ObjectDetail cannot be imported here, as it causes circular
|
||||||
dependencies in testing environment. Import it directly from
|
dependencies in testing environment. Import it directly from
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import AlertModal from '../../../components/AlertModal';
|
|||||||
import { CardBody, CardActionsRow } from '../../../components/Card';
|
import { CardBody, CardActionsRow } from '../../../components/Card';
|
||||||
import {
|
import {
|
||||||
Detail,
|
Detail,
|
||||||
|
ArrayDetail,
|
||||||
DetailList,
|
DetailList,
|
||||||
DeletedDetail,
|
DeletedDetail,
|
||||||
} from '../../../components/DetailList';
|
} from '../../../components/DetailList';
|
||||||
@@ -81,9 +82,9 @@ function NotificationTemplateDetail({ i18n, template }) {
|
|||||||
value={configuration.host}
|
value={configuration.host}
|
||||||
dataCy="nt-detail-host"
|
dataCy="nt-detail-host"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<ArrayDetail
|
||||||
label={i18n._(t`Recipient List`)}
|
label={i18n._(t`Recipient List`)}
|
||||||
value={configuration.recipients} // array
|
value={configuration.recipients}
|
||||||
dataCy="nt-detail-recipients"
|
dataCy="nt-detail-recipients"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
@@ -127,9 +128,9 @@ function NotificationTemplateDetail({ i18n, template }) {
|
|||||||
value={configuration.panelId}
|
value={configuration.panelId}
|
||||||
dataCy="nt-detail-panel-id"
|
dataCy="nt-detail-panel-id"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<ArrayDetail
|
||||||
label={i18n._(t`Tags for the Annotation`)}
|
label={i18n._(t`Tags for the Annotation`)}
|
||||||
value={configuration.annotation_tags} // array
|
value={configuration.annotation_tags}
|
||||||
dataCy="nt-detail-"
|
dataCy="nt-detail-"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
@@ -160,9 +161,9 @@ function NotificationTemplateDetail({ i18n, template }) {
|
|||||||
value={configuration.nickname}
|
value={configuration.nickname}
|
||||||
dataCy="nt-detail-irc-nickname"
|
dataCy="nt-detail-irc-nickname"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<ArrayDetail
|
||||||
label={i18n._(t`Destination Channels or Users`)}
|
label={i18n._(t`Destination Channels or Users`)}
|
||||||
value={configuration.targets} // array
|
value={configuration.targets}
|
||||||
dataCy="nt-detail-channels"
|
dataCy="nt-detail-channels"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
@@ -254,9 +255,9 @@ function NotificationTemplateDetail({ i18n, template }) {
|
|||||||
)}
|
)}
|
||||||
{template.notification_type === 'slack' && (
|
{template.notification_type === 'slack' && (
|
||||||
<>
|
<>
|
||||||
<Detail
|
<ArrayDetail
|
||||||
label={i18n._(t`Destination Channels`)}
|
label={i18n._(t`Destination Channels`)}
|
||||||
value={configuration.channels} // array
|
value={configuration.channels}
|
||||||
dataCy="nt-detail-slack-channels"
|
dataCy="nt-detail-slack-channels"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
@@ -273,9 +274,9 @@ function NotificationTemplateDetail({ i18n, template }) {
|
|||||||
value={configuration.from_number}
|
value={configuration.from_number}
|
||||||
dataCy="nt-detail-twilio-source-phone"
|
dataCy="nt-detail-twilio-source-phone"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<ArrayDetail
|
||||||
label={i18n._(t`Destination SMS Number`)}
|
label={i18n._(t`Destination SMS Number`)}
|
||||||
value={configuration.to_numbers} // array
|
value={configuration.to_numbers}
|
||||||
dataCy="nt-detail-twilio-destination-numbers"
|
dataCy="nt-detail-twilio-destination-numbers"
|
||||||
/>
|
/>
|
||||||
<Detail
|
<Detail
|
||||||
|
|||||||
Reference in New Issue
Block a user