Implement Remote Archive SCM Type for ui_next

Signed-off-by: Philip Douglass <philip.douglass@amadeus.com>
This commit is contained in:
Philip Douglass 2020-08-19 18:55:13 -04:00
parent 70cbccd2ef
commit d259500332
12 changed files with 76 additions and 3 deletions

View File

@ -105,6 +105,7 @@ function ProjectLookup({
[`git`, i18n._(t`Git`)],
[`hg`, i18n._(t`Mercurial`)],
[`svn`, i18n._(t`Subversion`)],
[`archive`, i18n._(t`Remote Archive`)],
[`insights`, i18n._(t`Red Hat Insights`)],
],
},

View File

@ -87,6 +87,7 @@ export default function getResourceAccessConfig(i18n) {
[`git`, i18n._(t`Git`)],
[`hg`, i18n._(t`Mercurial`)],
[`svn`, i18n._(t`Subversion`)],
[`archive`, i18n._(t`Remote Archive`)],
[`insights`, i18n._(t`Red Hat Insights`)],
],
},
@ -154,6 +155,7 @@ export default function getResourceAccessConfig(i18n) {
[`git`, i18n._(t`Git`)],
[`hg`, i18n._(t`Mercurial`)],
[`svn`, i18n._(t`Subversion`)],
[`archive`, i18n._(t`Remote Archive`)],
[`insights`, i18n._(t`Red Hat Insights`)],
],
},

View File

@ -37,6 +37,7 @@ describe('<ProjectAdd />', () => {
['git', 'Git'],
['hg', 'Mercurial'],
['svn', 'Subversion'],
['archive', 'Remote Archive'],
['insights', 'Red Hat Insights'],
],
},

View File

@ -49,6 +49,7 @@ describe('<ProjectEdit />', () => {
['git', 'Git'],
['hg', 'Mercurial'],
['svn', 'Subversion'],
['archive', 'Remote Archive'],
['insights', 'Red Hat Insights'],
],
},

View File

@ -138,6 +138,7 @@ function ProjectList({ i18n }) {
[`git`, i18n._(t`Git`)],
[`hg`, i18n._(t`Mercurial`)],
[`svn`, i18n._(t`Subversion`)],
[`archive`, i18n._(t`Remote Archive`)],
[`insights`, i18n._(t`Red Hat Insights`)],
],
},

View File

@ -61,6 +61,24 @@ const mockProjects = [
},
},
},
{
id: 4,
name: 'Project 4',
url: '/api/v2/projects/4',
type: 'project',
scm_type: 'archive',
scm_revision: 'odsd9ajf8aagjisooajfij34ikdj3fs994s4daiaos7',
summary_fields: {
last_job: {
id: 9004,
status: 'successful',
},
user_capabilities: {
delete: false,
update: false,
},
},
},
];
describe('<ProjectList />', () => {
@ -94,7 +112,7 @@ describe('<ProjectList />', () => {
});
wrapper.update();
expect(wrapper.find('ProjectListItem')).toHaveLength(3);
expect(wrapper.find('ProjectListItem')).toHaveLength(4);
});
test('should select project when checked', async () => {
@ -133,7 +151,7 @@ describe('<ProjectList />', () => {
wrapper.update();
const items = wrapper.find('ProjectListItem');
expect(items).toHaveLength(3);
expect(items).toHaveLength(4);
items.forEach(item => {
expect(item.prop('isSelected')).toEqual(true);
});

View File

@ -25,6 +25,7 @@ import {
GitSubForm,
HgSubForm,
SvnSubForm,
ArchiveSubForm,
InsightsSubForm,
ManualSubForm,
} from './ProjectSubForms';
@ -240,6 +241,13 @@ function ProjectFormFields({
scmUpdateOnLaunch={formik.values.scm_update_on_launch}
/>
),
archive: (
<ArchiveSubForm
credential={credentials.scm}
onCredentialSelection={handleCredentialSelection}
scmUpdateOnLaunch={formik.values.scm_update_on_launch}
/>
),
insights: (
<InsightsSubForm
credential={credentials.insights}

View File

@ -47,6 +47,7 @@ describe('<ProjectForm />', () => {
['git', 'Git'],
['hg', 'Mercurial'],
['svn', 'Subversion'],
['archive', 'Remote Archive'],
['insights', 'Red Hat Insights'],
],
},

View File

@ -0,0 +1,38 @@
import 'styled-components/macro';
import React from 'react';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import {
UrlFormField,
ScmCredentialFormField,
ScmTypeOptions,
} from './SharedFields';
const ArchiveSubForm = ({
i18n,
credential,
onCredentialSelection,
scmUpdateOnLaunch,
}) => (
<>
<UrlFormField
i18n={i18n}
tooltip={
<span>
{i18n._(t`Example URLs for Remote Archive Source Control include:`)}
<ul css={{ margin: '10px 0 10px 20px' }}>
<li>https://github.com/username/project/archive/v0.0.1.tar.gz</li>
<li>https://github.com/username/project/archive/v0.0.2.zip</li>
</ul>
</span>
}
/>
<ScmCredentialFormField
credential={credential}
onCredentialSelection={onCredentialSelection}
/>
<ScmTypeOptions scmUpdateOnLaunch={scmUpdateOnLaunch} />
</>
);
export default withI18n()(ArchiveSubForm);

View File

@ -3,3 +3,4 @@ export { default as HgSubForm } from './HgSubForm';
export { default as InsightsSubForm } from './InsightsSubForm';
export { default as ManualSubForm } from './ManualSubForm';
export { default as SvnSubForm } from './SvnSubForm';
export { default as ArchiveSubForm } from './ArchiveSubForm';

View File

@ -79,6 +79,7 @@ function ProjectsList({ i18n, nodeResource, onUpdateNodeResource }) {
[`git`, i18n._(t`Git`)],
[`hg`, i18n._(t`Mercurial`)],
[`svn`, i18n._(t`Subversion`)],
[`archive`, i18n._(t`Remote Archive`)],
[`insights`, i18n._(t`Red Hat Insights`)],
],
},

View File

@ -148,7 +148,7 @@ export const Project = shape({
created: string,
name: string.isRequired,
description: string,
scm_type: oneOf(['', 'git', 'hg', 'svn', 'insights']),
scm_type: oneOf(['', 'git', 'hg', 'svn', 'archive', 'insights']),
scm_url: string,
scm_branch: string,
scm_refspec: string,