mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 21:35:01 -02:30
Add project node details
This commit is contained in:
@@ -2,10 +2,14 @@ import React from 'react';
|
|||||||
import { shape } from 'prop-types';
|
import { shape } from 'prop-types';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t, Trans } from '@lingui/macro';
|
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 { Chip, ChipGroup } from '@patternfly/react-core';
|
||||||
import { VariablesDetail } from '@components/CodeMirrorInput';
|
import { VariablesDetail } from '@components/CodeMirrorInput';
|
||||||
import { DetailList, Detail } from '@components/DetailList';
|
import { DetailList, Detail, UserDateDetail } from '@components/DetailList';
|
||||||
import styled from 'styled-components';
|
|
||||||
|
import PromptProjectDetail from './PromptProjectDetail';
|
||||||
|
|
||||||
const PromptHeader = styled.h2`
|
const PromptHeader = styled.h2`
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -63,6 +67,34 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) {
|
|||||||
label={i18n._(t`Timeout`)}
|
label={i18n._(t`Timeout`)}
|
||||||
value={formatTimeout(resource?.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>
|
</DetailList>
|
||||||
|
|
||||||
{hasPromptData(launchConfig) && (
|
{hasPromptData(launchConfig) && (
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ const mockTemplate = {
|
|||||||
name: 'Mock Template',
|
name: 'Mock Template',
|
||||||
description: 'mock description',
|
description: 'mock description',
|
||||||
unified_job_type: 'job',
|
unified_job_type: 'job',
|
||||||
|
created: '2019-08-08T19:24:05.344276Z',
|
||||||
|
modified: '2019-08-08T19:24:18.162949Z',
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockPromptLaunch = {
|
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) {
|
function getNodeType(node) {
|
||||||
const ujtType = node.type || node.unified_job_type;
|
const ujtType = node.type || node.unified_job_type;
|
||||||
|
|
||||||
let nodeType;
|
|
||||||
let nodeAPI;
|
|
||||||
switch (ujtType) {
|
switch (ujtType) {
|
||||||
case 'job_template':
|
case 'job_template':
|
||||||
case 'job':
|
case 'job':
|
||||||
nodeType = 'job_template';
|
return ['job_template', JobTemplatesAPI];
|
||||||
nodeAPI = JobTemplatesAPI;
|
|
||||||
break;
|
|
||||||
case 'project':
|
case 'project':
|
||||||
case 'project_update':
|
case 'project_update':
|
||||||
nodeType = 'project_sync';
|
return ['project_sync', ProjectsAPI];
|
||||||
nodeAPI = ProjectsAPI;
|
|
||||||
break;
|
|
||||||
case 'inventory_source':
|
case 'inventory_source':
|
||||||
case 'inventory_update':
|
case 'inventory_update':
|
||||||
nodeType = 'inventory_source_sync';
|
return ['inventory_source_sync', InventorySourcesAPI];
|
||||||
nodeAPI = InventorySourcesAPI;
|
|
||||||
break;
|
|
||||||
case 'workflow_job_template':
|
case 'workflow_job_template':
|
||||||
case 'workflow_job':
|
case 'workflow_job':
|
||||||
nodeType = 'workflow_job_template';
|
return ['workflow_job_template', WorkflowJobTemplatesAPI];
|
||||||
nodeAPI = WorkflowJobTemplatesAPI;
|
|
||||||
break;
|
|
||||||
case 'workflow_approval_template':
|
case 'workflow_approval_template':
|
||||||
case 'workflow_approval':
|
case 'workflow_approval':
|
||||||
nodeType = 'approval';
|
return ['approval', null];
|
||||||
nodeAPI = null;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return [nodeType, nodeAPI];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function NodeViewModal({ i18n }) {
|
function NodeViewModal({ i18n }) {
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ describe('NodeViewModal', () => {
|
|||||||
name: 'Mock Node',
|
name: 'Mock Node',
|
||||||
description: '',
|
description: '',
|
||||||
unified_job_type: 'workflow_job',
|
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',
|
name: 'Mock Node',
|
||||||
description: '',
|
description: '',
|
||||||
type: 'job_template',
|
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',
|
name: 'Mock Node',
|
||||||
description: '',
|
description: '',
|
||||||
type: 'project_update',
|
type: 'project_update',
|
||||||
|
created: '2019-08-08T19:24:05.344276Z',
|
||||||
|
modified: '2019-08-08T19:24:18.162949Z',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user