diff --git a/awx/ui_next/src/components/Card/index.js b/awx/ui_next/src/components/Card/index.js
index 6d197d5600..55c70b8e14 100644
--- a/awx/ui_next/src/components/Card/index.js
+++ b/awx/ui_next/src/components/Card/index.js
@@ -1 +1,2 @@
+// eslint-disable-next-line import/prefer-default-export
export { default as TabbedCardHeader } from './TabbedCardHeader';
diff --git a/awx/ui_next/src/components/CodeMirrorInput/VariablesDetail.jsx b/awx/ui_next/src/components/CodeMirrorInput/VariablesDetail.jsx
index 04c7a1ed4b..2ea8e15ff9 100644
--- a/awx/ui_next/src/components/CodeMirrorInput/VariablesDetail.jsx
+++ b/awx/ui_next/src/components/CodeMirrorInput/VariablesDetail.jsx
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { string, number } from 'prop-types';
-import { Split, SplitItem } from '@patternfly/react-core';
+import { Split, SplitItem, TextListItemVariants } from '@patternfly/react-core';
+import { DetailName, DetailValue } from '@components/DetailList';
import CodeMirrorInput from './CodeMirrorInput';
import YamlJsonToggle from './YamlJsonToggle';
import { yamlToJson, jsonToYaml, isJson } from '../../util/yaml';
@@ -10,54 +11,68 @@ const JSON_MODE = 'javascript';
function VariablesDetail({ value, label, rows }) {
const [mode, setMode] = useState(isJson(value) ? JSON_MODE : YAML_MODE);
- const [val, setVal] = useState(value);
+ const [currentValue, setCurrentValue] = useState(value);
const [error, setError] = useState(null);
return (
-
-
-
-
-
- {label}
-
-
-
-
- {
- try {
- const newVal =
- newMode === YAML_MODE ? jsonToYaml(val) : yamlToJson(val);
- setVal(newVal);
- setMode(newMode);
- } catch (err) {
- setError(err);
- }
- }}
- />
-
-
-
- {error && (
-
+
+
+
+
+ {label}
+
+
+
+
+ {
+ try {
+ const newVal =
+ newMode === YAML_MODE
+ ? jsonToYaml(currentValue)
+ : yamlToJson(currentValue);
+ setCurrentValue(newVal);
+ setMode(newMode);
+ } catch (err) {
+ setError(err);
+ }
+ }}
+ />
+
+
+
+
+
+ {error && (
+
- Error: {error.message}
-
- )}
-
+ >
+ Error: {error.message}
+
+ )}
+
+ >
);
}
VariablesDetail.propTypes = {
diff --git a/awx/ui_next/src/components/CodeMirrorInput/VariablesField.jsx b/awx/ui_next/src/components/CodeMirrorInput/VariablesField.jsx
index 96b516946e..97c35c1871 100644
--- a/awx/ui_next/src/components/CodeMirrorInput/VariablesField.jsx
+++ b/awx/ui_next/src/components/CodeMirrorInput/VariablesField.jsx
@@ -7,7 +7,6 @@ import YamlJsonToggle from './YamlJsonToggle';
import { yamlToJson, jsonToYaml } from '../../util/yaml';
const YAML_MODE = 'yaml';
-const JSON_MODE = 'javascript';
function VariablesField({ id, name, label, readOnly }) {
// TODO: detect initial mode
diff --git a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx
index e9e18c3c4f..cf026f40f7 100644
--- a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx
+++ b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.jsx
@@ -4,10 +4,9 @@ import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import styled from 'styled-components';
import { Host } from '@types';
-import { formatDateString } from '@util/dates';
import { Button, CardBody } from '@patternfly/react-core';
-import { DetailList, Detail } from '@components/DetailList';
-import CodeMirrorInput from '@components/CodeMirrorInput';
+import { DetailList, Detail, UserDateDetail } from '@components/DetailList';
+import { VariablesDetail } from '@components/CodeMirrorInput';
const ActionButtonWrapper = styled.div`
display: flex;
@@ -21,30 +20,6 @@ const ActionButtonWrapper = styled.div`
function HostDetail({ host, i18n }) {
const { created, description, id, modified, name, summary_fields } = host;
- let createdBy = '';
- if (created) {
- if (summary_fields.created_by && summary_fields.created_by.username) {
- createdBy = i18n._(
- t`${formatDateString(created)} by ${summary_fields.created_by.username}`
- );
- } else {
- createdBy = formatDateString(created);
- }
- }
-
- let modifiedBy = '';
- if (modified) {
- if (summary_fields.modified_by && summary_fields.modified_by.username) {
- modifiedBy = i18n._(
- t`${formatDateString(modified)} by ${
- summary_fields.modified_by.username
- }`
- );
- } else {
- modifiedBy = formatDateString(modified);
- }
- }
-
return (
@@ -66,23 +41,20 @@ function HostDetail({ host, i18n }) {
}
/>
)}
- {/* TODO: Link to user in users */}
-
- {/* TODO: Link to user in users */}
-
-
+
+ {}}
- rows={6}
- hasErrors={false}
- />
- }
+ value={host.variables}
+ rows={6}
/>
diff --git a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.test.jsx b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.test.jsx
index a748f9596d..749c512171 100644
--- a/awx/ui_next/src/screens/Host/HostDetail/HostDetail.test.jsx
+++ b/awx/ui_next/src/screens/Host/HostDetail/HostDetail.test.jsx
@@ -30,7 +30,7 @@ describe('', () => {
mountWithContexts();
});
- test('should render Details', async done => {
+ test('should render Details', async () => {
const wrapper = mountWithContexts();
const testParams = [
{ label: 'Name', value: 'Foo' },
@@ -46,23 +46,22 @@ describe('', () => {
expect(detail.find('dt').text()).toBe(label);
expect(detail.find('dd').text()).toBe(value);
}
- done();
});
- test('should show edit button for users with edit permission', async done => {
+ test('should show edit button for users with edit permission', async () => {
const wrapper = mountWithContexts();
- const editButton = await waitForElement(wrapper, 'HostDetail Button');
+ // VariablesDetail has two buttons
+ const editButton = wrapper.find('Button').at(2);
expect(editButton.text()).toEqual('Edit');
expect(editButton.prop('to')).toBe('/hosts/1/edit');
- done();
});
- test('should hide edit button for users without edit permission', async done => {
+ test('should hide edit button for users without edit permission', async () => {
const readOnlyHost = { ...mockHost };
readOnlyHost.summary_fields.user_capabilities.edit = false;
const wrapper = mountWithContexts();
await waitForElement(wrapper, 'HostDetail');
- expect(wrapper.find('HostDetail Button').length).toBe(0);
- done();
+ // VariablesDetail has two buttons
+ expect(wrapper.find('Button').length).toBe(2);
});
});
diff --git a/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.jsx b/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.jsx
index dffff1881c..933b8794f3 100644
--- a/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.jsx
+++ b/awx/ui_next/src/screens/Inventory/InventoryDetail/InventoryDetail.jsx
@@ -56,16 +56,13 @@ function InventoryDetail({ inventory, i18n }) {
)
}
/>
-
- {inventory.variables && (
-
- )}
-
+ {inventory.variables && (
+
+ )}