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'; ...@@ -9,7 +9,6 @@ import config from 'app/core/config';
interface Props { interface Props {
onDismiss: () => void; onDismiss: () => void;
isOpen: boolean;
} }
interface State { interface State {
...@@ -42,13 +41,13 @@ export class OrgSwitcher extends React.PureComponent<Props, State> { ...@@ -42,13 +41,13 @@ export class OrgSwitcher extends React.PureComponent<Props, State> {
} }
render() { render() {
const { onDismiss, isOpen } = this.props; const { onDismiss } = this.props;
const { orgs } = this.state; const { orgs } = this.state;
const currentOrgId = contextSrv.user.orgId; const currentOrgId = contextSrv.user.orgId;
return ( 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"> <table className="filter-table form-inline">
<thead> <thead>
<tr> <tr>
......
...@@ -48,6 +48,7 @@ describe('Render', () => { ...@@ -48,6 +48,7 @@ describe('Render', () => {
}, },
}); });
wrapper.find('.sidemenu-org-switcher a').simulate('click');
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
}); });
......
...@@ -67,7 +67,7 @@ class BottomNavLinks extends PureComponent<Props, State> { ...@@ -67,7 +67,7 @@ class BottomNavLinks extends PureComponent<Props, State> {
</li> </li>
)} )}
<OrgSwitcher onDismiss={this.toggleSwitcherModal} isOpen={showSwitcherModal} /> {showSwitcherModal && <OrgSwitcher onDismiss={this.toggleSwitcherModal} />}
{link.children && {link.children &&
link.children.map((child, index) => { link.children.map((child, index) => {
......
...@@ -15,10 +15,6 @@ exports[`Render should render children 1`] = ` ...@@ -15,10 +15,6 @@ exports[`Render should render children 1`] = `
className="dropdown-menu dropdown-menu--sidemenu" className="dropdown-menu dropdown-menu--sidemenu"
role="menu" role="menu"
> >
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li <li
key="undefined-0" key="undefined-0"
> >
...@@ -66,10 +62,6 @@ exports[`Render should render component 1`] = ` ...@@ -66,10 +62,6 @@ exports[`Render should render component 1`] = `
className="dropdown-menu dropdown-menu--sidemenu" className="dropdown-menu dropdown-menu--sidemenu"
role="menu" role="menu"
> >
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li <li
className="side-menu-header" className="side-menu-header"
> >
...@@ -127,7 +119,6 @@ exports[`Render should render organization switcher 1`] = ` ...@@ -127,7 +119,6 @@ exports[`Render should render organization switcher 1`] = `
</a> </a>
</li> </li>
<OrgSwitcher <OrgSwitcher
isOpen={false}
onDismiss={[Function]} onDismiss={[Function]}
/> />
<li <li
...@@ -165,10 +156,6 @@ exports[`Render should render subtitle 1`] = ` ...@@ -165,10 +156,6 @@ exports[`Render should render subtitle 1`] = `
subtitle subtitle
</span> </span>
</li> </li>
<OrgSwitcher
isOpen={false}
onDismiss={[Function]}
/>
<li <li
className="side-menu-header" className="side-menu-header"
> >
......
...@@ -33,7 +33,7 @@ let orgSwitcher: OrgSwitcher; ...@@ -33,7 +33,7 @@ let orgSwitcher: OrgSwitcher;
describe('OrgSwitcher', () => { describe('OrgSwitcher', () => {
describe('when switching org', () => { describe('when switching org', () => {
beforeEach(async () => { beforeEach(async () => {
wrapper = shallow(<OrgSwitcher onDismiss={() => {}} isOpen={true} />); wrapper = shallow(<OrgSwitcher onDismiss={() => {}} />);
orgSwitcher = wrapper.instance() as OrgSwitcher; orgSwitcher = wrapper.instance() as OrgSwitcher;
orgSwitcher.setWindowLocation = jest.fn(); orgSwitcher.setWindowLocation = jest.fn();
wrapper.update(); 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