createPaste
Reviewed By: jknoxville Differential Revision: D14224400 fbshipit-source-id: 9a9a8578de00d276d65a7928964eae619f5bc41f
This commit is contained in:
committed by
Facebook Github Bot
parent
6118dee3e7
commit
99ea11b8e6
@@ -37,7 +37,8 @@ import {
|
|||||||
updateCategoryBlacklist,
|
updateCategoryBlacklist,
|
||||||
} from './reducers/notifications';
|
} from './reducers/notifications';
|
||||||
import {selectPlugin} from './reducers/connections';
|
import {selectPlugin} from './reducers/connections';
|
||||||
import {createPaste, textContent} from './utils/index';
|
import {textContent} from './utils/index';
|
||||||
|
import createPaste from './fb-stubs/createPaste';
|
||||||
|
|
||||||
export default class Notifications extends FlipperDevicePlugin<{}> {
|
export default class Notifications extends FlipperDevicePlugin<{}> {
|
||||||
static id = 'notifications';
|
static id = 'notifications';
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ class PluginDebugger extends Component<Props> {
|
|||||||
<InfoText>
|
<InfoText>
|
||||||
The table lists all plugins known to Flipper. Some of them might be
|
The table lists all plugins known to Flipper. Some of them might be
|
||||||
blocked by GKs, others may not show up, because none of the
|
blocked by GKs, others may not show up, because none of the
|
||||||
connected apps is supporting it.
|
connected apps are supporting it.
|
||||||
</InfoText>
|
</InfoText>
|
||||||
<TableContainer>
|
<TableContainer>
|
||||||
<ManagedTable
|
<ManagedTable
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import DetailSidebar from './chrome/DetailSidebar';
|
|||||||
import {FlipperPlugin} from './plugin';
|
import {FlipperPlugin} from './plugin';
|
||||||
import SearchableTable from './ui/components/searchable/SearchableTable';
|
import SearchableTable from './ui/components/searchable/SearchableTable';
|
||||||
import textContent from './utils/textContent.js';
|
import textContent from './utils/textContent.js';
|
||||||
import createPaste from './utils/createPaste.js';
|
import createPaste from './fb-stubs/createPaste.js';
|
||||||
|
|
||||||
type ID = string;
|
type ID = string;
|
||||||
|
|
||||||
|
|||||||
10
src/fb-stubs/createPaste.js
Normal file
10
src/fb-stubs/createPaste.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2018-present Facebook.
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function createPaste(input: string): Promise<?string> {
|
||||||
|
return Promise.reject('Not implemented!');
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ export {default as styled} from 'react-emotion';
|
|||||||
export * from './ui/index.js';
|
export * from './ui/index.js';
|
||||||
export * from './utils/index.js';
|
export * from './utils/index.js';
|
||||||
export {default as GK} from './fb-stubs/GK.js';
|
export {default as GK} from './fb-stubs/GK.js';
|
||||||
|
export {default as createPaste} from './fb-stubs/createPaste.js';
|
||||||
export {
|
export {
|
||||||
FlipperBasePlugin,
|
FlipperBasePlugin,
|
||||||
FlipperPlugin,
|
FlipperPlugin,
|
||||||
@@ -17,7 +18,7 @@ export {
|
|||||||
export type {PluginClient} from './plugin.js';
|
export type {PluginClient} from './plugin.js';
|
||||||
export {clipboard} from 'electron';
|
export {clipboard} from 'electron';
|
||||||
export * from './fb-stubs/constants.js';
|
export * from './fb-stubs/constants.js';
|
||||||
export * from './utils/createPaste.js';
|
export * from './fb-stubs/createPaste.js';
|
||||||
export {connect} from 'react-redux';
|
export {connect} from 'react-redux';
|
||||||
export {selectPlugin} from './reducers/connections';
|
export {selectPlugin} from './reducers/connections';
|
||||||
export {getPluginKey, getPersistedState} from './utils/pluginUtils.js';
|
export {getPluginKey, getPersistedState} from './utils/pluginUtils.js';
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ContextMenu from '../ContextMenu.js';
|
|||||||
import Tooltip from '../Tooltip.js';
|
import Tooltip from '../Tooltip.js';
|
||||||
import styled from '../../styled/index.js';
|
import styled from '../../styled/index.js';
|
||||||
import DataPreview from './DataPreview.js';
|
import DataPreview from './DataPreview.js';
|
||||||
import createPaste from '../../../utils/createPaste.js';
|
import createPaste from '../../../fb-stubs/createPaste.js';
|
||||||
import {reportInteraction} from '../../../utils/InteractionTracker.js';
|
import {reportInteraction} from '../../../utils/InteractionTracker.js';
|
||||||
import {getSortedKeys} from './utils.js';
|
import {getSortedKeys} from './utils.js';
|
||||||
import {colors} from '../colors.js';
|
import {colors} from '../colors.js';
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import TableHead from './TableHead.js';
|
|||||||
import TableRow from './TableRow.js';
|
import TableRow from './TableRow.js';
|
||||||
import ContextMenu from '../ContextMenu.js';
|
import ContextMenu from '../ContextMenu.js';
|
||||||
import FlexColumn from '../FlexColumn.js';
|
import FlexColumn from '../FlexColumn.js';
|
||||||
import createPaste from '../../../utils/createPaste.js';
|
import createPaste from '../../../fb-stubs/createPaste.js';
|
||||||
import debounceRender from 'react-debounce-render';
|
import debounceRender from 'react-debounce-render';
|
||||||
import debounce from 'lodash.debounce';
|
import debounce from 'lodash.debounce';
|
||||||
import {DEFAULT_ROW_HEIGHT} from './types';
|
import {DEFAULT_ROW_HEIGHT} from './types';
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2018-present Facebook.
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
import child_process from 'child_process';
|
|
||||||
import {clipboard, shell} from 'electron';
|
|
||||||
import JSONStream from 'JSONStream';
|
|
||||||
|
|
||||||
type PasteResponse =
|
|
||||||
| string
|
|
||||||
| {
|
|
||||||
createdPaste: {
|
|
||||||
id: number,
|
|
||||||
url: string,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function createPaste(input: string): Promise<?string> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const child = child_process.spawn('pastry', ['--json']);
|
|
||||||
|
|
||||||
let lastMessage: ?PasteResponse;
|
|
||||||
|
|
||||||
child.stdout
|
|
||||||
.pipe(JSONStream.parse([true]))
|
|
||||||
.on('data', (data: PasteResponse) => {
|
|
||||||
if (typeof data === 'string' && lastMessage === 'error') {
|
|
||||||
new window.Notification('Failed to create paste', {
|
|
||||||
body: data,
|
|
||||||
});
|
|
||||||
reject(data);
|
|
||||||
} else if (typeof data === 'object' && data.createdPaste) {
|
|
||||||
const {url, id} = data.createdPaste;
|
|
||||||
clipboard.writeText(url);
|
|
||||||
const notification = new window.Notification(`Paste P${id} created`, {
|
|
||||||
body: 'URL copied to clipboard',
|
|
||||||
});
|
|
||||||
notification.onclick = () => shell.openExternal(url);
|
|
||||||
resolve(url);
|
|
||||||
}
|
|
||||||
lastMessage = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
child.stdin.write(input);
|
|
||||||
child.stdin.end();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -6,4 +6,3 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export {default as textContent} from './textContent.js';
|
export {default as textContent} from './textContent.js';
|
||||||
export {default as createPaste} from './createPaste.js';
|
|
||||||
|
|||||||
Reference in New Issue
Block a user