mirror of
https://github.com/ansible/awx.git
synced 2026-02-20 12:40:06 -03:30
Ensures Variables Details renders even when no value.
When there is no value VariablesDetails will show ---.
This commit is contained in:
@@ -14,10 +14,6 @@ function VariablesDetail({ value, label, rows }) {
|
|||||||
const [currentValue, setCurrentValue] = useState(value);
|
const [currentValue, setCurrentValue] = useState(value);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DetailName
|
<DetailName
|
||||||
@@ -62,7 +58,7 @@ function VariablesDetail({ value, label, rows }) {
|
|||||||
>
|
>
|
||||||
<CodeMirrorInput
|
<CodeMirrorInput
|
||||||
mode={mode}
|
mode={mode}
|
||||||
value={currentValue}
|
value={currentValue || '---'} // When github issue https://github.com/ansible/awx/issues/5502 gets resolved this line of code should be revisited and refactored if possible.
|
||||||
readOnly
|
readOnly
|
||||||
rows={rows}
|
rows={rows}
|
||||||
css="margin-top: 10px"
|
css="margin-top: 10px"
|
||||||
|
|||||||
@@ -40,4 +40,9 @@ describe('<VariablesDetail>', () => {
|
|||||||
expect(input2.prop('mode')).toEqual('yaml');
|
expect(input2.prop('mode')).toEqual('yaml');
|
||||||
expect(input2.prop('value')).toEqual('foo: bar\n');
|
expect(input2.prop('value')).toEqual('foo: bar\n');
|
||||||
});
|
});
|
||||||
|
test('should render label and value= --- when there are no values', () => {
|
||||||
|
const wrapper = shallow(<VariablesDetail value="" label="Variables" />);
|
||||||
|
expect(wrapper.find('Styled(CodeMirrorInput)').length).toBe(1);
|
||||||
|
expect(wrapper.find('div.pf-c-form__label').text()).toBe('Variables');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user