From a2c3027bd7fa3f201fc5cfdc4d710b7843e98bc4 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Thu, 23 Apr 2020 13:08:16 -0400 Subject: [PATCH] Display a "Deleted" label for prompt view node details --- .../components/DetailList/MissingDetail.jsx | 22 ++++++++ .../src/components/DetailList/index.js | 1 + .../components/PromptDetail/PromptDetail.jsx | 55 ++++++++++--------- .../PromptInventorySourceDetail.jsx | 16 +++++- .../PromptDetail/PromptJobTemplateDetail.jsx | 27 ++++++++- .../PromptDetail/PromptProjectDetail.jsx | 17 +++++- .../PromptWFJobTemplateDetail.jsx | 12 ++++ .../JobTemplateDetail/JobTemplateDetail.jsx | 27 ++++----- 8 files changed, 131 insertions(+), 46 deletions(-) create mode 100644 awx/ui_next/src/components/DetailList/MissingDetail.jsx diff --git a/awx/ui_next/src/components/DetailList/MissingDetail.jsx b/awx/ui_next/src/components/DetailList/MissingDetail.jsx new file mode 100644 index 0000000000..94572413a0 --- /dev/null +++ b/awx/ui_next/src/components/DetailList/MissingDetail.jsx @@ -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 ; +} + +MissingDetail.propTypes = { + label: node.isRequired, +}; + +export default withI18n()(MissingDetail); diff --git a/awx/ui_next/src/components/DetailList/index.js b/awx/ui_next/src/components/DetailList/index.js index 4a5b77dbc0..820f353bf1 100644 --- a/awx/ui_next/src/components/DetailList/index.js +++ b/awx/ui_next/src/components/DetailList/index.js @@ -1,3 +1,4 @@ export { default as DetailList } from './DetailList'; export { default as Detail, DetailName, DetailValue } from './Detail'; +export { default as MissingDetail } from './MissingDetail'; export { default as UserDateDetail } from './UserDateDetail'; diff --git a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx index e2aa73ec6e..05ff230175 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx @@ -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)] ? ( + {resource.name} + ) : ( + resource.name + ); +} + function hasPromptData(launchData) { return ( launchData.ask_credential_on_launch || @@ -150,7 +165,7 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) { return ( <> - + - {details?.summary_fields?.organization && ( - - {details?.summary_fields?.organization.name} - - } - /> - )} - {details?.type === 'project' && ( )} @@ -185,17 +187,20 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) { {details?.type === 'workflow_job_template' && ( )} - - - + {details?.created && ( + + )} + {details?.modified && ( + + )} {hasPromptData(launchConfig) && hasOverrides && ( diff --git a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx index 6b385c5ef3..0b7b7c9243 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx @@ -4,7 +4,7 @@ import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; 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 CredentialChip from '@components/CredentialChip'; @@ -57,6 +57,20 @@ function PromptInventorySourceDetail({ i18n, resource }) { return ( <> + {summary_fields?.organization ? ( + + {summary_fields?.organization.name} + + } + /> + ) : ( + + )} {summary_fields?.inventory && ( )} - {summary_fields?.inventory && ( + {summary_fields?.organization ? ( + + {summary_fields?.organization.name} + + } + /> + ) : ( + + )} + {summary_fields?.inventory ? ( } /> + ) : ( + !ask_inventory_on_launch && ( + + ) )} - {summary_fields?.project && ( + {summary_fields?.project ? ( } /> + ) : ( + )} diff --git a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx index 577a706d7d..fe44985bd3 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx @@ -3,8 +3,9 @@ import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { Config } from '@contexts/Config'; 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 { toTitleCase } from '@util/strings'; @@ -49,6 +50,20 @@ function PromptProjectDetail({ i18n, resource }) { return ( <> + {summary_fields?.organization ? ( + + {summary_fields?.organization.name} + + } + /> + ) : ( + + )} )} + {summary_fields?.organization && ( + + {summary_fields?.organization.name} + + } + /> + )} {summary_fields?.inventory && ( ); - const renderMissingDataDetail = value => ( - - ); - const inventoryValue = (kind, id) => { const inventorykind = kind === 'smart' ? 'smart_inventory' : 'inventory'; @@ -180,7 +174,7 @@ function JobTemplateDetail({ i18n, template }) { } /> ) : ( - renderMissingDataDetail(i18n._(t`Project`)) + )} {summary_fields.inventory ? ( ) : ( - !ask_inventory_on_launch && - renderMissingDataDetail(i18n._(t`Inventory`)) + !ask_inventory_on_launch && ( + + ) )} {summary_fields.project ? ( ) : ( - renderMissingDataDetail(i18n._(t`Project`)) + )}