Adds a notifyAvailableUpdate flag to config.json to disable update (#3992)

Summary:
We would like to version control Flipper and some of our custom plugins that are installed on developers' systems.
Flipper by default prompts users to upgrade so they sometimes do the update and then all our custom plugins break because they were compiled for an older version.
See https://github.com/facebook/flipper/issues/3947 for feature request info.

## Changelog

Adds notifyAvailable flag to config.json to disable prompting for users that "an update is available"

Pull Request resolved: https://github.com/facebook/flipper/pull/3992

Test Plan:
Tested by running locally.
Had to comment out the isProduction() check to confirm this it worked properly because this flag is false on dev versions.
Couldn't figure out how to manually test the handleOpenPluginDeeplink.tsx change but made a similar change there; happy to test that if you can tell me how to exercise that path.

Reviewed By: antonk52

Differential Revision: D39654481

Pulled By: antonk52

fbshipit-source-id: cef6b48d870915c48f620269c42d24b8ef1f4c29
This commit is contained in:
Ken Yee
2022-09-21 09:47:44 -07:00
committed by Facebook GitHub Bot
parent 3314c77ce9
commit fa9ba6f2d0
8 changed files with 27 additions and 4 deletions

View File

@@ -76,7 +76,7 @@ export type LauncherSettings = {
ignoreLocalPin: boolean;
};
// Settings that primarily only apply to Eelectron atm
// Settings that primarily only apply to Electron atm
// TODO: further separte between flipper-ui config and Electron config
export type ProcessConfig = {
disabledPlugins: string[];
@@ -90,6 +90,8 @@ export type ProcessConfig = {
launcherMsg: string | null;
// Controls whether to delegate to the launcher if present.
launcherEnabled: boolean;
// Control whether to suppress "update available" notifications
suppressPluginUpdateNotifications?: boolean;
};
export type Platform =

View File

@@ -17,6 +17,7 @@ test('config is decoded from env', () => {
launcherMsg: 'wubba lubba dub dub',
screenCapturePath: '/my/screenshot/path',
launcherEnabled: false,
suppressPluginUpdateNotifications: true,
}),
});
@@ -26,6 +27,7 @@ test('config is decoded from env', () => {
launcherMsg: 'wubba lubba dub dub',
screenCapturePath: '/my/screenshot/path',
launcherEnabled: false,
suppressPluginUpdateNotifications: true,
});
});
@@ -36,5 +38,6 @@ test('config is decoded from env with defaults', () => {
launcherMsg: undefined,
screenCapturePath: undefined,
launcherEnabled: true,
suppressPluginUpdateNotifications: false,
});
});

View File

@@ -18,5 +18,9 @@ export function loadProcessConfig(env: NodeJS.ProcessEnv): ProcessConfig {
screenCapturePath: json.screenCapturePath,
launcherEnabled:
typeof json.launcherEnabled === 'boolean' ? json.launcherEnabled : true,
suppressPluginUpdateNotifications:
typeof json.suppressPluginUpdateNotifications === 'boolean'
? json.suppressPluginUpdateNotifications
: false,
};
}

View File

@@ -15,6 +15,7 @@ import fbConfig from '../fb-stubs/config';
import {useStore} from '../utils/useStore';
import {getAppVersion} from '../utils/info';
import {checkForUpdate} from '../fb-stubs/checkForUpdate';
import {getRenderHostInstance} from 'flipper-frontend-core';
export type VersionCheckResult =
| {
@@ -63,6 +64,7 @@ export default function UpdateIndicator() {
// trigger the update check, unless there is a launcher message already
useEffect(() => {
const version = getAppVersion();
const config = getRenderHostInstance().serverConfig.processConfig;
if (launcherMsg && launcherMsg.message) {
if (launcherMsg.severity === 'error') {
notification.error({
@@ -81,7 +83,11 @@ export default function UpdateIndicator() {
duration: null,
});
}
} else if (version && isProduction()) {
} else if (
version &&
!config.suppressPluginUpdateNotifications &&
isProduction()
) {
reportPlatformFailures(
checkForUpdate(version).then((res) => {
if (res.kind === 'error') {

View File

@@ -274,7 +274,8 @@ async function waitForLogin(store: Store) {
}
async function verifyFlipperIsUpToDate(title: string) {
if (!isProduction() || isTest()) {
const config = getRenderHostInstance().serverConfig.processConfig;
if (!isProduction() || isTest() || config.suppressPluginUpdateNotifications) {
return;
}
const currentVersion = getAppVersion();

View File

@@ -137,6 +137,7 @@ function createStubRenderHost(): RenderHost {
launcherEnabled: false,
launcherMsg: null,
screenCapturePath: `/dev/null`,
suppressPluginUpdateNotifications: false,
},
settings: {
androidHome: `/dev/null`,

View File

@@ -216,7 +216,7 @@ app.on('ready', async () => {
{allowFileAccess: true},
);
} catch (e) {
console.error('Failed to loa React devtools from disk: ', e);
console.error('Failed to load React devtools from disk: ', e);
}
} else {
try {

View File

@@ -17,6 +17,7 @@ export const defaultConfig: Config = {
pluginPaths: [],
disabledPlugins: [],
darkMode: 'light',
suppressPluginUpdateNotifications: false,
};
export type Config = {
@@ -33,6 +34,7 @@ export type Config = {
updaterEnabled?: boolean;
launcherEnabled?: boolean;
darkMode: 'system' | 'light' | 'dark';
suppressPluginUpdateNotifications?: boolean;
};
const ensureConfigDirExists = async (path: fs.PathLike) => {
@@ -83,6 +85,10 @@ export default async function setup(argv: any) {
updaterEnabled: argv.updater,
launcherEnabled: argv.launcher,
launcherMsg: argv.launcherMsg,
suppressPluginUpdateNotifications:
typeof config.suppressPluginUpdateNotifications === 'boolean'
? config.suppressPluginUpdateNotifications
: false,
};
return config;