Skip to content

Commit 138e707

Browse files
author
Jonas Gossens
committed
🐛 Fix bug that modeSwitch is hidden
if there are 2 modes, user and custom uac group, but no admin group
1 parent fd48829 commit 138e707

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/react-chayns-modeswitch/component/ModeSwitch.jsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default class ModeSwitch extends Component {
6464
constructor(props) {
6565
super(props);
6666

67+
this.showModeSwitch = this.showModeSwitch.bind(this);
6768
this.toggleModeSwitch = this.toggleModeSwitch.bind(this);
6869
this.switchMode = this.switchMode.bind(this);
6970
this.setMode = this.setMode.bind(this);
@@ -205,10 +206,25 @@ export default class ModeSwitch extends Component {
205206
this.setState({ open: !open });
206207
}
207208

208-
render() {
209+
showModeSwitch() {
209210
const { show } = this.props;
211+
const { modes } = this.state;
212+
213+
let customModes = modes.length;
214+
if (modes.find(mode => mode.uacIds && mode.uacIds.indexOf(1) >= 0)) {
215+
customModes -= 1;
216+
}
217+
if (modes.find(mode => !mode.uacIds || (mode.uacIds && mode.uacIds.indexOf(0) >= 0))) {
218+
customModes -= 1;
219+
}
220+
221+
return (show || (show === null && (!ModeSwitch.adminSwitchSupport || modes.length > 2 || customModes))) && chayns.env.user.isAuthenticated;
222+
}
223+
224+
render() {
210225
const { modes, open, activeModeId } = this.state;
211-
if ((show || (show === null && (!ModeSwitch.adminSwitchSupport || modes.length > 2))) && chayns.env.user.isAuthenticated) {
226+
227+
if (this.showModeSwitch()) {
212228
return (
213229
<TappPortal>
214230
<div

0 commit comments

Comments
 (0)