mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
Move Organization screens and tests into new folder structure
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import Organizations from '../../../src/pages/Organizations/index';
|
import Organizations from '../../../src/pages/Organizations/Organizations';
|
||||||
|
|
||||||
describe('<Organizations />', () => {
|
describe('<Organizations />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
@@ -2,14 +2,14 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import OrganizationView from '../../../../src/pages/Organizations/views/Organization.view';
|
import Organization from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
||||||
|
|
||||||
describe('<OrganizationView />', () => {
|
describe('<OrganizationView />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
mount(
|
mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
<OrganizationView
|
<Organization
|
||||||
match={{ path: '/organizations/:id', url: '/organizations/1' }}
|
match={{ path: '/organizations/:id', url: '/organizations/1' }}
|
||||||
location={{ search: '', pathname: '/organizations/1' }}
|
location={{ search: '', pathname: '/organizations/1' }}
|
||||||
/>
|
/>
|
||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import OrganizationDetail from '../../../../src/pages/Organizations/components/OrganizationDetail';
|
import OrganizationDetail from '../../../../../src/pages/Organizations/screens/Organization/OrganizationDetail';
|
||||||
|
|
||||||
describe('<OrganizationDetail />', () => {
|
describe('<OrganizationDetail />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import OrganizationEdit from '../../../../src/pages/Organizations/components/OrganizationEdit';
|
import OrganizationEdit from '../../../../../src/pages/Organizations/screens/Organization/OrganizationEdit';
|
||||||
|
|
||||||
describe('<OrganizationEdit />', () => {
|
describe('<OrganizationEdit />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
@@ -17,7 +17,7 @@ const getAppWithConfigContext = (context = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Return the updated OrganizationAdd module with mocked context
|
// Return the updated OrganizationAdd module with mocked context
|
||||||
return require('../../../../src/pages/Organizations/views/Organization.add').default;
|
return require('../../../../src/pages/Organizations/screens/OrganizationAdd').default;
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import OrganizationsList from '../../../../src/pages/Organizations/views/Organizations.list';
|
import OrganizationsList from '../../../../src/pages/Organizations/screens/OrganizationsList';
|
||||||
|
|
||||||
describe('<OrganizationsList />', () => {
|
describe('<OrganizationsList />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
@@ -34,7 +34,7 @@ import Jobs from './pages/Jobs';
|
|||||||
import Login from './pages/Login';
|
import Login from './pages/Login';
|
||||||
import ManagementJobs from './pages/ManagementJobs';
|
import ManagementJobs from './pages/ManagementJobs';
|
||||||
import NotificationTemplates from './pages/NotificationTemplates';
|
import NotificationTemplates from './pages/NotificationTemplates';
|
||||||
import Organizations from './pages/Organizations';
|
import Organizations from './pages/Organizations/Organizations';
|
||||||
import Portal from './pages/Portal';
|
import Portal from './pages/Portal';
|
||||||
import Projects from './pages/Projects';
|
import Projects from './pages/Projects';
|
||||||
import Schedules from './pages/Schedules';
|
import Schedules from './pages/Schedules';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Route, Switch } from 'react-router-dom';
|
import { Route, Switch } from 'react-router-dom';
|
||||||
|
|
||||||
import OrganizationAdd from './views/Organization.add';
|
import OrganizationsList from './screens/OrganizationsList';
|
||||||
import OrganizationView from './views/Organization.view';
|
import OrganizationAdd from './screens/OrganizationAdd'
|
||||||
import OrganizationsList from './views/Organizations.list';
|
import Organization from './screens/Organization/Organization';
|
||||||
|
|
||||||
export default ({ api, match }) => (
|
export default ({ api, match }) => (
|
||||||
<Switch>
|
<Switch>
|
||||||
@@ -18,7 +18,7 @@ export default ({ api, match }) => (
|
|||||||
<Route
|
<Route
|
||||||
path={`${match.path}/:id`}
|
path={`${match.path}/:id`}
|
||||||
render={() => (
|
render={() => (
|
||||||
<OrganizationView
|
<Organization
|
||||||
api={api}
|
api={api}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Trans } from '@lingui/macro';
|
|
||||||
import {
|
|
||||||
Card,
|
|
||||||
CardBody,
|
|
||||||
PageSection,
|
|
||||||
PageSectionVariants
|
|
||||||
} from '@patternfly/react-core';
|
|
||||||
import {
|
|
||||||
Link
|
|
||||||
} from 'react-router-dom';
|
|
||||||
|
|
||||||
const OrganizationEdit = ({ match, parentBreadcrumbObj, organization }) => {
|
|
||||||
const { medium } = PageSectionVariants;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageSection variant={medium}>
|
|
||||||
<Card className="at-c-orgPane">
|
|
||||||
<CardBody>
|
|
||||||
<Trans>edit view </Trans>
|
|
||||||
<Link to={{ pathname: `/organizations/${match.params.id}`, state: { breadcrumb: parentBreadcrumbObj, organization } }}>
|
|
||||||
<Trans>save/cancel and go back to view</Trans>
|
|
||||||
</Link>
|
|
||||||
</CardBody>
|
|
||||||
</Card>
|
|
||||||
</PageSection>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default OrganizationEdit;
|
|
||||||
@@ -5,11 +5,15 @@ import {
|
|||||||
Route,
|
Route,
|
||||||
withRouter,
|
withRouter,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import OrganizationBreadcrumb from '../components/OrganizationBreadcrumb';
|
import {
|
||||||
import OrganizationDetail from '../components/OrganizationDetail';
|
PageSection
|
||||||
import OrganizationEdit from '../components/OrganizationEdit';
|
} from '@patternfly/react-core';
|
||||||
|
|
||||||
class OrganizationView extends Component {
|
import OrganizationBreadcrumb from '../../components/OrganizationBreadcrumb';
|
||||||
|
import OrganizationDetail from './OrganizationDetail';
|
||||||
|
import OrganizationEdit from './OrganizationEdit';
|
||||||
|
|
||||||
|
class Organization extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@@ -84,39 +88,41 @@ class OrganizationView extends Component {
|
|||||||
location={location}
|
location={location}
|
||||||
organization={organization}
|
organization={organization}
|
||||||
/>
|
/>
|
||||||
<Switch>
|
<PageSection>
|
||||||
<Route
|
<Switch>
|
||||||
path={`${match.path}/edit`}
|
<Route
|
||||||
component={() => (
|
path={`${match.path}/edit`}
|
||||||
<OrganizationEdit
|
component={() => (
|
||||||
location={location}
|
<OrganizationEdit
|
||||||
match={match}
|
location={location}
|
||||||
parentBreadcrumbObj={parentBreadcrumbObj}
|
match={match}
|
||||||
organization={organization}
|
parentBreadcrumbObj={parentBreadcrumbObj}
|
||||||
params={params}
|
organization={organization}
|
||||||
currentTab={currentTab}
|
params={params}
|
||||||
/>
|
currentTab={currentTab}
|
||||||
)}
|
/>
|
||||||
/>
|
)}
|
||||||
<Route
|
/>
|
||||||
path={`${match.path}`}
|
<Route
|
||||||
component={() => (
|
path={`${match.path}`}
|
||||||
<OrganizationDetail
|
component={() => (
|
||||||
location={location}
|
<OrganizationDetail
|
||||||
match={match}
|
location={location}
|
||||||
parentBreadcrumbObj={parentBreadcrumbObj}
|
match={match}
|
||||||
organization={organization}
|
parentBreadcrumbObj={parentBreadcrumbObj}
|
||||||
params={params}
|
organization={organization}
|
||||||
currentTab={currentTab}
|
params={params}
|
||||||
/>
|
currentTab={currentTab}
|
||||||
)}
|
/>
|
||||||
/>
|
)}
|
||||||
</Switch>
|
/>
|
||||||
{error ? 'error!' : ''}
|
</Switch>
|
||||||
{loading ? 'loading...' : ''}
|
{error ? 'error!' : ''}
|
||||||
|
{loading ? 'loading...' : ''}
|
||||||
|
</PageSection>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(OrganizationView);
|
export default withRouter(Organization);
|
||||||
@@ -5,8 +5,6 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardBody,
|
CardBody,
|
||||||
PageSection,
|
|
||||||
PageSectionVariants
|
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import {
|
import {
|
||||||
Switch,
|
Switch,
|
||||||
@@ -14,9 +12,9 @@ import {
|
|||||||
Route
|
Route
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
|
||||||
import Tab from '../../../components/Tabs/Tab';
|
import Tab from '../../../../components/Tabs/Tab';
|
||||||
import Tabs from '../../../components/Tabs/Tabs';
|
import Tabs from '../../../../components/Tabs/Tabs';
|
||||||
import getTabName from '../utils';
|
import getTabName from '../../utils';
|
||||||
|
|
||||||
|
|
||||||
const OrganizationDetail = ({
|
const OrganizationDetail = ({
|
||||||
@@ -28,7 +26,6 @@ const OrganizationDetail = ({
|
|||||||
currentTab
|
currentTab
|
||||||
}) => {
|
}) => {
|
||||||
// TODO: set objectName by param or through grabbing org detail get from api
|
// TODO: set objectName by param or through grabbing org detail get from api
|
||||||
const { medium } = PageSectionVariants;
|
|
||||||
const tabList=['details', 'access', 'teams', 'notifications'];
|
const tabList=['details', 'access', 'teams', 'notifications'];
|
||||||
|
|
||||||
const deleteResourceView = () => (
|
const deleteResourceView = () => (
|
||||||
@@ -64,46 +61,44 @@ const OrganizationDetail = ({
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageSection variant={medium}>
|
<Card className="at-c-orgPane">
|
||||||
<Card className="at-c-orgPane">
|
<CardHeader>
|
||||||
<CardHeader>
|
<I18n>
|
||||||
<I18n>
|
{({ i18n }) => (
|
||||||
{({ i18n }) => (
|
<Tabs labelText={i18n._(t`Organization detail tabs`)}>
|
||||||
<Tabs labelText={i18n._(t`Organization detail tabs`)}>
|
{tabList.map(tab => (
|
||||||
{tabList.map(tab => (
|
<Tab
|
||||||
<Tab
|
key={tab}
|
||||||
key={tab}
|
tab={tab}
|
||||||
tab={tab}
|
location={location}
|
||||||
location={location}
|
match={match}
|
||||||
match={match}
|
currentTab={currentTab}
|
||||||
currentTab={currentTab}
|
breadcrumb={parentBreadcrumbObj}
|
||||||
breadcrumb={parentBreadcrumbObj}
|
>
|
||||||
>
|
<Trans>{getTabName(tab)}</Trans>
|
||||||
<Trans>{getTabName(tab)}</Trans>
|
</Tab>
|
||||||
</Tab>
|
))}
|
||||||
))}
|
</Tabs>
|
||||||
</Tabs>
|
|
||||||
)}
|
|
||||||
</I18n>
|
|
||||||
</CardHeader>
|
|
||||||
<CardBody>
|
|
||||||
{(currentTab && currentTab !== 'details') ? (
|
|
||||||
<Switch>
|
|
||||||
<Route path={`${match.path}/delete-resources`} component={() => deleteResourceView()} />
|
|
||||||
<Route path={`${match.path}/add-resource`} component={() => addResourceView()} />
|
|
||||||
<Route path={`${match.path}`} component={() => resourceView()} />
|
|
||||||
</Switch>
|
|
||||||
) : (
|
|
||||||
<Fragment>
|
|
||||||
{'detail view '}
|
|
||||||
<Link to={{ pathname: `${match.url}/edit`, state: { breadcrumb: parentBreadcrumbObj, organization } }}>
|
|
||||||
{'edit'}
|
|
||||||
</Link>
|
|
||||||
</Fragment>
|
|
||||||
)}
|
)}
|
||||||
</CardBody>
|
</I18n>
|
||||||
</Card>
|
</CardHeader>
|
||||||
</PageSection>
|
<CardBody>
|
||||||
|
{(currentTab && currentTab !== 'details') ? (
|
||||||
|
<Switch>
|
||||||
|
<Route path={`${match.path}/delete-resources`} component={() => deleteResourceView()} />
|
||||||
|
<Route path={`${match.path}/add-resource`} component={() => addResourceView()} />
|
||||||
|
<Route path={`${match.path}`} component={() => resourceView()} />
|
||||||
|
</Switch>
|
||||||
|
) : (
|
||||||
|
<Fragment>
|
||||||
|
{'detail view '}
|
||||||
|
<Link to={{ pathname: `${match.url}/edit`, state: { breadcrumb: parentBreadcrumbObj, organization } }}>
|
||||||
|
{'edit'}
|
||||||
|
</Link>
|
||||||
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Trans } from '@lingui/macro';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardBody
|
||||||
|
} from '@patternfly/react-core';
|
||||||
|
import {
|
||||||
|
Link
|
||||||
|
} from 'react-router-dom';
|
||||||
|
|
||||||
|
const OrganizationEdit = ({ match, parentBreadcrumbObj, organization }) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card className="at-c-orgPane">
|
||||||
|
<CardBody>
|
||||||
|
<Trans>edit view </Trans>
|
||||||
|
<Link to={{ pathname: `/organizations/${match.params.id}`, state: { breadcrumb: parentBreadcrumbObj, organization } }}>
|
||||||
|
<Trans>save/cancel and go back to view</Trans>
|
||||||
|
</Link>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrganizationEdit;
|
||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
parseQueryString,
|
parseQueryString,
|
||||||
} from '../../../qs';
|
} from '../../../qs';
|
||||||
|
|
||||||
class Organizations extends Component {
|
class OrganizationsList extends Component {
|
||||||
columns = [
|
columns = [
|
||||||
{ name: i18nMark('Name'), key: 'name', isSortable: true },
|
{ name: i18nMark('Name'), key: 'name', isSortable: true },
|
||||||
{ name: i18nMark('Modified'), key: 'modified', isSortable: true, isNumeric: true },
|
{ name: i18nMark('Modified'), key: 'modified', isSortable: true, isNumeric: true },
|
||||||
@@ -248,4 +248,4 @@ class Organizations extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(Organizations);
|
export default withRouter(OrganizationsList);
|
||||||
Reference in New Issue
Block a user