Setting to choose release channel

Summary: Add possibility to choose release channel in Flipper Settings

Reviewed By: passy

Differential Revision: D25300775

fbshipit-source-id: 55fc86f0e12b9f3a4603bb40b038f5c0e5f30b3b
This commit is contained in:
Anton Nikolaev
2020-12-03 07:21:19 -08:00
committed by Facebook GitHub Bot
parent dd7c2ab96d
commit a7573139a2
6 changed files with 45 additions and 7 deletions

View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export enum ReleaseChannel {
DEFAULT = 'default',
STABLE = 'stable',
INSIDERS = 'insiders',
}
export default ReleaseChannel;

View File

@@ -233,6 +233,15 @@ class SettingsSheet extends Component<Props, State> {
}, },
}); });
}} }}
releaseChannel={this.state.updatedLauncherSettings.releaseChannel}
onReleaseChannelChange={(v) => {
this.setState({
updatedLauncherSettings: {
...this.state.updatedLauncherSettings,
releaseChannel: v,
},
});
}}
/> />
<SandySettingsPanel <SandySettingsPanel
toggled={this.state.updatedSettings.disableSandy} toggled={this.state.updatedSettings.disableSandy}

View File

@@ -22,14 +22,14 @@ import {promises as fs} from 'fs';
import {remote} from 'electron'; import {remote} from 'electron';
import path from 'path'; import path from 'path';
const ConfigFieldContainer = styled(FlexRow)({ export const ConfigFieldContainer = styled(FlexRow)({
paddingLeft: 10, paddingLeft: 10,
paddingRight: 10, paddingRight: 10,
marginBottom: 5, marginBottom: 5,
paddingTop: 5, paddingTop: 5,
}); });
const InfoText = styled(Text)({ export const InfoText = styled(Text)({
lineHeight: 1.35, lineHeight: 1.35,
paddingTop: 5, paddingTop: 5,
}); });

View File

@@ -8,12 +8,15 @@
*/ */
import {Tristate} from '../reducers/settings'; import {Tristate} from '../reducers/settings';
import ReleaseChannel from '../ReleaseChannel';
export default function (_props: { export default function (_props: {
isPrefetchingEnabled: Tristate; isPrefetchingEnabled: Tristate;
onEnablePrefetchingChange: (v: Tristate) => void; onEnablePrefetchingChange: (v: Tristate) => void;
isLocalPinIgnored: boolean; isLocalPinIgnored: boolean;
onIgnoreLocalPinChange: (v: boolean) => void; onIgnoreLocalPinChange: (v: boolean) => void;
releaseChannel: ReleaseChannel;
onReleaseChannelChange: (v: ReleaseChannel) => void;
}) { }) {
return null; return null;
} }

View File

@@ -8,8 +8,10 @@
*/ */
import {Actions} from './index'; import {Actions} from './index';
import ReleaseChannel from '../ReleaseChannel';
export type LauncherSettings = { export type LauncherSettings = {
releaseChannel: ReleaseChannel;
ignoreLocalPin: boolean; ignoreLocalPin: boolean;
}; };
@@ -19,6 +21,7 @@ export type Action = {
}; };
export const defaultLauncherSettings: LauncherSettings = { export const defaultLauncherSettings: LauncherSettings = {
releaseChannel: ReleaseChannel.DEFAULT,
ignoreLocalPin: false, ignoreLocalPin: false,
}; };

View File

@@ -9,12 +9,13 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import TOML from '@iarna/toml'; import TOML, {JsonMap} from '@iarna/toml';
import {Storage} from 'redux-persist/es/types'; import {Storage} from 'redux-persist/es/types';
import { import {
defaultLauncherSettings, defaultLauncherSettings,
LauncherSettings, LauncherSettings,
} from '../reducers/launcherSettings'; } from '../reducers/launcherSettings';
import ReleaseChannel from '../ReleaseChannel';
export default class LauncherSettingsStorage implements Storage { export default class LauncherSettingsStorage implements Storage {
constructor(readonly filepath: string) {} constructor(readonly filepath: string) {}
@@ -60,20 +61,26 @@ export default class LauncherSettingsStorage implements Storage {
interface FormattedSettings { interface FormattedSettings {
ignore_local_pin?: boolean; ignore_local_pin?: boolean;
release_channel?: ReleaseChannel;
} }
function serialize(value: LauncherSettings): string { function serialize(value: LauncherSettings): string {
const {ignoreLocalPin, ...rest} = value; const {ignoreLocalPin, releaseChannel, ...rest} = value;
return TOML.stringify({ const formattedSettings: FormattedSettings = {
...rest, ...rest,
ignore_local_pin: ignoreLocalPin, ignore_local_pin: ignoreLocalPin,
}); release_channel: releaseChannel,
};
return TOML.stringify(formattedSettings as JsonMap);
} }
function deserialize(content: string): LauncherSettings { function deserialize(content: string): LauncherSettings {
const {ignore_local_pin, ...rest} = TOML.parse(content) as FormattedSettings; const {ignore_local_pin, release_channel, ...rest} = TOML.parse(
content,
) as FormattedSettings;
return { return {
...rest, ...rest,
ignoreLocalPin: !!ignore_local_pin, ignoreLocalPin: !!ignore_local_pin,
releaseChannel: release_channel ?? ReleaseChannel.DEFAULT,
}; };
} }