Move settings, launcherSettings, GKs to app / flipper-server-core
Summary: This diff moves a lot of stuff from the client to the server. This diff is fairly large, as a lot of concept closely relate, although some things have split off to the earlier diffs in the stack, or are still to follow (like making intern requests). This diff primarily moves reading and storing settings and GKs from client to server (both flipper and launcher settings). This means that settings are no longer persisted by Redux (which only exists on client). Most other changes are fallout from that. For now settings are just one big object, although we might need to separate settings that are only make sense in an Electron context. For example launcher settings. Reviewed By: passy, aigoncharov Differential Revision: D32498649 fbshipit-source-id: d842faf7a7f03774b621c7656e53a9127afc6192
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eed19b3a3d
commit
bca169df73
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* 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 type GKID = string;
|
||||
|
||||
export const TEST_PASSING_GK = 'TEST_PASSING_GK';
|
||||
export const TEST_FAILING_GK = 'TEST_FAILING_GK';
|
||||
export type GKMap = {[key: string]: boolean};
|
||||
|
||||
const whitelistedGKs: Array<GKID> = [];
|
||||
|
||||
export function loadGKs(_username: string, _gks: Array<GKID>): Promise<GKMap> {
|
||||
return Promise.reject(
|
||||
new Error('Implement your custom logic for loading GK'),
|
||||
);
|
||||
}
|
||||
|
||||
export function loadDistilleryGK(
|
||||
_gk: GKID,
|
||||
): Promise<{[key: string]: {result: boolean}}> {
|
||||
return Promise.reject(
|
||||
new Error('Implement your custom logic for loading GK'),
|
||||
);
|
||||
}
|
||||
|
||||
export default class GK {
|
||||
static init() {}
|
||||
|
||||
static get(id: GKID): boolean {
|
||||
if (process.env.NODE_ENV === 'test' && id === TEST_PASSING_GK) {
|
||||
return true;
|
||||
}
|
||||
if (whitelistedGKs.includes(id)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static serializeGKs() {
|
||||
return '';
|
||||
}
|
||||
|
||||
static async withWhitelistedGK(
|
||||
id: GKID,
|
||||
callback: () => Promise<void> | void,
|
||||
) {
|
||||
whitelistedGKs.push(id);
|
||||
try {
|
||||
const p = callback();
|
||||
if (p) {
|
||||
await p;
|
||||
}
|
||||
} finally {
|
||||
const idx = whitelistedGKs.indexOf(id);
|
||||
if (idx !== -1) {
|
||||
whitelistedGKs.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {Tristate} from '../reducers/settings';
|
||||
import ReleaseChannel from '../ReleaseChannel';
|
||||
import {Tristate, ReleaseChannel} from 'flipper-common';
|
||||
|
||||
export default function (_props: {
|
||||
isPrefetchingEnabled: Tristate;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import {Settings} from '../reducers/settings';
|
||||
|
||||
export default async function setupPrefetcher(_settings: Settings) {}
|
||||
export const shouldInstallPrefetcher = () => false;
|
||||
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import ReleaseChannel from '../ReleaseChannel';
|
||||
import {ReleaseChannel} from 'flipper-common';
|
||||
|
||||
export default {
|
||||
updateServer: 'https://www.facebook.com/fbflipper/public/latest.json',
|
||||
|
||||
@@ -42,12 +42,4 @@ export default Object.freeze({
|
||||
},
|
||||
|
||||
SUPPORT_GROUPS: [],
|
||||
|
||||
// Only WebSocket requests from the following origin prefixes will be accepted
|
||||
VALID_WEB_SOCKET_REQUEST_ORIGIN_PREFIXES: [
|
||||
'chrome-extension://',
|
||||
'localhost:',
|
||||
'http://localhost:',
|
||||
'app://',
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user