mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 03:30:02 -03:30
Display a "Deleted" label for prompt view node details
This commit is contained in:
22
awx/ui_next/src/components/DetailList/MissingDetail.jsx
Normal file
22
awx/ui_next/src/components/DetailList/MissingDetail.jsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { withI18n } from '@lingui/react';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
|
import { node } from 'prop-types';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import _Detail from './Detail';
|
||||||
|
|
||||||
|
const Detail = styled(_Detail)`
|
||||||
|
dd& {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
function MissingDetail({ i18n, label }) {
|
||||||
|
return <Detail label={label} value={i18n._(t`Deleted`)} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
MissingDetail.propTypes = {
|
||||||
|
label: node.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withI18n()(MissingDetail);
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
export { default as DetailList } from './DetailList';
|
export { default as DetailList } from './DetailList';
|
||||||
export { default as Detail, DetailName, DetailValue } from './Detail';
|
export { default as Detail, DetailName, DetailValue } from './Detail';
|
||||||
|
export { default as MissingDetail } from './MissingDetail';
|
||||||
export { default as UserDateDetail } from './UserDateDetail';
|
export { default as UserDateDetail } from './UserDateDetail';
|
||||||
|
|||||||
@@ -34,6 +34,21 @@ function formatTimeout(timeout) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildResourceLink(resource) {
|
||||||
|
const link = {
|
||||||
|
job_template: `/templates/job_template/${resource.id}/details`,
|
||||||
|
project: `/projects/${resource.id}/details`,
|
||||||
|
inventory_source: `/inventories/inventory/${resource.inventory}/sources/${resource.id}/details`,
|
||||||
|
workflow_job_template: `/templates/workflow_job_template/${resource.id}/details`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return link[(resource?.type)] ? (
|
||||||
|
<Link to={link[resource.type]}>{resource.name}</Link>
|
||||||
|
) : (
|
||||||
|
resource.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function hasPromptData(launchData) {
|
function hasPromptData(launchData) {
|
||||||
return (
|
return (
|
||||||
launchData.ask_credential_on_launch ||
|
launchData.ask_credential_on_launch ||
|
||||||
@@ -150,7 +165,7 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DetailList gutter="sm">
|
<DetailList gutter="sm">
|
||||||
<Detail label={i18n._(t`Name`)} value={details.name} />
|
<Detail label={i18n._(t`Name`)} value={buildResourceLink(resource)} />
|
||||||
<Detail label={i18n._(t`Description`)} value={details.description} />
|
<Detail label={i18n._(t`Description`)} value={details.description} />
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Type`)}
|
label={i18n._(t`Type`)}
|
||||||
@@ -160,19 +175,6 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
|
|||||||
label={i18n._(t`Timeout`)}
|
label={i18n._(t`Timeout`)}
|
||||||
value={formatTimeout(details?.timeout)}
|
value={formatTimeout(details?.timeout)}
|
||||||
/>
|
/>
|
||||||
{details?.summary_fields?.organization && (
|
|
||||||
<Detail
|
|
||||||
label={i18n._(t`Organization`)}
|
|
||||||
value={
|
|
||||||
<Link
|
|
||||||
to={`/organizations/${details?.summary_fields.organization.id}/details`}
|
|
||||||
>
|
|
||||||
{details?.summary_fields?.organization.name}
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{details?.type === 'project' && (
|
{details?.type === 'project' && (
|
||||||
<PromptProjectDetail resource={details} />
|
<PromptProjectDetail resource={details} />
|
||||||
)}
|
)}
|
||||||
@@ -185,17 +187,20 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
|
|||||||
{details?.type === 'workflow_job_template' && (
|
{details?.type === 'workflow_job_template' && (
|
||||||
<PromptWFJobTemplateDetail resource={details} />
|
<PromptWFJobTemplateDetail resource={details} />
|
||||||
)}
|
)}
|
||||||
|
{details?.created && (
|
||||||
<UserDateDetail
|
<UserDateDetail
|
||||||
label={i18n._(t`Created`)}
|
label={i18n._(t`Created`)}
|
||||||
date={details?.created}
|
date={details.created}
|
||||||
user={details?.summary_fields?.created_by}
|
user={details?.summary_fields?.created_by}
|
||||||
/>
|
/>
|
||||||
<UserDateDetail
|
)}
|
||||||
label={i18n._(t`Last Modified`)}
|
{details?.modified && (
|
||||||
date={details?.modified}
|
<UserDateDetail
|
||||||
user={details?.summary_fields?.modified_by}
|
label={i18n._(t`Last Modified`)}
|
||||||
/>
|
date={details?.modified}
|
||||||
|
user={details?.summary_fields?.modified_by}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
|
|
||||||
{hasPromptData(launchConfig) && hasOverrides && (
|
{hasPromptData(launchConfig) && hasOverrides && (
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Chip, ChipGroup, List, ListItem } from '@patternfly/react-core';
|
import { Chip, ChipGroup, List, ListItem } from '@patternfly/react-core';
|
||||||
import { Detail } from '@components/DetailList';
|
import { Detail, MissingDetail } from '@components/DetailList';
|
||||||
import { VariablesDetail } from '@components/CodeMirrorInput';
|
import { VariablesDetail } from '@components/CodeMirrorInput';
|
||||||
import CredentialChip from '@components/CredentialChip';
|
import CredentialChip from '@components/CredentialChip';
|
||||||
|
|
||||||
@@ -57,6 +57,20 @@ function PromptInventorySourceDetail({ i18n, resource }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{summary_fields?.organization ? (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Organization`)}
|
||||||
|
value={
|
||||||
|
<Link
|
||||||
|
to={`/organizations/${summary_fields.organization.id}/details`}
|
||||||
|
>
|
||||||
|
{summary_fields?.organization.name}
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<MissingDetail label={i18n._(t`Organization`)} />
|
||||||
|
)}
|
||||||
{summary_fields?.inventory && (
|
{summary_fields?.inventory && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Inventory`)}
|
label={i18n._(t`Inventory`)}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { t } from '@lingui/macro';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Chip, ChipGroup, List, ListItem } from '@patternfly/react-core';
|
import { Chip, ChipGroup, List, ListItem } from '@patternfly/react-core';
|
||||||
import { Detail } from '@components/DetailList';
|
import { Detail, MissingDetail } from '@components/DetailList';
|
||||||
import { VariablesDetail } from '@components/CodeMirrorInput';
|
import { VariablesDetail } from '@components/CodeMirrorInput';
|
||||||
import CredentialChip from '@components/CredentialChip';
|
import CredentialChip from '@components/CredentialChip';
|
||||||
import Sparkline from '@components/Sparkline';
|
import Sparkline from '@components/Sparkline';
|
||||||
@@ -13,6 +13,7 @@ import { toTitleCase } from '@util/strings';
|
|||||||
function PromptJobTemplateDetail({ i18n, resource }) {
|
function PromptJobTemplateDetail({ i18n, resource }) {
|
||||||
const {
|
const {
|
||||||
allow_simultaneous,
|
allow_simultaneous,
|
||||||
|
ask_inventory_on_launch,
|
||||||
become_enabled,
|
become_enabled,
|
||||||
diff_mode,
|
diff_mode,
|
||||||
extra_vars,
|
extra_vars,
|
||||||
@@ -84,7 +85,21 @@ function PromptJobTemplateDetail({ i18n, resource }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Detail label={i18n._(t`Job Type`)} value={toTitleCase(job_type)} />
|
<Detail label={i18n._(t`Job Type`)} value={toTitleCase(job_type)} />
|
||||||
{summary_fields?.inventory && (
|
{summary_fields?.organization ? (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Organization`)}
|
||||||
|
value={
|
||||||
|
<Link
|
||||||
|
to={`/organizations/${summary_fields.organization.id}/details`}
|
||||||
|
>
|
||||||
|
{summary_fields?.organization.name}
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<MissingDetail label={i18n._(t`Organization`)} />
|
||||||
|
)}
|
||||||
|
{summary_fields?.inventory ? (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Inventory`)}
|
label={i18n._(t`Inventory`)}
|
||||||
value={
|
value={
|
||||||
@@ -95,8 +110,12 @@ function PromptJobTemplateDetail({ i18n, resource }) {
|
|||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
!ask_inventory_on_launch && (
|
||||||
|
<MissingDetail label={i18n._(t`Inventory`)} />
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
{summary_fields?.project && (
|
{summary_fields?.project ? (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Project`)}
|
label={i18n._(t`Project`)}
|
||||||
value={
|
value={
|
||||||
@@ -105,6 +124,8 @@ function PromptJobTemplateDetail({ i18n, resource }) {
|
|||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<MissingDetail label={i18n._(t`Project`)} />
|
||||||
)}
|
)}
|
||||||
<Detail label={i18n._(t`Source Control Branch`)} value={scm_branch} />
|
<Detail label={i18n._(t`Source Control Branch`)} value={scm_branch} />
|
||||||
<Detail label={i18n._(t`Playbook`)} value={playbook} />
|
<Detail label={i18n._(t`Playbook`)} value={playbook} />
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import { withI18n } from '@lingui/react';
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Config } from '@contexts/Config';
|
import { Config } from '@contexts/Config';
|
||||||
import { List, ListItem } from '@patternfly/react-core';
|
import { List, ListItem } from '@patternfly/react-core';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Detail } from '@components/DetailList';
|
import { Detail, MissingDetail } from '@components/DetailList';
|
||||||
import CredentialChip from '@components/CredentialChip';
|
import CredentialChip from '@components/CredentialChip';
|
||||||
import { toTitleCase } from '@util/strings';
|
import { toTitleCase } from '@util/strings';
|
||||||
|
|
||||||
@@ -49,6 +50,20 @@ function PromptProjectDetail({ i18n, resource }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{summary_fields?.organization ? (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Organization`)}
|
||||||
|
value={
|
||||||
|
<Link
|
||||||
|
to={`/organizations/${summary_fields.organization.id}/details`}
|
||||||
|
>
|
||||||
|
{summary_fields?.organization.name}
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<MissingDetail label={i18n._(t`Organization`)} />
|
||||||
|
)}
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Source Control Type`)}
|
label={i18n._(t`Source Control Type`)}
|
||||||
value={scm_type === '' ? i18n._(t`Manual`) : toTitleCase(scm_type)}
|
value={scm_type === '' ? i18n._(t`Manual`) : toTitleCase(scm_type)}
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ function PromptWFJobTemplateDetail({ i18n, resource }) {
|
|||||||
label={i18n._(t`Activity`)}
|
label={i18n._(t`Activity`)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{summary_fields?.organization && (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Organization`)}
|
||||||
|
value={
|
||||||
|
<Link
|
||||||
|
to={`/organizations/${summary_fields.organization.id}/details`}
|
||||||
|
>
|
||||||
|
{summary_fields?.organization.name}
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{summary_fields?.inventory && (
|
{summary_fields?.inventory && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Inventory`)}
|
label={i18n._(t`Inventory`)}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
TextListItemVariants,
|
TextListItemVariants,
|
||||||
TextListVariants,
|
TextListVariants,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import styled from 'styled-components';
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import AlertModal from '@components/AlertModal';
|
import AlertModal from '@components/AlertModal';
|
||||||
@@ -18,19 +17,18 @@ import { CardBody, CardActionsRow } from '@components/Card';
|
|||||||
import ContentError from '@components/ContentError';
|
import ContentError from '@components/ContentError';
|
||||||
import ContentLoading from '@components/ContentLoading';
|
import ContentLoading from '@components/ContentLoading';
|
||||||
import CredentialChip from '@components/CredentialChip';
|
import CredentialChip from '@components/CredentialChip';
|
||||||
import { DetailList, Detail, UserDateDetail } from '@components/DetailList';
|
import {
|
||||||
|
Detail,
|
||||||
|
DetailList,
|
||||||
|
MissingDetail,
|
||||||
|
UserDateDetail,
|
||||||
|
} from '@components/DetailList';
|
||||||
import DeleteButton from '@components/DeleteButton';
|
import DeleteButton from '@components/DeleteButton';
|
||||||
import ErrorDetail from '@components/ErrorDetail';
|
import ErrorDetail from '@components/ErrorDetail';
|
||||||
import LaunchButton from '@components/LaunchButton';
|
import LaunchButton from '@components/LaunchButton';
|
||||||
import { VariablesDetail } from '@components/CodeMirrorInput';
|
import { VariablesDetail } from '@components/CodeMirrorInput';
|
||||||
import { JobTemplatesAPI } from '@api';
|
import { JobTemplatesAPI } from '@api';
|
||||||
|
|
||||||
const MissingDetail = styled(Detail)`
|
|
||||||
dd& {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
function JobTemplateDetail({ i18n, template }) {
|
function JobTemplateDetail({ i18n, template }) {
|
||||||
const {
|
const {
|
||||||
ask_inventory_on_launch,
|
ask_inventory_on_launch,
|
||||||
@@ -133,10 +131,6 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
</TextList>
|
</TextList>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderMissingDataDetail = value => (
|
|
||||||
<MissingDetail label={value} value={i18n._(t`Deleted`)} />
|
|
||||||
);
|
|
||||||
|
|
||||||
const inventoryValue = (kind, id) => {
|
const inventoryValue = (kind, id) => {
|
||||||
const inventorykind = kind === 'smart' ? 'smart_inventory' : 'inventory';
|
const inventorykind = kind === 'smart' ? 'smart_inventory' : 'inventory';
|
||||||
|
|
||||||
@@ -180,7 +174,7 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
renderMissingDataDetail(i18n._(t`Project`))
|
<MissingDetail label={i18n._(t`Organization`)} />
|
||||||
)}
|
)}
|
||||||
{summary_fields.inventory ? (
|
{summary_fields.inventory ? (
|
||||||
<Detail
|
<Detail
|
||||||
@@ -191,8 +185,9 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
!ask_inventory_on_launch &&
|
!ask_inventory_on_launch && (
|
||||||
renderMissingDataDetail(i18n._(t`Inventory`))
|
<MissingDetail label={i18n._(t`Inventory`)} />
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
{summary_fields.project ? (
|
{summary_fields.project ? (
|
||||||
<Detail
|
<Detail
|
||||||
@@ -204,7 +199,7 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
renderMissingDataDetail(i18n._(t`Project`))
|
<MissingDetail label={i18n._(t`Project`)} />
|
||||||
)}
|
)}
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Source Control Branch`)}
|
label={i18n._(t`Source Control Branch`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user