Skip to content

Commit

Permalink
fix(settings): provide privacypolicy URL&change default settings for …
Browse files Browse the repository at this point in the history
…mas (#1471)

* fix(settings): provide privacypolicy URL&change default settings for mas

* fix(setupdialog): give react hook a dependency

* fix(settings): disable all settings by default & add links to general
  • Loading branch information
JPSchellenberg committed Apr 21, 2021
1 parent 152f8be commit c6de423
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 69 deletions.
9 changes: 0 additions & 9 deletions client/src/state/Settings/SettingsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ export default function settingsReducer(
try {
switch (action.type) {
case SETTINGS_GET_SETTINGS_SUCCESS:
if (action.payload.firstOpen) {
return {
...action.payload,
privacyPolicyConsent: true,
usageStatistics: true,
bugTracking: true,
autoUpdates: true
};
}
return action.payload;

case SETTINGS_CHANGE:
Expand Down
3 changes: 2 additions & 1 deletion client/src/state/System/SystemReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
} from './SystemTypes';

export const initialState: ISystemState = {
platformSupportsUpdates: true
platformSupportsUpdates: true,
platform: 'mac'
};

export default function settingsReducer(
Expand Down
3 changes: 3 additions & 0 deletions client/src/state/System/SystemTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ export interface IState {

export interface ISystemState {
platformSupportsUpdates: boolean;
platform: Platform;
}

type Platform = 'mac' | 'mas' | 'win' | 'win-store' | 'linux' | NodeJS.Platform;

export const SYSTEM_GET_SYSTEM_REQUEST = 'SYSTEM_GET_SYSTEM_REQUEST';
export const SYSTEM_GET_SYSTEM_SUCCESS = 'SYSTEM_GET_SYSTEM_SUCCESS';
export const SYSTEM_GET_SYSTEM_ERROR = 'SYSTEM_GET_SYSTEM_ERROR';
Expand Down
65 changes: 44 additions & 21 deletions client/src/views/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import SettingsList from './components/Settings/GeneralSettingsList';
import AccountSettingsList from './components/Settings/AccountSettingsList';
import SettingsLibraryManagement from './components/Settings/LibraryManagement';
import UpdateSettings from './components/Settings/UpdatesSettings';
import LinkList from './components/Settings/LinkList';

import { IState } from '../state';
import { track } from '../state/track/actions';
Expand Down Expand Up @@ -70,7 +71,8 @@ const useStyles = makeStyles((theme: Theme) =>
background: theme.palette.background.default
},
paper: {
minWidth: '640px'
minWidth: '640px',
margin: '20px'
},
drawer: {
width: drawerWidth,
Expand Down Expand Up @@ -226,26 +228,47 @@ export default function FullScreenDialog() {
<DialogContent className={classes.bg}>
<div className={classes.root}>
<div className={classes.center}>
<Paper className={classes.paper}>
{(() => {
switch (section) {
case 'general':
default:
return <SettingsList />;

case 'updates':
return <UpdateSettings />;

case 'h5p-library-administration':
return (
<SettingsLibraryManagement endpointUrl="/api/v1/h5p/libraries" />
);

case 'account':
return <AccountSettingsList />;
}
})()}
</Paper>
{(() => {
switch (section) {
case 'general':
default:
return (
<div>
<Paper
className={classes.paper}
>
<SettingsList />{' '}
</Paper>
<Paper
className={classes.paper}
>
<LinkList />
</Paper>
</div>
);

case 'updates':
return (
<Paper className={classes.paper}>
<UpdateSettings />{' '}
</Paper>
);

case 'h5p-library-administration':
return (
<Paper className={classes.paper}>
<SettingsLibraryManagement endpointUrl="/api/v1/h5p/libraries" />{' '}
</Paper>
);

case 'account':
return (
<Paper className={classes.paper}>
<AccountSettingsList />{' '}
</Paper>
);
}
})()}
</div>
</div>
</DialogContent>
Expand Down
42 changes: 42 additions & 0 deletions client/src/views/components/Settings/LinkList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { useTranslation } from 'react-i18next';

import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import ListSubheader from '@material-ui/core/ListSubheader';

import PolicyIcon from '@material-ui/icons/Policy';

export default function SettingsLinkList() {
const { t } = useTranslation();

return (
<List
subheader={
<ListSubheader>{t('settings.links.header')}</ListSubheader>
}
>
<a
href="https://www.lumi.education/app/privacy-policy"
target="_blank"
rel="noreferrer"
style={{ color: 'inherit', textDecoration: 'inherit' }}
>
<ListItem>
<ListItemIcon>
<PolicyIcon />
</ListItemIcon>
<ListItemText
id="switch-list-label-privacy-policy"
primary={
'https://www.Lumi.education/app/privacy-policy'
}
secondary={t('privacy_policy.title')}
/>
</ListItem>
</a>
</List>
);
}
61 changes: 26 additions & 35 deletions client/src/views/components/SetupDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import BugReportIcon from '@material-ui/icons/BugReport';
import InsertChartIcon from '@material-ui/icons/InsertChart';
import UpdateIcon from '@material-ui/icons/Update';
import TranslateIcon from '@material-ui/icons/Translate';
import GitHubIcon from '@material-ui/icons/GitHub';

import LanguageList from './Settings/LanguageList';
import LinkList from './Settings/LinkList';

import { IState, actions } from '../../state';

Expand Down Expand Up @@ -91,6 +91,7 @@ export default function CustomizedDialogs() {
const platformSupportsUpdates = useSelector(
(state: IState) => state.system.platformSupportsUpdates
);

const classes = useStyles();
const { t } = useTranslation();

Expand All @@ -100,6 +101,19 @@ export default function CustomizedDialogs() {
);
};

const handleAcceptAll = () => {
dispatch(
actions.settings.updateSettings({
...settings,
bugTracking: true,
usageStatistics: true,
privacyPolicyConsent: true,
autoUpdates: true,
firstOpen: false
})
);
};

return (
<Dialog
// onClose={handleClose}
Expand All @@ -110,44 +124,14 @@ export default function CustomizedDialogs() {
<Typography variant="body2" gutterBottom>
{t('setup_dialog.description')}
</Typography>
<LinkList />

<a
href="https://www.lumi.education/app/privacy-policy"
target="_blank"
rel="noreferrer"
style={{ color: 'inherit', textDecoration: 'inherit' }}
>
<Button
variant="contained"
color="secondary"
className={classes.button}
startIcon={<PolicyIcon />}
>
{t('privacy_policy.title')}
</Button>
</a>
<a
href="https://www.github.com/Lumieducation/Lumi"
target="_blank"
rel="noreferrer"
style={{ color: 'inherit', textDecoration: 'inherit' }}
>
<Button
variant="contained"
color="secondary"
className={classes.button}
startIcon={<GitHubIcon />}
>
Open Source
</Button>
</a>
<List
subheader={
<ListSubheader>
{t('settings.appbar.label')}
</ListSubheader>
}
// className={classes.list}
>
<ListItem>
<ListItemIcon>
Expand Down Expand Up @@ -285,12 +269,19 @@ export default function CustomizedDialogs() {
</DialogContent>
<DialogActions>
<Button
autoFocus
onClick={handleSave}
color="primary"
color="secondary"
disabled={!settings.privacyPolicyConsent}
>
{t('setup_dialog.save')}
{t('setup_dialog.accept_selected')}
</Button>
<Button
autoFocus={true}
onClick={handleAcceptAll}
color="primary"
// disabled={!settings.privacyPolicyConsent}
>
{t('setup_dialog.accept_all')}
</Button>
</DialogActions>
</Dialog>
Expand Down
8 changes: 6 additions & 2 deletions locales/lumi/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
"not-set": "Email is not set"
}
},
"links": {
"header": "Links"
},
"h5p-library-administration": {
"header": "Installed H5P libraries",
"notifications": {
Expand Down Expand Up @@ -179,8 +182,9 @@
},
"setup_dialog": {
"description": "Protecting the individual's privacy is important for us. We only collect the information you choose to give us, and we process it with your consent. We want to be as transparent as possible. However Lumi relies on some connections and data transfers to work.",
"save": "Save",
"consent_warning": "You need to at least consent to the privacy policy to use this application."
"consent_warning": "You need to at least consent to the privacy policy to use this application.",
"accept_all": "Accept all",
"accept_selected": "Accept selected"
},
"menu": {
"mac": {
Expand Down
26 changes: 25 additions & 1 deletion server/src/routes/systemRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ import * as Sentry from '@sentry/electron';

import { platformSupportsUpdates } from '../updater';

export type Platform =
| 'mac'
| 'mas'
| 'win'
| 'win-store'
| 'linux'
| NodeJS.Platform;

function getPlatform(): Platform {
if (process.mas) {
return 'mas';
}

if (process.windowsStore) {
return 'win-store';
}

if (process.platform === 'darwin') {
return 'mac';
}

return process.platform;
}
export default function (): express.Router {
const router = express.Router();

Expand All @@ -15,7 +38,8 @@ export default function (): express.Router {
) => {
try {
res.status(200).json({
platformSupportsUpdates: platformSupportsUpdates()
platformSupportsUpdates: platformSupportsUpdates(),
platform: getPlatform()
});
} catch (error) {
Sentry.captureException(error);
Expand Down

0 comments on commit c6de423

Please sign in to comment.