mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 09:57:33 -02:30
Remove unwanted committed file
This commit is contained in:
@@ -1,20 +1,64 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
|
<<<<<<< HEAD
|
||||||
|
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import { I18nProvider } from '@lingui/react'; import { I18nProvider } from '@lingui/react';
|
||||||
|
import Organization from '../../../../../src/pages/Organizations/screens/Organization/Organization'; import Organization, { _Organization } from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
||||||
|
|
||||||
|
=======
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { I18nProvider } from '@lingui/react';
|
import { I18nProvider } from '@lingui/react';
|
||||||
import Organization from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
import Organization, { _Organization } from '../../../../../src/pages/Organizations/screens/Organization/Organization';
|
||||||
|
>>>>>>> addresses PR issues
|
||||||
|
|
||||||
describe('<OrganizationView />', () => {
|
describe('<OrganizationView />', () => {
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders succesfully', () => {
|
||||||
|
const spy = jest.spyOn(_Organization.prototype, 'checkLocation');
|
||||||
mount(
|
mount(
|
||||||
<I18nProvider>
|
<I18nProvider>
|
||||||
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
<Organization
|
<_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' }}
|
||||||
/>
|
/>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
);
|
);
|
||||||
|
expect(spy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('handleTabSelect renders the correct tab', async () => {
|
||||||
|
const currentTab = 'organizations/19/access';
|
||||||
|
const spy = jest.spyOn(_Organization.prototype, 'handleTabSelect');
|
||||||
|
const wrapper = mount(
|
||||||
|
<I18nProvider>
|
||||||
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
|
<Organization location={currentTab} />
|
||||||
|
</MemoryRouter>
|
||||||
|
</I18nProvider>
|
||||||
|
).find('Organization');
|
||||||
|
wrapper.find('button').at(2).simulate('click');
|
||||||
|
setImmediate(async () => {
|
||||||
|
wrapper.setState({ activeTabKey: 1 });
|
||||||
|
});
|
||||||
|
wrapper.update();
|
||||||
|
expect(spy).toBeCalled();
|
||||||
|
expect(wrapper.state('activeTabKey')).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('checkLocation renders proper state when new tab is selected', async () => {
|
||||||
|
const currentTab = 'organizations/19/access';
|
||||||
|
const wrapper = mount(
|
||||||
|
<I18nProvider>
|
||||||
|
<MemoryRouter initialEntries={['/organizations/1']} initialIndex={0}>
|
||||||
|
<Organization location={currentTab} />
|
||||||
|
</MemoryRouter>
|
||||||
|
</I18nProvider>
|
||||||
|
).find('Organization');
|
||||||
|
setImmediate(async () => {
|
||||||
|
wrapper.setState({ activeTabKey: 1 });
|
||||||
|
});
|
||||||
|
wrapper.find('button').at(3).simulate('click');
|
||||||
|
expect(wrapper.state('activeTabKey')).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
19
src/app.scss
19
src/app.scss
@@ -283,6 +283,25 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.orgListAlert-actionBtn{
|
||||||
|
margin:0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orgListDetete-progressBar{
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orgListDelete-progressBar-noShow{
|
||||||
|
display: none;
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.OrgsTab-closeButton {
|
||||||
|
color: black;
|
||||||
|
float:right;
|
||||||
|
position: relative;
|
||||||
|
top: -60px;
|
||||||
|
}
|
||||||
.awx-c-form-action-group {
|
.awx-c-form-action-group {
|
||||||
float: right;
|
float: right;
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -5,20 +5,21 @@ import {
|
|||||||
Switch,
|
Switch,
|
||||||
Route,
|
Route,
|
||||||
withRouter,
|
withRouter,
|
||||||
Redirect
|
Redirect,
|
||||||
|
Link
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
PageSection
|
PageSection,
|
||||||
|
Tab,
|
||||||
|
Tabs
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
|
import {
|
||||||
|
TimesIcon
|
||||||
|
} from '@patternfly/react-icons';
|
||||||
import { withNetwork } from '../../../../contexts/Network';
|
import { withNetwork } from '../../../../contexts/Network';
|
||||||
|
|
||||||
import Tabs from '../../../../components/Tabs/Tabs';
|
|
||||||
import Tab from '../../../../components/Tabs/Tab';
|
|
||||||
import NotifyAndRedirect from '../../../../components/NotifyAndRedirect';
|
import NotifyAndRedirect from '../../../../components/NotifyAndRedirect';
|
||||||
|
|
||||||
import OrganizationAccess from './OrganizationAccess';
|
import OrganizationAccess from './OrganizationAccess';
|
||||||
import OrganizationDetail from './OrganizationDetail';
|
import OrganizationDetail from './OrganizationDetail';
|
||||||
import OrganizationEdit from './OrganizationEdit';
|
import OrganizationEdit from './OrganizationEdit';
|
||||||
@@ -33,9 +34,17 @@ class Organization extends Component {
|
|||||||
organization: null,
|
organization: null,
|
||||||
error: false,
|
error: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
|
tabElements: [
|
||||||
|
{ name: i18nMark('Details'), link: `${props.match.url}/details`, id: 0 },
|
||||||
|
{ name: i18nMark('Access'), link: `${props.match.url}/access`, id: 1 },
|
||||||
|
{ name: i18nMark('Teams'), link: `${props.match.url}/teams`, id: 2 },
|
||||||
|
{ name: i18nMark('Notifications'), link: `${props.match.url}/notifications`, id: 3 },
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fetchOrganization = this.fetchOrganization.bind(this);
|
this.fetchOrganization = this.fetchOrganization.bind(this);
|
||||||
|
this.handleTabSelect = this.handleTabSelect.bind(this);
|
||||||
|
this.checkLocation = this.checkLocation.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@@ -62,48 +71,80 @@ class Organization extends Component {
|
|||||||
setBreadcrumb(data);
|
setBreadcrumb(data);
|
||||||
this.setState({ organization: data, loading: false });
|
this.setState({ organization: data, loading: false });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
<<<<<<< HEAD
|
||||||
handleHttpError(error) || this.setState({ error: true, loading: false });
|
handleHttpError(error) || this.setState({ error: true, loading: false });
|
||||||
|
=======
|
||||||
|
this.setState({ error: true });
|
||||||
|
} finally {
|
||||||
|
this.setState({ loading: false });
|
||||||
|
this.checkLocation();
|
||||||
|
>>>>>>> addresses PR issues
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkLocation () {
|
||||||
|
const { location } = this.props;
|
||||||
|
const { tabElements } = this.state;
|
||||||
|
const activeTab = tabElements.filter(tabElement => tabElement.link === location.pathname);
|
||||||
|
this.setState({ activeTabKey: activeTab[0].id });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleTabSelect (event, eventKey) {
|
||||||
|
const { history } = this.props;
|
||||||
|
const { tabElements } = this.state;
|
||||||
|
|
||||||
|
const tab = tabElements.find(tabElement => tabElement.id === eventKey);
|
||||||
|
history.push(tab.link);
|
||||||
|
const activeTab = tabElements.filter(selectedTab => selectedTab.link === tab.link)
|
||||||
|
.map(selectedTab => selectedTab.id);
|
||||||
|
this.setState({ activeTabKey: activeTab[0] });
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
location,
|
location,
|
||||||
match,
|
match,
|
||||||
history
|
history
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
activeTabKey,
|
||||||
organization,
|
organization,
|
||||||
error,
|
error,
|
||||||
loading
|
loading,
|
||||||
|
tabElements
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const tabElements = [
|
|
||||||
{ name: i18nMark('Details'), link: `${match.url}/details` },
|
|
||||||
{ name: i18nMark('Access'), link: `${match.url}/access` },
|
|
||||||
{ name: i18nMark('Teams'), link: `${match.url}/teams` },
|
|
||||||
{ name: i18nMark('Notifications'), link: `${match.url}/notifications` },
|
|
||||||
];
|
|
||||||
|
|
||||||
let cardHeader = (
|
let cardHeader = (
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<I18n>
|
<I18n>
|
||||||
{({ i18n }) => (
|
{({ i18n }) => (
|
||||||
<Tabs
|
<>
|
||||||
labelText={i18n._(t`Organization detail tabs`)}
|
<Tabs
|
||||||
closeButton={{ link: '/organizations', text: i18nMark('Close') }}
|
labeltext={i18n._(t`Organization detail tabs`)}
|
||||||
>
|
activeKey={activeTabKey}
|
||||||
{tabElements.map(tabElement => (
|
onSelect={(event, eventKey) => {
|
||||||
<Tab
|
this.handleTabSelect(event, eventKey);
|
||||||
key={tabElement.name}
|
}}
|
||||||
link={tabElement.link}
|
>
|
||||||
replace
|
{tabElements.map(tabElement => (
|
||||||
>
|
<Tab
|
||||||
{tabElement.name}
|
className={`${tabElement.name}`}
|
||||||
</Tab>
|
aria-label={`${tabElement.name}`}
|
||||||
))}
|
eventKey={tabElement.id}
|
||||||
</Tabs>
|
key={tabElement.id}
|
||||||
|
link={tabElement.link}
|
||||||
|
title={tabElement.name}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Tabs>
|
||||||
|
<Link
|
||||||
|
aria-label="Close"
|
||||||
|
title="Close"
|
||||||
|
to="/organizations"
|
||||||
|
>
|
||||||
|
<TimesIcon className="OrgsTab-closeButton" />
|
||||||
|
</Link>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</I18n>
|
</I18n>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -185,5 +226,10 @@ class Organization extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
export default withNetwork(withRouter(Organization));
|
export default withNetwork(withRouter(Organization));
|
||||||
|
=======
|
||||||
|
export { Organization as _Organization };
|
||||||
|
export default withRouter(Organization);
|
||||||
|
>>>>>>> addresses PR issues
|
||||||
|
|||||||
Reference in New Issue
Block a user