diff --git a/desktop/flipper-plugin/src/__tests__/api.node.tsx b/desktop/flipper-plugin/src/__tests__/api.node.tsx index f255f4b54..cffd85015 100644 --- a/desktop/flipper-plugin/src/__tests__/api.node.tsx +++ b/desktop/flipper-plugin/src/__tests__/api.node.tsx @@ -81,6 +81,8 @@ test('Correct top level API exposed', () => { "Atom", "CrashLog", "CrashLogListener", + "CreatePasteArgs", + "CreatePasteResult", "DataDescriptionType", "DataInspectorExpanded", "DataTableColumn", diff --git a/desktop/flipper-plugin/src/index.ts b/desktop/flipper-plugin/src/index.ts index d30e39886..bd2d55b23 100644 --- a/desktop/flipper-plugin/src/index.ts +++ b/desktop/flipper-plugin/src/index.ts @@ -49,6 +49,7 @@ export { DefaultKeyboardAction, } from './plugin/MenuEntry'; export {Notification} from './plugin/Notification'; +export {CreatePasteArgs, CreatePasteResult} from './plugin/Paste'; export {theme} from './ui/theme'; export {Layout} from './ui/Layout'; diff --git a/desktop/flipper-plugin/src/plugin/FlipperLib.tsx b/desktop/flipper-plugin/src/plugin/FlipperLib.tsx index eea1f363b..10c03cf5b 100644 --- a/desktop/flipper-plugin/src/plugin/FlipperLib.tsx +++ b/desktop/flipper-plugin/src/plugin/FlipperLib.tsx @@ -26,6 +26,7 @@ import { EnvironmentInfo, FSStatsLike, } from 'flipper-common'; +import {CreatePasteArgs, CreatePasteResult} from './Paste'; export type FileEncoding = 'utf-8' | 'base64'; @@ -94,7 +95,9 @@ export interface FlipperLib { isFB: boolean; logger: Logger; enableMenuEntries(menuEntries: NormalizedMenuEntry[]): void; - createPaste(input: string): Promise; + createPaste( + args: string | CreatePasteArgs, + ): Promise; GK(gatekeeper: string): boolean; selectPlugin( device: Device, diff --git a/desktop/flipper-plugin/src/plugin/Paste.tsx b/desktop/flipper-plugin/src/plugin/Paste.tsx new file mode 100644 index 000000000..4da0b6faf --- /dev/null +++ b/desktop/flipper-plugin/src/plugin/Paste.tsx @@ -0,0 +1,21 @@ +/** + * 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 CreatePasteArgs = { + content: string; + title?: string; + showSuccessNotification?: boolean; + showErrorNotification?: boolean; + writeToClipboard?: boolean; +}; + +export type CreatePasteResult = { + number: number; + url: string; +}; diff --git a/desktop/flipper-plugin/src/plugin/PluginBase.tsx b/desktop/flipper-plugin/src/plugin/PluginBase.tsx index 84ee7b098..7ee67c543 100644 --- a/desktop/flipper-plugin/src/plugin/PluginBase.tsx +++ b/desktop/flipper-plugin/src/plugin/PluginBase.tsx @@ -17,6 +17,7 @@ import {batched} from '../state/batch'; import {Idler} from '../utils/Idler'; import {Notification} from './Notification'; import {Logger} from '../utils/Logger'; +import {CreatePasteArgs, CreatePasteResult} from './Paste'; type StateExportHandler = ( idler: Idler, @@ -94,7 +95,9 @@ export interface BasePluginClient { * Creates a Paste (similar to a Github Gist). * Facebook only function. Resolves to undefined if creating a paste failed. */ - createPaste(input: string): Promise; + createPaste( + args: string | CreatePasteArgs, + ): Promise; /** * Returns true if this is an internal Facebook build. diff --git a/desktop/flipper-ui-core/src/fb-stubs/createPaste.tsx b/desktop/flipper-ui-core/src/fb-stubs/createPaste.tsx index 6606e3e2c..80e705362 100644 --- a/desktop/flipper-ui-core/src/fb-stubs/createPaste.tsx +++ b/desktop/flipper-ui-core/src/fb-stubs/createPaste.tsx @@ -7,20 +7,10 @@ * @format */ -export default function createPaste( - _input: string, -): Promise { - return Promise.reject(new Error('Not implemented!')); -} +import type {CreatePasteArgs, CreatePasteResult} from 'flipper-plugin'; -export type CreatePasteResult = { - number: number; - url: string; -}; - -export async function createPasteWithDetails(_details: { - title?: string; - content: string; -}): Promise { - return Promise.reject(new Error('Not implemented!')); +export default async function createPaste( + _args: string | CreatePasteArgs, +): Promise { + throw new Error('Not implemented'); }