mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 11:20:39 -03:30
Add project node details
This commit is contained in:
parent
4704e24c24
commit
d1b5a60bb9
@ -2,10 +2,14 @@ import React from 'react';
|
||||
import { shape } from 'prop-types';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t, Trans } from '@lingui/macro';
|
||||
import { Link } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Chip, ChipGroup } from '@patternfly/react-core';
|
||||
import { VariablesDetail } from '@components/CodeMirrorInput';
|
||||
import { DetailList, Detail } from '@components/DetailList';
|
||||
import styled from 'styled-components';
|
||||
import { DetailList, Detail, UserDateDetail } from '@components/DetailList';
|
||||
|
||||
import PromptProjectDetail from './PromptProjectDetail';
|
||||
|
||||
const PromptHeader = styled.h2`
|
||||
font-weight: bold;
|
||||
@ -63,6 +67,34 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
|
||||
label={i18n._(t`Timeout`)}
|
||||
value={formatTimeout(resource?.timeout)}
|
||||
/>
|
||||
{resource?.summary_fields?.organization && (
|
||||
<Detail
|
||||
label={i18n._(t`Organization`)}
|
||||
value={
|
||||
<Link
|
||||
to={`/organizations/${resource?.summary_fields.organization.id}/details`}
|
||||
>
|
||||
{resource?.summary_fields?.organization.name}
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* TODO: Add JT, WFJT, Inventory Source Details */}
|
||||
{resource?.type === 'project' && (
|
||||
<PromptProjectDetail resource={resource} />
|
||||
)}
|
||||
|
||||
<UserDateDetail
|
||||
label={i18n._(t`Created`)}
|
||||
date={resource?.created}
|
||||
user={resource?.summary_fields?.created_by}
|
||||
/>
|
||||
<UserDateDetail
|
||||
label={i18n._(t`Last Modified`)}
|
||||
date={resource?.modified}
|
||||
user={resource?.summary_fields?.modified_by}
|
||||
/>
|
||||
</DetailList>
|
||||
|
||||
{hasPromptData(launchConfig) && (
|
||||
|
||||
@ -7,6 +7,8 @@ const mockTemplate = {
|
||||
name: 'Mock Template',
|
||||
description: 'mock description',
|
||||
unified_job_type: 'job',
|
||||
created: '2019-08-08T19:24:05.344276Z',
|
||||
modified: '2019-08-08T19:24:18.162949Z',
|
||||
};
|
||||
|
||||
const mockPromptLaunch = {
|
||||
|
||||
@ -0,0 +1,93 @@
|
||||
import React from 'react';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Config } from '@contexts/Config';
|
||||
import { List, ListItem } from '@patternfly/react-core';
|
||||
|
||||
import { Detail } from '@components/DetailList';
|
||||
import CredentialChip from '@components/CredentialChip';
|
||||
import { toTitleCase } from '@util/strings';
|
||||
|
||||
function PromptProjectDetail({ i18n, resource }) {
|
||||
const {
|
||||
allow_override,
|
||||
custom_virtualenv,
|
||||
local_path,
|
||||
scm_branch,
|
||||
scm_clean,
|
||||
scm_delete_on_update,
|
||||
scm_refspec,
|
||||
scm_type,
|
||||
scm_update_on_launch,
|
||||
scm_update_cache_timeout,
|
||||
scm_url,
|
||||
summary_fields,
|
||||
} = resource;
|
||||
|
||||
let optionsList = '';
|
||||
if (
|
||||
scm_clean ||
|
||||
scm_delete_on_update ||
|
||||
scm_update_on_launch ||
|
||||
allow_override
|
||||
) {
|
||||
optionsList = (
|
||||
<List>
|
||||
{scm_clean && <ListItem>{i18n._(t`Clean`)}</ListItem>}
|
||||
{scm_delete_on_update && (
|
||||
<ListItem>{i18n._(t`Delete on Update`)}</ListItem>
|
||||
)}
|
||||
{scm_update_on_launch && (
|
||||
<ListItem>{i18n._(t`Update Revision on Launch`)}</ListItem>
|
||||
)}
|
||||
{allow_override && (
|
||||
<ListItem>{i18n._(t`Allow Branch Override`)}</ListItem>
|
||||
)}
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Detail
|
||||
label={i18n._(t`SCM Type`)}
|
||||
value={scm_type === '' ? i18n._(t`Manual`) : toTitleCase(scm_type)}
|
||||
/>
|
||||
<Detail label={i18n._(t`SCM URL`)} value={scm_url} />
|
||||
<Detail label={i18n._(t`SCM Branch`)} value={scm_branch} />
|
||||
<Detail label={i18n._(t`SCM Refspec`)} value={scm_refspec} />
|
||||
{summary_fields?.credential?.id && (
|
||||
<Detail
|
||||
label={i18n._(t`SCM Credential`)}
|
||||
value={
|
||||
<CredentialChip
|
||||
key={resource.summary_fields.credential.id}
|
||||
credential={resource.summary_fields.credential}
|
||||
isReadOnly
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{optionsList && <Detail label={i18n._(t`Options`)} value={optionsList} />}
|
||||
<Detail
|
||||
label={i18n._(t`Cache Timeout`)}
|
||||
value={`${scm_update_cache_timeout} ${i18n._(t`Seconds`)}`}
|
||||
/>
|
||||
<Detail
|
||||
label={i18n._(t`Ansible Environment`)}
|
||||
value={custom_virtualenv}
|
||||
/>
|
||||
<Config>
|
||||
{({ project_base_dir }) => (
|
||||
<Detail
|
||||
label={i18n._(t`Project Base Path`)}
|
||||
value={project_base_dir}
|
||||
/>
|
||||
)}
|
||||
</Config>
|
||||
<Detail label={i18n._(t`Playbook Directory`)} value={local_path} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default withI18n()(PromptProjectDetail);
|
||||
@ -20,38 +20,25 @@ import {
|
||||
|
||||
function getNodeType(node) {
|
||||
const ujtType = node.type || node.unified_job_type;
|
||||
|
||||
let nodeType;
|
||||
let nodeAPI;
|
||||
switch (ujtType) {
|
||||
case 'job_template':
|
||||
case 'job':
|
||||
nodeType = 'job_template';
|
||||
nodeAPI = JobTemplatesAPI;
|
||||
break;
|
||||
return ['job_template', JobTemplatesAPI];
|
||||
case 'project':
|
||||
case 'project_update':
|
||||
nodeType = 'project_sync';
|
||||
nodeAPI = ProjectsAPI;
|
||||
break;
|
||||
return ['project_sync', ProjectsAPI];
|
||||
case 'inventory_source':
|
||||
case 'inventory_update':
|
||||
nodeType = 'inventory_source_sync';
|
||||
nodeAPI = InventorySourcesAPI;
|
||||
break;
|
||||
return ['inventory_source_sync', InventorySourcesAPI];
|
||||
case 'workflow_job_template':
|
||||
case 'workflow_job':
|
||||
nodeType = 'workflow_job_template';
|
||||
nodeAPI = WorkflowJobTemplatesAPI;
|
||||
break;
|
||||
return ['workflow_job_template', WorkflowJobTemplatesAPI];
|
||||
case 'workflow_approval_template':
|
||||
case 'workflow_approval':
|
||||
nodeType = 'approval';
|
||||
nodeAPI = null;
|
||||
break;
|
||||
return ['approval', null];
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return [nodeType, nodeAPI];
|
||||
}
|
||||
|
||||
function NodeViewModal({ i18n }) {
|
||||
|
||||
@ -34,6 +34,8 @@ describe('NodeViewModal', () => {
|
||||
name: 'Mock Node',
|
||||
description: '',
|
||||
unified_job_type: 'workflow_job',
|
||||
created: '2019-08-08T19:24:05.344276Z',
|
||||
modified: '2019-08-08T19:24:18.162949Z',
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -94,6 +96,8 @@ describe('NodeViewModal', () => {
|
||||
name: 'Mock Node',
|
||||
description: '',
|
||||
type: 'job_template',
|
||||
created: '2019-08-08T19:24:05.344276Z',
|
||||
modified: '2019-08-08T19:24:18.162949Z',
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -143,6 +147,8 @@ describe('NodeViewModal', () => {
|
||||
name: 'Mock Node',
|
||||
description: '',
|
||||
type: 'project_update',
|
||||
created: '2019-08-08T19:24:05.344276Z',
|
||||
modified: '2019-08-08T19:24:18.162949Z',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user