From 24f86cd0d11e489ab03994a2c31545fe643cd830 Mon Sep 17 00:00:00 2001 From: nixocio Date: Wed, 1 Jul 2020 17:20:16 -0400 Subject: [PATCH] Add stub files for Instance Groups Add stub files for Instance Groups. Routing system, and screens layout. closes: https://github.com/ansible/awx/issues/7471 --- .../screens/InstanceGroup/InstanceGroup.jsx | 25 ++++++++ .../InstanceGroupAdd/InstanceGroupAdd.jsx | 14 +++++ .../InstanceGroup/InstanceGroupAdd/index.js | 1 + .../InstanceGroupDetails.jsx | 14 +++++ .../InstanceGroupDetails/index.js | 1 + .../InstanceGroupEdit/InstanceGroupEdit.jsx | 14 +++++ .../InstanceGroup/InstanceGroupEdit/index.js | 1 + .../InstanceGroupList/InstanceGroupList.jsx | 14 +++++ .../InstanceGroup/InstanceGroupList/index.js | 1 + .../screens/InstanceGroup/InstanceGroups.jsx | 62 ++++++++++++------- .../InstanceGroup/InstanceGroups.test.jsx | 8 +-- 11 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/InstanceGroupAdd.jsx create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/index.js create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/index.js create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.jsx create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/index.js create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupList.jsx create mode 100644 awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/index.js diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx new file mode 100644 index 0000000000..60c23ec31f --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroup.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Route, Switch, Redirect } from 'react-router-dom'; + +import InstanceGroupDetails from './InstanceGroupDetails'; +import InstanceGroupEdit from './InstanceGroupEdit'; + +function InstanceGroup() { + return ( + + + + + + + + + + ); +} + +export default InstanceGroup; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/InstanceGroupAdd.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/InstanceGroupAdd.jsx new file mode 100644 index 0000000000..fb8f034a0f --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/InstanceGroupAdd.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Card, PageSection } from '@patternfly/react-core'; + +function InstanceGroupAdd() { + return ( + + +
Instance Group Add
+
+
+ ); +} + +export default InstanceGroupAdd; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/index.js b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/index.js new file mode 100644 index 0000000000..b60610120d --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupAdd/index.js @@ -0,0 +1 @@ +export { default } from './InstanceGroupAdd'; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx new file mode 100644 index 0000000000..f88675ec81 --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/InstanceGroupDetails.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Card, PageSection } from '@patternfly/react-core'; + +function InstanceGroupDetails() { + return ( + + +
Instance Group Details
+
+
+ ); +} + +export default InstanceGroupDetails; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/index.js b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/index.js new file mode 100644 index 0000000000..d92e89e961 --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupDetails/index.js @@ -0,0 +1 @@ +export { default } from './InstanceGroupDetails'; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.jsx new file mode 100644 index 0000000000..a06b1db2e8 --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/InstanceGroupEdit.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Card, PageSection } from '@patternfly/react-core'; + +function InstanceGroupEdit() { + return ( + + +
Instance Group Edit
+
+
+ ); +} + +export default InstanceGroupEdit; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/index.js b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/index.js new file mode 100644 index 0000000000..324bdabb31 --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupEdit/index.js @@ -0,0 +1 @@ +export { default } from './InstanceGroupEdit'; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupList.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupList.jsx new file mode 100644 index 0000000000..dc1ed2ce73 --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/InstanceGroupList.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Card, PageSection } from '@patternfly/react-core'; + +function InstanceGroupList() { + return ( + + +
Instance Group List
+
+
+ ); +} + +export default InstanceGroupList; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/index.js b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/index.js new file mode 100644 index 0000000000..3b1a71ec1b --- /dev/null +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroupList/index.js @@ -0,0 +1 @@ +export { default } from './InstanceGroupList'; diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.jsx index 9a973bccc0..336d6e5037 100644 --- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.jsx @@ -1,28 +1,48 @@ -import React, { Component, Fragment } from 'react'; +import React, { useState, useCallback } from 'react'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; -import { - PageSection, - PageSectionVariants, - Title, -} from '@patternfly/react-core'; +import { Route, Switch } from 'react-router-dom'; -class InstanceGroups extends Component { - render() { - const { i18n } = this.props; - const { light } = PageSectionVariants; +import InstanceGroupAdd from './InstanceGroupAdd'; +import InstanceGroupList from './InstanceGroupList'; +import InstanceGroup from './InstanceGroup'; +import Breadcrumbs from '../../components/Breadcrumbs'; - return ( - - - - {i18n._(t`Instance Groups`)} - - - - - ); - } +function InstanceGroups({ i18n }) { + const [breadcrumbConfig, setBreadcrumbConfig] = useState({ + '/instance_groups': i18n._(t`Instance Groups`), + '/instance_groups/add': i18n._(t`Create Instance Groups`), + }); + + const buildBreadcrumbConfig = useCallback( + instanceGroups => { + if (!instanceGroups) { + return; + } + setBreadcrumbConfig({ + '/instance_groups': i18n._(t`Instance Groups`), + '/instance_groups/add': i18n._(t`Create Instance Groups`), + [`/instance_groups/${instanceGroups.id}`]: `${instanceGroups.name}`, + }); + }, + [i18n] + ); + return ( + <> + + + + + + + + + + + + + + ); } export default withI18n()(InstanceGroups); diff --git a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx index dfc33e37de..321b6ca71b 100644 --- a/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx +++ b/awx/ui_next/src/screens/InstanceGroup/InstanceGroups.test.jsx @@ -4,15 +4,13 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import InstanceGroups from './InstanceGroups'; -describe('', () => { +describe('', () => { let pageWrapper; let pageSections; - let title; beforeEach(() => { pageWrapper = mountWithContexts(); pageSections = pageWrapper.find('PageSection'); - title = pageWrapper.find('Title'); }); afterEach(() => { @@ -21,9 +19,7 @@ describe('', () => { test('initially renders without crashing', () => { expect(pageWrapper.length).toBe(1); - expect(pageSections.length).toBe(2); - expect(title.length).toBe(1); - expect(title.props().size).toBe('2xl'); + expect(pageSections.length).toBe(1); expect(pageSections.first().props().variant).toBe('light'); }); });