NotificationHub: allow to select notification text and copy it

Summary: Enabled selection of notification text + added a context menu item to copy the selected text only.

Reviewed By: passy

Differential Revision: D22065704

fbshipit-source-id: 510e68d50a54329aaeefb9b3097bc4283f884dc9
This commit is contained in:
Anton Nikolaev
2020-06-16 04:29:36 -07:00
committed by Facebook GitHub Bot
parent 5b92836bea
commit 4a52af358e

View File

@@ -370,6 +370,7 @@ const NotificationContent = styled(FlexColumn)<{isSelected?: boolean}>(
maxHeight: props.isSelected ? 'none' : 56, maxHeight: props.isSelected ? 'none' : 56,
lineHeight: 1.4, lineHeight: 1.4,
color: props.isSelected ? colors.light50 : colors.light30, color: props.isSelected ? colors.light50 : colors.light30,
userSelect: 'text',
}), }),
); );
@@ -429,7 +430,7 @@ class NotificationItem extends Component<
> { > {
constructor(props: ItemProps & PluginNotification) { constructor(props: ItemProps & PluginNotification) {
super(props); super(props);
const items = []; const items: Array<Electron.MenuItemConstructorOptions> = [];
if (props.onHidePlugin && props.plugin) { if (props.onHidePlugin && props.plugin) {
items.push({ items.push({
label: `Hide ${getPluginTitle(props.plugin)} plugin`, label: `Hide ${getPluginTitle(props.plugin)} plugin`,
@@ -443,7 +444,8 @@ class NotificationItem extends Component<
}); });
} }
items.push( items.push(
{label: 'Copy', click: this.copy}, {label: 'Copy', role: 'copy'},
{label: 'Copy All', click: this.copy},
{label: 'Create Paste', click: this.createPaste}, {label: 'Create Paste', click: this.createPaste},
); );
@@ -451,7 +453,7 @@ class NotificationItem extends Component<
} }
state = {reportedNotHelpful: false}; state = {reportedNotHelpful: false};
contextMenuItems: Array<{label: string; click: (() => any) | undefined}>; contextMenuItems: Array<Electron.MenuItemConstructorOptions>;
deepLinkButton = React.createRef(); deepLinkButton = React.createRef();
createPaste = () => { createPaste = () => {