From ea4c678facd58d4c89a23ac9ef56434e84daf40c Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 10 Oct 2019 09:21:35 -0700 Subject: [PATCH] Expose iOS "setting" in settings Summary: Adds an iOS "setting" to the settings, but it's automatically set based on xcode-select for minimum required effort. Helpful text added to tell you how to enable it if it's disabled. Reviewed By: passy Differential Revision: D17830940 fbshipit-source-id: 53e1e40c5b96e29b30036259cc774ab14097a1da --- src/chrome/SettingsSheet.tsx | 25 ++++++++++++++++++++----- src/chrome/settings/ToggledSection.tsx | 17 ++++++++++------- src/chrome/settings/configFields.tsx | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/chrome/SettingsSheet.tsx b/src/chrome/SettingsSheet.tsx index 7f6981a05..db86d2d00 100644 --- a/src/chrome/SettingsSheet.tsx +++ b/src/chrome/SettingsSheet.tsx @@ -13,7 +13,7 @@ import {State as Store} from '../reducers'; import {Settings} from '../reducers/settings'; import {flush} from '../utils/persistor'; import ToggledSection from './settings/ToggledSection'; -import {FilePathConfigField} from './settings/configFields'; +import {FilePathConfigField, ConfigText} from './settings/configFields'; import {remote} from 'electron'; import isEqual from 'lodash.isequal'; @@ -35,6 +35,7 @@ type OwnProps = { type StateFromProps = { settings: Settings; + isXcodeDetected: boolean; }; type DispatchFromProps = { @@ -65,8 +66,8 @@ class SettingsSheet extends Component { Settings { this.setState({ updatedSettings: { @@ -88,7 +89,18 @@ class SettingsSheet extends Component { }} /> - + + {' '} + +
@@ -110,6 +122,9 @@ class SettingsSheet extends Component { } export default connect( - ({settingsState}) => ({settings: settingsState}), + ({settingsState, application}) => ({ + settings: settingsState, + isXcodeDetected: application.xcodeCommandLineToolsDetected, + }), {updateSettings}, )(SettingsSheet); diff --git a/src/chrome/settings/ToggledSection.tsx b/src/chrome/settings/ToggledSection.tsx index 399326ffe..8aee4896b 100644 --- a/src/chrome/settings/ToggledSection.tsx +++ b/src/chrome/settings/ToggledSection.tsx @@ -17,28 +17,31 @@ const GreyedOutOverlay = styled('div')({ opacity: 0.6, height: '100%', position: 'absolute', - left: 50, + left: 0, right: 0, }); export default function ToggledSection(props: { label: string; - enabled: boolean; - onChange: (value: boolean) => void; - children: React.ReactNode; + toggled: boolean; + onChange?: (value: boolean) => void; + children?: React.ReactNode; + // Whether to disallow interactions with this toggle + frozen?: boolean; }) { return ( props.onChange(!props.enabled)} - toggled={props.enabled} + onClick={() => props.onChange && props.onChange(!props.toggled)} + toggled={props.toggled} /> + {props.frozen && } {props.children} - {props.enabled ? null : } + {props.toggled ? null : } ); diff --git a/src/chrome/settings/configFields.tsx b/src/chrome/settings/configFields.tsx index 804771012..8dfa97cd1 100644 --- a/src/chrome/settings/configFields.tsx +++ b/src/chrome/settings/configFields.tsx @@ -36,10 +36,21 @@ const CenteredGlyph = styled(Glyph)({ marginLeft: 10, }); +const GreyedOutOverlay = styled('div')({ + backgroundColor: '#EFEEEF', + borderRadius: 4, + opacity: 0.6, + height: '100%', + position: 'absolute', + left: 0, + right: 0, +}); + export function FilePathConfigField(props: { label: string; defaultValue: string; onChange: (path: string) => void; + frozen?: boolean; }) { const [value, setValue] = useState(props.defaultValue); const [isValid, setIsValid] = useState(true); @@ -80,6 +91,16 @@ export function FilePathConfigField(props: { {isValid ? null : ( )} + {props.frozen && } + + ); +} + +export function ConfigText(props: {content: string; frozen?: boolean}) { + return ( + + {props.content} + {props.frozen && } ); }