-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove custom virtual from the UI. Also, surface missing-resource warnings on list items for UJTs that were using custom virtualenvs. Fix some uni-tests warnings. See: #9190 Also: #9207
- Loading branch information
Showing
51 changed files
with
418 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React from 'react'; | ||
import { bool, string } from 'prop-types'; | ||
import { Link } from 'react-router-dom'; | ||
import { withI18n } from '@lingui/react'; | ||
import { t } from '@lingui/macro'; | ||
import { Tooltip } from '@patternfly/react-core'; | ||
import styled from 'styled-components'; | ||
|
||
import { ExclamationTriangleIcon as PFExclamationTriangleIcon } from '@patternfly/react-icons'; | ||
|
||
import { Detail } from '../DetailList'; | ||
import { ExecutionEnvironment } from '../../types'; | ||
|
||
const ExclamationTriangleIcon = styled(PFExclamationTriangleIcon)` | ||
color: var(--pf-global--warning-color--100); | ||
margin-left: 18px; | ||
`; | ||
|
||
function ExecutionEnvironmentDetail({ | ||
virtualEnvironment, | ||
executionEnvironment, | ||
isDefaultEnvironment, | ||
i18n, | ||
}) { | ||
const label = isDefaultEnvironment | ||
? i18n._(t`Default Execution Environment`) | ||
: i18n._(t`Execution Environment`); | ||
|
||
if (executionEnvironment) { | ||
return ( | ||
<Detail | ||
label={label} | ||
value={ | ||
<Link | ||
to={`/execution_environments/${executionEnvironment.id}/details`} | ||
> | ||
{executionEnvironment.name} | ||
</Link> | ||
} | ||
dataCy="execution-environment-detail" | ||
/> | ||
); | ||
} | ||
if (virtualEnvironment && !executionEnvironment) { | ||
return ( | ||
<Detail | ||
label={label} | ||
value={ | ||
<> | ||
{i18n._(t`Missing resource`)} | ||
<span> | ||
<Tooltip | ||
content={i18n._( | ||
t`Custom virtual environment ${virtualEnvironment} must be replaced by an execution environment.` | ||
)} | ||
position="right" | ||
> | ||
<ExclamationTriangleIcon /> | ||
</Tooltip> | ||
</span> | ||
</> | ||
} | ||
dataCy="missing-execution-environment-detail" | ||
/> | ||
); | ||
} | ||
return null; | ||
} | ||
|
||
ExecutionEnvironmentDetail.propTypes = { | ||
executionEnvironment: ExecutionEnvironment, | ||
isDefaultEnvironment: bool, | ||
virtualEnvironment: string, | ||
}; | ||
|
||
ExecutionEnvironmentDetail.defaultProps = { | ||
isDefaultEnvironment: false, | ||
executionEnvironment: null, | ||
virtualEnvironment: '', | ||
}; | ||
|
||
export default withI18n()(ExecutionEnvironmentDetail); |
64 changes: 64 additions & 0 deletions
64
awx/ui_next/src/components/ExecutionEnvironmentDetail/ExecutionEnvironmentDetail.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; | ||
|
||
import ExecutionEnvironmentDetail from './ExecutionEnvironmentDetail'; | ||
|
||
const mockExecutionEnvironment = { | ||
id: 2, | ||
name: 'Foo', | ||
image: 'quay.io/ansible/awx-ee', | ||
pull: 'missing', | ||
description: '', | ||
}; | ||
|
||
const virtualEnvironment = 'var/lib/awx/custom_env'; | ||
|
||
describe('<ExecutionEnvironmentDetail/>', () => { | ||
test('should display execution environment detail', async () => { | ||
const wrapper = mountWithContexts( | ||
<ExecutionEnvironmentDetail | ||
executionEnvironment={mockExecutionEnvironment} | ||
/> | ||
); | ||
const executionEnvironment = wrapper.find('ExecutionEnvironmentDetail'); | ||
expect(executionEnvironment).toHaveLength(1); | ||
expect(executionEnvironment.find('dt').text()).toEqual( | ||
'Execution Environment' | ||
); | ||
expect(executionEnvironment.find('dd').text()).toEqual( | ||
mockExecutionEnvironment.name | ||
); | ||
}); | ||
|
||
test('should display execution environment detail even with a previous virtual env present', async () => { | ||
const wrapper = mountWithContexts( | ||
<ExecutionEnvironmentDetail | ||
executionEnvironment={mockExecutionEnvironment} | ||
virtualEnvironment={virtualEnvironment} | ||
/> | ||
); | ||
const executionEnvironment = wrapper.find('ExecutionEnvironmentDetail'); | ||
expect(executionEnvironment).toHaveLength(1); | ||
expect(executionEnvironment.find('dt').text()).toEqual( | ||
'Execution Environment' | ||
); | ||
expect(executionEnvironment.find('dd').text()).toEqual( | ||
mockExecutionEnvironment.name | ||
); | ||
}); | ||
|
||
test('should display warning missing execution environment', async () => { | ||
const wrapper = mountWithContexts( | ||
<ExecutionEnvironmentDetail virtualEnvironment={virtualEnvironment} /> | ||
); | ||
const executionEnvironment = wrapper.find('ExecutionEnvironmentDetail'); | ||
expect(executionEnvironment).toHaveLength(1); | ||
expect(executionEnvironment.find('dt').text()).toEqual( | ||
'Execution Environment' | ||
); | ||
expect(executionEnvironment.find('dd').text()).toEqual('Missing resource'); | ||
expect(wrapper.find('Tooltip').prop('content')).toEqual( | ||
`Custom virtual environment ${virtualEnvironment} must be replaced by an execution environment.` | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ExecutionEnvironmentDetail'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.