Skip to content

Commit 8503ee5

Browse files
committed
feat: close app from mainmenu
closes #282
1 parent 0c56268 commit 8503ee5

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/components/common/MainMenu.js

+20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import List from '@material-ui/core/List';
1515
import ShowChartIcon from '@material-ui/icons/ShowChart';
1616
import HomeIcon from '@material-ui/icons/Home';
1717
import PublishIcon from '@material-ui/icons/Publish';
18+
import CloseIcon from '@material-ui/icons/ExitToApp';
1819
import SettingsIcon from '@material-ui/icons/Settings';
1920
import { Online, Offline } from 'react-detect-offline';
2021
import { withTranslation } from 'react-i18next';
@@ -200,6 +201,24 @@ export class MainMenu extends Component {
200201
return null;
201202
};
202203

204+
renderCloseApp = () => {
205+
const { t } = this.props;
206+
207+
return (
208+
<MenuItem
209+
onClick={() => {
210+
window.close();
211+
}}
212+
button
213+
>
214+
<ListItemIcon>
215+
<CloseIcon />
216+
</ListItemIcon>
217+
<ListItemText primary={t('Quit')} />
218+
</MenuItem>
219+
);
220+
};
221+
203222
renderAuthenticatedMenu() {
204223
const {
205224
authenticated,
@@ -311,6 +330,7 @@ export class MainMenu extends Component {
311330
{this.renderClassrooms()}
312331
{this.renderDeveloperMode()}
313332
{this.renderSignOut()}
333+
{this.renderCloseApp()}
314334
</List>
315335
);
316336
}

src/components/common/MainMenu.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '../../config/paths';
1818

1919
const MENUITEM_OFFLINE_NUMBER = 2;
20-
const MENUITEM_OFFLINE_ONLINE_COUNT = 10;
20+
const MENUITEM_OFFLINE_ONLINE_COUNT = 11;
2121

2222
const createMainMenuProps = (developerMode, path, authenticated = true) => {
2323
return {

src/components/common/__snapshots__/MainMenu.test.js.snap

+22
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ exports[`<MainMenu /> <MainMenu /> with developerMode = false renders correctly
168168
primary="Sign Out"
169169
/>
170170
</WithStyles(ForwardRef(MenuItem))>
171+
<WithStyles(ForwardRef(MenuItem))
172+
button={true}
173+
onClick={[Function]}
174+
>
175+
<WithStyles(ForwardRef(ListItemIcon))>
176+
<ExitToAppIcon />
177+
</WithStyles(ForwardRef(ListItemIcon))>
178+
<WithStyles(ForwardRef(ListItemText))
179+
primary="Quit"
180+
/>
181+
</WithStyles(ForwardRef(MenuItem))>
171182
</WithStyles(ForwardRef(List))>
172183
`;
173184

@@ -352,5 +363,16 @@ exports[`<MainMenu /> <MainMenu /> with developerMode = true renders correctly 1
352363
primary="Sign Out"
353364
/>
354365
</WithStyles(ForwardRef(MenuItem))>
366+
<WithStyles(ForwardRef(MenuItem))
367+
button={true}
368+
onClick={[Function]}
369+
>
370+
<WithStyles(ForwardRef(ListItemIcon))>
371+
<ExitToAppIcon />
372+
</WithStyles(ForwardRef(ListItemIcon))>
373+
<WithStyles(ForwardRef(ListItemText))
374+
primary="Quit"
375+
/>
376+
</WithStyles(ForwardRef(MenuItem))>
355377
</WithStyles(ForwardRef(List))>
356378
`;

0 commit comments

Comments
 (0)