Expose isConnected and currentUser
Summary: Requested by antonk52 and MSYS team Reviewed By: passy Differential Revision: D44662243 fbshipit-source-id: 2bace476c4e79b6a05bfb89ddc3e6acb437c6c3b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f8a1f38c0a
commit
7f111a11de
@@ -249,8 +249,17 @@ test('log listeners are resumed and suspended automatically - 1', async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const baseFlipperLib = baseFlipperLibImplementation(
|
||||||
|
getRenderHostInstance(),
|
||||||
|
getLogger(),
|
||||||
|
);
|
||||||
_setFlipperLibImplementation({
|
_setFlipperLibImplementation({
|
||||||
...baseFlipperLibImplementation(getRenderHostInstance(), getLogger()),
|
...baseFlipperLib,
|
||||||
|
intern: {
|
||||||
|
...baseFlipperLib.intern,
|
||||||
|
currentUser: jest.fn(),
|
||||||
|
isConnected: jest.fn(),
|
||||||
|
},
|
||||||
createPaste: jest.fn(),
|
createPaste: jest.fn(),
|
||||||
enableMenuEntries: jest.fn(),
|
enableMenuEntries: jest.fn(),
|
||||||
selectPlugin: jest.fn(),
|
selectPlugin: jest.fn(),
|
||||||
@@ -328,8 +337,17 @@ test('log listeners are resumed and suspended automatically - 2', async () => {
|
|||||||
|
|
||||||
const client = new TestClient(device, [Plugin]);
|
const client = new TestClient(device, [Plugin]);
|
||||||
|
|
||||||
|
const baseFlipperLib = baseFlipperLibImplementation(
|
||||||
|
getRenderHostInstance(),
|
||||||
|
getLogger(),
|
||||||
|
);
|
||||||
_setFlipperLibImplementation({
|
_setFlipperLibImplementation({
|
||||||
...baseFlipperLibImplementation(getRenderHostInstance(), getLogger()),
|
...baseFlipperLib,
|
||||||
|
intern: {
|
||||||
|
...baseFlipperLib.intern,
|
||||||
|
currentUser: jest.fn(),
|
||||||
|
isConnected: jest.fn(),
|
||||||
|
},
|
||||||
createPaste: jest.fn(),
|
createPaste: jest.fn(),
|
||||||
enableMenuEntries: jest.fn(),
|
enableMenuEntries: jest.fn(),
|
||||||
selectPlugin: jest.fn(),
|
selectPlugin: jest.fn(),
|
||||||
|
|||||||
@@ -26,8 +26,12 @@ export function baseFlipperLibImplementation(
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Omit<
|
): Omit<
|
||||||
FlipperLib,
|
FlipperLib,
|
||||||
'enableMenuEntries' | 'selectPlugin' | 'showNotification' | 'createPaste'
|
| 'enableMenuEntries'
|
||||||
> {
|
| 'selectPlugin'
|
||||||
|
| 'showNotification'
|
||||||
|
| 'createPaste'
|
||||||
|
| 'intern'
|
||||||
|
> & {intern: Omit<FlipperLib['intern'], 'currentUser' | 'isConnected'>} {
|
||||||
return {
|
return {
|
||||||
isFB: !constants.IS_PUBLIC_BUILD,
|
isFB: !constants.IS_PUBLIC_BUILD,
|
||||||
logger,
|
logger,
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import {
|
|||||||
FSStatsLike,
|
FSStatsLike,
|
||||||
FlipperServerCommands,
|
FlipperServerCommands,
|
||||||
ENVIRONMENT_VARIABLES,
|
ENVIRONMENT_VARIABLES,
|
||||||
|
User,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import {CreatePasteArgs, CreatePasteResult} from './Paste';
|
import {CreatePasteArgs, CreatePasteResult} from './Paste';
|
||||||
|
import {Atom} from '../state/atom';
|
||||||
|
|
||||||
export type FileEncoding = 'utf-8' | 'base64';
|
export type FileEncoding = 'utf-8' | 'base64';
|
||||||
|
|
||||||
@@ -213,6 +215,8 @@ interface InternAPI {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
isLoggedIn: FlipperServerCommands['is-logged-in'];
|
isLoggedIn: FlipperServerCommands['is-logged-in'];
|
||||||
|
currentUser: () => Atom<User | null>;
|
||||||
|
isConnected: () => Atom<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let flipperLibInstance: FlipperLib | undefined;
|
export let flipperLibInstance: FlipperLib | undefined;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
FlipperPluginModule,
|
FlipperPluginModule,
|
||||||
SandyPluginDefinition,
|
SandyPluginDefinition,
|
||||||
} from '../plugin/SandyPluginDefinition';
|
} from '../plugin/SandyPluginDefinition';
|
||||||
|
import {createState} from '../state/atom';
|
||||||
import {stubLogger} from '../utils/Logger';
|
import {stubLogger} from '../utils/Logger';
|
||||||
|
|
||||||
declare const process: any;
|
declare const process: any;
|
||||||
@@ -80,6 +81,8 @@ export function createMockFlipperLib(options?: StartPluginOptions): FlipperLib {
|
|||||||
graphGet: createStubFunction(),
|
graphGet: createStubFunction(),
|
||||||
graphPost: createStubFunction(),
|
graphPost: createStubFunction(),
|
||||||
isLoggedIn: createStubFunction(),
|
isLoggedIn: createStubFunction(),
|
||||||
|
currentUser: () => createState(null),
|
||||||
|
isConnected: () => createState(true),
|
||||||
},
|
},
|
||||||
remoteServerContext: {
|
remoteServerContext: {
|
||||||
childProcess: {
|
childProcess: {
|
||||||
|
|||||||
@@ -7,15 +7,27 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Logger, _setFlipperLibImplementation} from 'flipper-plugin-core';
|
import {
|
||||||
|
createState,
|
||||||
|
Logger,
|
||||||
|
_setFlipperLibImplementation,
|
||||||
|
} from 'flipper-plugin-core';
|
||||||
import {baseFlipperLibImplementation, RenderHost} from 'flipper-frontend-core';
|
import {baseFlipperLibImplementation, RenderHost} from 'flipper-frontend-core';
|
||||||
|
|
||||||
export function initializeFlipperLibImplementation(
|
export function initializeFlipperLibImplementation(
|
||||||
renderHost: RenderHost,
|
renderHost: RenderHost,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
) {
|
) {
|
||||||
|
const base = baseFlipperLibImplementation(renderHost, logger);
|
||||||
_setFlipperLibImplementation({
|
_setFlipperLibImplementation({
|
||||||
...baseFlipperLibImplementation(renderHost, logger),
|
...base,
|
||||||
|
intern: {
|
||||||
|
...base.intern,
|
||||||
|
// TODO: Implement me
|
||||||
|
currentUser: () => createState(null),
|
||||||
|
// TODO: Implement me
|
||||||
|
isConnected: () => createState(true),
|
||||||
|
},
|
||||||
enableMenuEntries() {},
|
enableMenuEntries() {},
|
||||||
createPaste() {
|
createPaste() {
|
||||||
// TODO: Implement me
|
// TODO: Implement me
|
||||||
|
|||||||
@@ -17,14 +17,21 @@ import {addNotification} from '../../reducers/notifications';
|
|||||||
import {deconstructPluginKey} from 'flipper-common';
|
import {deconstructPluginKey} from 'flipper-common';
|
||||||
import {RenderHost} from 'flipper-frontend-core';
|
import {RenderHost} from 'flipper-frontend-core';
|
||||||
import {setMenuEntries} from '../../reducers/connections';
|
import {setMenuEntries} from '../../reducers/connections';
|
||||||
|
import {currentUser, isConnected} from '../../fb-stubs/user';
|
||||||
|
|
||||||
export function initializeFlipperLibImplementation(
|
export function initializeFlipperLibImplementation(
|
||||||
renderHost: RenderHost,
|
renderHost: RenderHost,
|
||||||
store: Store,
|
store: Store,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
) {
|
) {
|
||||||
|
const base = baseFlipperLibImplementation(renderHost, logger);
|
||||||
_setFlipperLibImplementation({
|
_setFlipperLibImplementation({
|
||||||
...baseFlipperLibImplementation(renderHost, logger),
|
...base,
|
||||||
|
intern: {
|
||||||
|
...base.intern,
|
||||||
|
currentUser,
|
||||||
|
isConnected,
|
||||||
|
},
|
||||||
enableMenuEntries(entries) {
|
enableMenuEntries(entries) {
|
||||||
store.dispatch(setMenuEntries(entries));
|
store.dispatch(setMenuEntries(entries));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user