API for creating pastes without showing notifications

Reviewed By: mweststrate

Differential Revision: D33277470

fbshipit-source-id: 2ec9ad7d9fc48d7d2da64be3bfc1a66bb5b3a347
This commit is contained in:
Anton Nikolaev
2021-12-22 15:33:08 -08:00
committed by Facebook GitHub Bot
parent 6b8588c5ef
commit dd4d7bbe7f
6 changed files with 37 additions and 17 deletions

View File

@@ -81,6 +81,8 @@ test('Correct top level API exposed', () => {
"Atom",
"CrashLog",
"CrashLogListener",
"CreatePasteArgs",
"CreatePasteResult",
"DataDescriptionType",
"DataInspectorExpanded",
"DataTableColumn",

View File

@@ -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';

View File

@@ -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<string | undefined>;
createPaste(
args: string | CreatePasteArgs,
): Promise<CreatePasteResult | undefined>;
GK(gatekeeper: string): boolean;
selectPlugin(
device: Device,

View File

@@ -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;
};

View File

@@ -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<T = any> = (
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<string | undefined>;
createPaste(
args: string | CreatePasteArgs,
): Promise<CreatePasteResult | undefined>;
/**
* Returns true if this is an internal Facebook build.

View File

@@ -7,20 +7,10 @@
* @format
*/
export default function createPaste(
_input: string,
): Promise<string | undefined> {
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<CreatePasteResult | undefined> {
return Promise.reject(new Error('Not implemented!'));
export default async function createPaste(
_args: string | CreatePasteArgs,
): Promise<CreatePasteResult | undefined> {
throw new Error('Not implemented');
}