Commit 98bea099 by Torkel Ödegaard Committed by GitHub

OrgSwitcher: Fixed issue rendering org switcher even when it's not open (#21061)

* OrgSwitcher: Fixed issue rendering org switcher even when it's not open

* Updated test

* Fixed unit test
parent 818972f1
......@@ -9,7 +9,6 @@ import config from 'app/core/config';
interface Props {
onDismiss: () => void;
isOpen: boolean;
}
interface State {
......@@ -42,13 +41,13 @@ export class OrgSwitcher extends React.PureComponent<Props, State> {
}
render() {
const { onDismiss, isOpen } = this.props;
const { onDismiss } = this.props;
const { orgs } = this.state;
const currentOrgId = contextSrv.user.orgId;
return (
<Modal title="Switch Organization" icon="random" onDismiss={onDismiss} isOpen={isOpen}>
<Modal title="Switch Organization" icon="random" onDismiss={onDismiss} isOpen={true}>
<table className="filter-table form-inline">
<thead>
<tr>
......
......@@ -48,6 +48,7 @@ describe('Render', () => {
},
});
wrapper.find('.sidemenu-org-switcher a').simulate('click');
expect(wrapper).toMatchSnapshot();
});
......
......@@ -67,7 +67,7 @@ class BottomNavLinks extends PureComponent<Props, State> {
</li>
)}
<OrgSwitcher onDismiss={this.toggleSwitcherModal} isOpen={showSwitcherModal} />
{showSwitcherModal && <OrgSwitcher onDismiss={this.toggleSwitcherModal} />}
{link.children &&
link.children.map((child, index) => {
......
......@@ -15,10 +15,6 @@ exports[`Render should render children 1`] = `
className="dropdown-menu dropdown-menu--sidemenu"
role="menu"
>
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li
key="undefined-0"
>
......@@ -66,10 +62,6 @@ exports[`Render should render component 1`] = `
className="dropdown-menu dropdown-menu--sidemenu"
role="menu"
>
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li
className="side-menu-header"
>
......@@ -127,7 +119,6 @@ exports[`Render should render organization switcher 1`] = `
</a>
</li>
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li
......@@ -165,10 +156,6 @@ exports[`Render should render subtitle 1`] = `
subtitle
</span>
</li>
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li
className="side-menu-header"
>
......
......@@ -33,7 +33,7 @@ let orgSwitcher: OrgSwitcher;
describe('OrgSwitcher', () => {
describe('when switching org', () => {
beforeEach(async () => {
wrapper = shallow(<OrgSwitcher onDismiss={() => {}} isOpen={true} />);
wrapper = shallow(<OrgSwitcher onDismiss={() => {}} />);
orgSwitcher = wrapper.instance() as OrgSwitcher;
orgSwitcher.setWindowLocation = jest.fn();
wrapper.update();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment