From c6de42381425347b73a21250eda89363e2ee5b80 Mon Sep 17 00:00:00 2001 From: Jan Philip Schellenberg Date: Wed, 21 Apr 2021 10:15:11 +0200 Subject: [PATCH] fix(settings): provide privacypolicy URL&change default settings for 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 --- client/src/state/Settings/SettingsReducer.ts | 9 --- client/src/state/System/SystemReducer.ts | 3 +- client/src/state/System/SystemTypes.ts | 3 + client/src/views/Settings.tsx | 65 +++++++++++++------ .../views/components/Settings/LinkList.tsx | 42 ++++++++++++ client/src/views/components/SetupDialog.tsx | 61 ++++++++--------- locales/lumi/en.json | 8 ++- server/src/routes/systemRoutes.ts | 26 +++++++- 8 files changed, 148 insertions(+), 69 deletions(-) create mode 100644 client/src/views/components/Settings/LinkList.tsx diff --git a/client/src/state/Settings/SettingsReducer.ts b/client/src/state/Settings/SettingsReducer.ts index 3488adc5e..b47e547c4 100644 --- a/client/src/state/Settings/SettingsReducer.ts +++ b/client/src/state/Settings/SettingsReducer.ts @@ -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: diff --git a/client/src/state/System/SystemReducer.ts b/client/src/state/System/SystemReducer.ts index b4dc71b92..36eaf17b6 100644 --- a/client/src/state/System/SystemReducer.ts +++ b/client/src/state/System/SystemReducer.ts @@ -7,7 +7,8 @@ import { } from './SystemTypes'; export const initialState: ISystemState = { - platformSupportsUpdates: true + platformSupportsUpdates: true, + platform: 'mac' }; export default function settingsReducer( diff --git a/client/src/state/System/SystemTypes.ts b/client/src/state/System/SystemTypes.ts index d571fb755..313a7b6ca 100644 --- a/client/src/state/System/SystemTypes.ts +++ b/client/src/state/System/SystemTypes.ts @@ -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'; diff --git a/client/src/views/Settings.tsx b/client/src/views/Settings.tsx index c4203e42a..2ecd9f2a2 100644 --- a/client/src/views/Settings.tsx +++ b/client/src/views/Settings.tsx @@ -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'; @@ -70,7 +71,8 @@ const useStyles = makeStyles((theme: Theme) => background: theme.palette.background.default }, paper: { - minWidth: '640px' + minWidth: '640px', + margin: '20px' }, drawer: { width: drawerWidth, @@ -226,26 +228,47 @@ export default function FullScreenDialog() {
- - {(() => { - switch (section) { - case 'general': - default: - return ; - - case 'updates': - return ; - - case 'h5p-library-administration': - return ( - - ); - - case 'account': - return ; - } - })()} - + {(() => { + switch (section) { + case 'general': + default: + return ( +
+ + {' '} + + + + +
+ ); + + case 'updates': + return ( + + {' '} + + ); + + case 'h5p-library-administration': + return ( + + {' '} + + ); + + case 'account': + return ( + + {' '} + + ); + } + })()}
diff --git a/client/src/views/components/Settings/LinkList.tsx b/client/src/views/components/Settings/LinkList.tsx new file mode 100644 index 000000000..ac889040d --- /dev/null +++ b/client/src/views/components/Settings/LinkList.tsx @@ -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 ( + {t('settings.links.header')} + } + > + + + + + + + + + + ); +} diff --git a/client/src/views/components/SetupDialog.tsx b/client/src/views/components/SetupDialog.tsx index dcb679097..f71be3e09 100644 --- a/client/src/views/components/SetupDialog.tsx +++ b/client/src/views/components/SetupDialog.tsx @@ -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'; @@ -91,6 +91,7 @@ export default function CustomizedDialogs() { const platformSupportsUpdates = useSelector( (state: IState) => state.system.platformSupportsUpdates ); + const classes = useStyles(); const { t } = useTranslation(); @@ -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 ( {t('setup_dialog.description')} + - - - - - - {t('settings.appbar.label')} } - // className={classes.list} > @@ -285,12 +269,19 @@ export default function CustomizedDialogs() { + diff --git a/locales/lumi/en.json b/locales/lumi/en.json index 9c736affd..fd1bca588 100644 --- a/locales/lumi/en.json +++ b/locales/lumi/en.json @@ -97,6 +97,9 @@ "not-set": "Email is not set" } }, + "links": { + "header": "Links" + }, "h5p-library-administration": { "header": "Installed H5P libraries", "notifications": { @@ -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": { diff --git a/server/src/routes/systemRoutes.ts b/server/src/routes/systemRoutes.ts index 22a7181c6..451abc009 100644 --- a/server/src/routes/systemRoutes.ts +++ b/server/src/routes/systemRoutes.ts @@ -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(); @@ -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);