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
This commit is contained in:
Torkel Ödegaard
2019-12-13 09:27:45 +01:00
committed by GitHub
parent 818972f11b
commit 98bea0990f
5 changed files with 5 additions and 18 deletions

View File

@@ -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>

View File

@@ -48,6 +48,7 @@ describe('Render', () => {
},
});
wrapper.find('.sidemenu-org-switcher a').simulate('click');
expect(wrapper).toMatchSnapshot();
});

View File

@@ -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) => {

View File

@@ -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"
>