Rename Notification Blacklist to Blocklist
Summary: per title Reviewed By: mweststrate Differential Revision: D25021786 fbshipit-source-id: 444e0959b5a4157171dad5c81b102abf105a99ed
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f68cef3046
commit
21ad9ad433
@@ -27,8 +27,8 @@ import React, {Component, Fragment} from 'react';
|
||||
import {clipboard} from 'electron';
|
||||
import {
|
||||
PluginNotification,
|
||||
updatePluginBlacklist,
|
||||
updateCategoryBlacklist,
|
||||
updatePluginBlocklist,
|
||||
updateCategoryBlocklist,
|
||||
} from './reducers/notifications';
|
||||
import {selectPlugin} from './reducers/connections';
|
||||
import {State as StoreState} from './reducers/index';
|
||||
@@ -45,8 +45,8 @@ type OwnProps = {
|
||||
type StateFromProps = {
|
||||
activeNotifications: Array<PluginNotification>;
|
||||
invalidatedNotifications: Array<PluginNotification>;
|
||||
blacklistedPlugins: Array<string>;
|
||||
blacklistedCategories: Array<string>;
|
||||
blocklistedPlugins: Array<string>;
|
||||
blocklistedCategories: Array<string>;
|
||||
devicePlugins: DevicePluginMap;
|
||||
clientPlugins: ClientPluginMap;
|
||||
};
|
||||
@@ -57,8 +57,8 @@ type DispatchFromProps = {
|
||||
selectedApp: string | null;
|
||||
deepLinkPayload: unknown;
|
||||
}) => any;
|
||||
updatePluginBlacklist: (blacklist: Array<string>) => any;
|
||||
updateCategoryBlacklist: (blacklist: Array<string>) => any;
|
||||
updatePluginBlocklist: (blocklist: Array<string>) => any;
|
||||
updateCategoryBlocklist: (blocklist: Array<string>) => any;
|
||||
};
|
||||
|
||||
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
||||
@@ -106,7 +106,7 @@ class NotificationsTable extends Component<Props & SearchableProps, State> {
|
||||
|
||||
componentDidUpdate(prevProps: Props & SearchableProps) {
|
||||
if (this.props.filters.length !== prevProps.filters.length) {
|
||||
this.props.updatePluginBlacklist(
|
||||
this.props.updatePluginBlocklist(
|
||||
this.props.filters
|
||||
.filter(
|
||||
(f) => f.type === 'exclude' && f.key.toLowerCase() === 'plugin',
|
||||
@@ -114,7 +114,7 @@ class NotificationsTable extends Component<Props & SearchableProps, State> {
|
||||
.map((f) => String(f.value)),
|
||||
);
|
||||
|
||||
this.props.updateCategoryBlacklist(
|
||||
this.props.updateCategoryBlocklist(
|
||||
this.props.filters
|
||||
.filter(
|
||||
(f) => f.type === 'exclude' && f.key.toLowerCase() === 'category',
|
||||
@@ -140,8 +140,8 @@ class NotificationsTable extends Component<Props & SearchableProps, State> {
|
||||
type: 'exclude',
|
||||
key: 'plugin',
|
||||
});
|
||||
this.props.updatePluginBlacklist(
|
||||
this.props.blacklistedPlugins.concat(pluginId),
|
||||
this.props.updatePluginBlocklist(
|
||||
this.props.blocklistedPlugins.concat(pluginId),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -152,8 +152,8 @@ class NotificationsTable extends Component<Props & SearchableProps, State> {
|
||||
type: 'exclude',
|
||||
key: 'category',
|
||||
});
|
||||
this.props.updatePluginBlacklist(
|
||||
this.props.blacklistedCategories.concat(category),
|
||||
this.props.updatePluginBlocklist(
|
||||
this.props.blocklistedCategories.concat(category),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -163,20 +163,20 @@ class NotificationsTable extends Component<Props & SearchableProps, State> {
|
||||
const searchTerm = this.props.searchTerm.toLowerCase();
|
||||
|
||||
// filter plugins
|
||||
const blacklistedPlugins = new Set(
|
||||
this.props.blacklistedPlugins.map((p) => p.toLowerCase()),
|
||||
const blocklistedPlugins = new Set(
|
||||
this.props.blocklistedPlugins.map((p) => p.toLowerCase()),
|
||||
);
|
||||
if (blacklistedPlugins.has(n.pluginId.toLowerCase())) {
|
||||
if (blocklistedPlugins.has(n.pluginId.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// filter categories
|
||||
const {category} = n.notification;
|
||||
if (category) {
|
||||
const blacklistedCategories = new Set(
|
||||
this.props.blacklistedCategories.map((p) => p.toLowerCase()),
|
||||
const blocklistedCategories = new Set(
|
||||
this.props.blocklistedCategories.map((p) => p.toLowerCase()),
|
||||
);
|
||||
if (blacklistedCategories.has(category.toLowerCase())) {
|
||||
if (blocklistedCategories.has(category.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -277,21 +277,21 @@ export const ConnectedNotificationsTable = connect<
|
||||
notifications: {
|
||||
activeNotifications,
|
||||
invalidatedNotifications,
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
blocklistedPlugins,
|
||||
blocklistedCategories,
|
||||
},
|
||||
plugins: {devicePlugins, clientPlugins},
|
||||
}) => ({
|
||||
activeNotifications,
|
||||
invalidatedNotifications,
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
blocklistedPlugins,
|
||||
blocklistedCategories,
|
||||
devicePlugins,
|
||||
clientPlugins,
|
||||
}),
|
||||
{
|
||||
updatePluginBlacklist,
|
||||
updateCategoryBlacklist,
|
||||
updatePluginBlocklist,
|
||||
updateCategoryBlocklist,
|
||||
selectPlugin,
|
||||
},
|
||||
)(Searchable(NotificationsTable));
|
||||
|
||||
@@ -19,8 +19,8 @@ import React from 'react';
|
||||
|
||||
type StateFromProps = {
|
||||
deepLinkPayload: unknown;
|
||||
blacklistedPlugins: Array<string>;
|
||||
blacklistedCategories: Array<string>;
|
||||
blocklistedPlugins: Array<string>;
|
||||
blocklistedCategories: Array<string>;
|
||||
};
|
||||
|
||||
type DispatchFromProps = {
|
||||
@@ -50,8 +50,8 @@ const Container = styled(FlexColumn)({
|
||||
class Notifications extends PureComponent<Props, State> {
|
||||
render() {
|
||||
const {
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
blocklistedPlugins,
|
||||
blocklistedCategories,
|
||||
deepLinkPayload,
|
||||
logger,
|
||||
clearAllNotifications,
|
||||
@@ -68,12 +68,12 @@ class Notifications extends PureComponent<Props, State> {
|
||||
onSelectPlugin={selectPlugin}
|
||||
logger={logger}
|
||||
defaultFilters={[
|
||||
...blacklistedPlugins.map((value) => ({
|
||||
...blocklistedPlugins.map((value) => ({
|
||||
value,
|
||||
type: 'exclude',
|
||||
key: 'plugin',
|
||||
})),
|
||||
...blacklistedCategories.map((value) => ({
|
||||
...blocklistedCategories.map((value) => ({
|
||||
value,
|
||||
type: 'exclude',
|
||||
key: 'category',
|
||||
@@ -94,11 +94,11 @@ class Notifications extends PureComponent<Props, State> {
|
||||
export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
({
|
||||
connections: {deepLinkPayload},
|
||||
notifications: {blacklistedPlugins, blacklistedCategories},
|
||||
notifications: {blocklistedPlugins, blocklistedCategories},
|
||||
}) => ({
|
||||
deepLinkPayload,
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
blocklistedPlugins,
|
||||
blocklistedCategories,
|
||||
}),
|
||||
{clearAllNotifications, selectPlugin},
|
||||
)(Notifications);
|
||||
|
||||
@@ -430,13 +430,13 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
uninitializedClients,
|
||||
staticView,
|
||||
},
|
||||
notifications: {activeNotifications, blacklistedPlugins},
|
||||
notifications: {activeNotifications, blocklistedPlugins},
|
||||
plugins: {devicePlugins, clientPlugins},
|
||||
}) => ({
|
||||
numNotifications: (() => {
|
||||
const blacklist = new Set(blacklistedPlugins);
|
||||
const blocklist = new Set(blocklistedPlugins);
|
||||
return activeNotifications.filter(
|
||||
(n: PluginNotification) => !blacklist.has(n.pluginId),
|
||||
(n: PluginNotification) => !blocklist.has(n.pluginId),
|
||||
).length;
|
||||
})(),
|
||||
windowIsFocused,
|
||||
|
||||
@@ -143,12 +143,12 @@ const RenderNotificationsEntry = connect<
|
||||
>(
|
||||
({
|
||||
connections: {staticView},
|
||||
notifications: {activeNotifications, blacklistedPlugins},
|
||||
notifications: {activeNotifications, blocklistedPlugins},
|
||||
}) => ({
|
||||
numNotifications: (() => {
|
||||
const blacklist = new Set(blacklistedPlugins);
|
||||
const blocklist = new Set(blocklistedPlugins);
|
||||
return activeNotifications.filter(
|
||||
(n: PluginNotification) => !blacklist.has(n.pluginId),
|
||||
(n: PluginNotification) => !blocklist.has(n.pluginId),
|
||||
).length;
|
||||
})(),
|
||||
staticView,
|
||||
|
||||
@@ -16,8 +16,8 @@ import {setStaticView} from '../reducers/connections';
|
||||
import {ipcRenderer, IpcRendererEvent} from 'electron';
|
||||
import {
|
||||
setActiveNotifications,
|
||||
updatePluginBlacklist,
|
||||
updateCategoryBlacklist,
|
||||
updatePluginBlocklist,
|
||||
updateCategoryBlocklist,
|
||||
} from '../reducers/notifications';
|
||||
import {textContent} from '../utils/index';
|
||||
import GK from '../fb-stubs/GK';
|
||||
@@ -63,21 +63,21 @@ export default (store: Store, logger: Logger) => {
|
||||
);
|
||||
|
||||
const {category} = pluginNotification.notification;
|
||||
const {blacklistedCategories} = store.getState().notifications;
|
||||
if (category && blacklistedCategories.indexOf(category) === -1) {
|
||||
const {blocklistedCategories} = store.getState().notifications;
|
||||
if (category && blocklistedCategories.indexOf(category) === -1) {
|
||||
store.dispatch(
|
||||
updateCategoryBlacklist([...blacklistedCategories, category]),
|
||||
updateCategoryBlocklist([...blocklistedCategories, category]),
|
||||
);
|
||||
}
|
||||
} else if (arg === 2) {
|
||||
// Hide plugin
|
||||
logger.track('usage', 'notification-hide-plugin', pluginNotification);
|
||||
|
||||
const {blacklistedPlugins} = store.getState().notifications;
|
||||
if (blacklistedPlugins.indexOf(pluginNotification.pluginId) === -1) {
|
||||
const {blocklistedPlugins} = store.getState().notifications;
|
||||
if (blocklistedPlugins.indexOf(pluginNotification.pluginId) === -1) {
|
||||
store.dispatch(
|
||||
updatePluginBlacklist([
|
||||
...blacklistedPlugins,
|
||||
updatePluginBlocklist([
|
||||
...blocklistedPlugins,
|
||||
pluginNotification.pluginId,
|
||||
]),
|
||||
);
|
||||
@@ -144,8 +144,8 @@ export default (store: Store, logger: Logger) => {
|
||||
|
||||
const {
|
||||
activeNotifications,
|
||||
blacklistedPlugins,
|
||||
blacklistedCategories,
|
||||
blocklistedPlugins,
|
||||
blocklistedCategories,
|
||||
} = notifications;
|
||||
|
||||
activeNotifications
|
||||
@@ -161,9 +161,9 @@ export default (store: Store, logger: Logger) => {
|
||||
!isHeadless() &&
|
||||
store.getState().connections.selectedPlugin !== 'notifications' &&
|
||||
!knownNotifications.has(n.notification.id) &&
|
||||
blacklistedPlugins.indexOf(n.pluginId) === -1 &&
|
||||
blocklistedPlugins.indexOf(n.pluginId) === -1 &&
|
||||
(!n.notification.category ||
|
||||
blacklistedCategories.indexOf(n.notification.category) === -1)
|
||||
blocklistedCategories.indexOf(n.notification.category) === -1)
|
||||
) {
|
||||
const prevNotificationTime: number =
|
||||
lastNotificationTime.get(n.pluginId) || 0;
|
||||
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
default as reducer,
|
||||
setActiveNotifications,
|
||||
clearAllNotifications,
|
||||
updatePluginBlacklist,
|
||||
updateCategoryBlacklist,
|
||||
updatePluginBlocklist,
|
||||
updateCategoryBlocklist,
|
||||
} from '../notifications';
|
||||
|
||||
import {Notification} from '../../plugin';
|
||||
@@ -30,33 +30,33 @@ function getInitialState(): State {
|
||||
return {
|
||||
activeNotifications: [],
|
||||
invalidatedNotifications: [],
|
||||
blacklistedPlugins: [],
|
||||
blacklistedCategories: [],
|
||||
blocklistedPlugins: [],
|
||||
blocklistedCategories: [],
|
||||
clearedNotifications: new Set(),
|
||||
};
|
||||
}
|
||||
|
||||
test('reduce updateCategoryBlacklist', () => {
|
||||
const blacklistedCategories = ['blacklistedCategory'];
|
||||
test('reduce updateCategoryBlocklist', () => {
|
||||
const blocklistedCategories = ['blocklistedCategory'];
|
||||
const res = reducer(
|
||||
getInitialState(),
|
||||
updateCategoryBlacklist(blacklistedCategories),
|
||||
updateCategoryBlocklist(blocklistedCategories),
|
||||
);
|
||||
expect(res).toEqual({
|
||||
...getInitialState(),
|
||||
blacklistedCategories,
|
||||
blocklistedCategories,
|
||||
});
|
||||
});
|
||||
|
||||
test('reduce updatePluginBlacklist', () => {
|
||||
const blacklistedPlugins = ['blacklistedPlugin'];
|
||||
test('reduce updatePluginBlocklist', () => {
|
||||
const blocklistedPlugins = ['blocklistedPlugin'];
|
||||
const res = reducer(
|
||||
getInitialState(),
|
||||
updatePluginBlacklist(blacklistedPlugins),
|
||||
updatePluginBlocklist(blocklistedPlugins),
|
||||
);
|
||||
expect(res).toEqual({
|
||||
...getInitialState(),
|
||||
blacklistedPlugins,
|
||||
blocklistedPlugins,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -149,8 +149,8 @@ test('addNotification removes duplicates', () => {
|
||||
"pluginId": "test",
|
||||
},
|
||||
],
|
||||
"blacklistedCategories": Array [],
|
||||
"blacklistedPlugins": Array [],
|
||||
"blocklistedCategories": Array [],
|
||||
"blocklistedPlugins": Array [],
|
||||
"clearedNotifications": Set {},
|
||||
"invalidatedNotifications": Array [],
|
||||
}
|
||||
@@ -212,8 +212,8 @@ test('reduce removeNotification', () => {
|
||||
"pluginId": "test",
|
||||
},
|
||||
],
|
||||
"blacklistedCategories": Array [],
|
||||
"blacklistedPlugins": Array [],
|
||||
"blocklistedCategories": Array [],
|
||||
"blocklistedPlugins": Array [],
|
||||
"clearedNotifications": Set {},
|
||||
"invalidatedNotifications": Array [],
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ export type PluginNotificationReference = {
|
||||
export type State = {
|
||||
activeNotifications: Array<PluginNotification>;
|
||||
invalidatedNotifications: Array<PluginNotification>;
|
||||
blacklistedPlugins: Array<string>;
|
||||
blacklistedCategories: Array<string>;
|
||||
blocklistedPlugins: Array<string>;
|
||||
blocklistedCategories: Array<string>;
|
||||
clearedNotifications: Set<string>;
|
||||
};
|
||||
|
||||
@@ -52,11 +52,11 @@ export type Action =
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_PLUGIN_BLACKLIST';
|
||||
type: 'UPDATE_PLUGIN_BLOCKLIST';
|
||||
payload: Array<string>;
|
||||
}
|
||||
| {
|
||||
type: 'UPDATE_CATEGORY_BLACKLIST';
|
||||
type: 'UPDATE_CATEGORY_BLOCKLIST';
|
||||
payload: Array<string>;
|
||||
}
|
||||
| {
|
||||
@@ -71,8 +71,8 @@ export type Action =
|
||||
const INITIAL_STATE: State = {
|
||||
activeNotifications: [],
|
||||
invalidatedNotifications: [],
|
||||
blacklistedPlugins: [],
|
||||
blacklistedCategories: [],
|
||||
blocklistedPlugins: [],
|
||||
blocklistedCategories: [],
|
||||
clearedNotifications: new Set(),
|
||||
};
|
||||
|
||||
@@ -99,15 +99,15 @@ export default function reducer(
|
||||
activeNotifications: [],
|
||||
invalidatedNotifications: [],
|
||||
};
|
||||
case 'UPDATE_PLUGIN_BLACKLIST':
|
||||
case 'UPDATE_PLUGIN_BLOCKLIST':
|
||||
return {
|
||||
...state,
|
||||
blacklistedPlugins: action.payload,
|
||||
blocklistedPlugins: action.payload,
|
||||
};
|
||||
case 'UPDATE_CATEGORY_BLACKLIST':
|
||||
case 'UPDATE_CATEGORY_BLOCKLIST':
|
||||
return {
|
||||
...state,
|
||||
blacklistedCategories: action.payload,
|
||||
blocklistedCategories: action.payload,
|
||||
};
|
||||
case 'ADD_NOTIFICATION':
|
||||
return {
|
||||
@@ -233,16 +233,16 @@ export function clearAllNotifications(): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function updatePluginBlacklist(payload: Array<string>): Action {
|
||||
export function updatePluginBlocklist(payload: Array<string>): Action {
|
||||
return {
|
||||
type: 'UPDATE_PLUGIN_BLACKLIST',
|
||||
type: 'UPDATE_PLUGIN_BLOCKLIST',
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
export function updateCategoryBlacklist(payload: Array<string>): Action {
|
||||
export function updateCategoryBlocklist(payload: Array<string>): Action {
|
||||
return {
|
||||
type: 'UPDATE_CATEGORY_BLACKLIST',
|
||||
type: 'UPDATE_CATEGORY_BLOCKLIST',
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -218,8 +218,8 @@ function NotificationButton({
|
||||
const notifications = useStore((state) => state.notifications);
|
||||
const activeNotifications = useMemoize(filterNotifications, [
|
||||
notifications.activeNotifications,
|
||||
notifications.blacklistedPlugins,
|
||||
notifications.blacklistedCategories,
|
||||
notifications.blocklistedPlugins,
|
||||
notifications.blocklistedCategories,
|
||||
]);
|
||||
return (
|
||||
<LeftRailButton
|
||||
|
||||
@@ -28,8 +28,8 @@ import {deconstructClientId} from '../../utils/clientUtils';
|
||||
import {selectPlugin} from '../../reducers/connections';
|
||||
import {
|
||||
clearAllNotifications,
|
||||
updateCategoryBlacklist,
|
||||
updatePluginBlacklist,
|
||||
updateCategoryBlocklist,
|
||||
updatePluginBlocklist,
|
||||
} from '../../reducers/notifications';
|
||||
import {filterNotifications} from './notificationUtils';
|
||||
import {useMemoize} from '../../utils/useMemoize';
|
||||
@@ -217,8 +217,8 @@ export function Notification() {
|
||||
|
||||
const activeNotifications = useMemoize(filterNotifications, [
|
||||
notifications.activeNotifications,
|
||||
notifications.blacklistedPlugins,
|
||||
notifications.blacklistedCategories,
|
||||
notifications.blocklistedPlugins,
|
||||
notifications.blocklistedCategories,
|
||||
]);
|
||||
const displayedNotifications: Array<PluginNotification> = useMemo(
|
||||
() =>
|
||||
@@ -238,16 +238,16 @@ export function Notification() {
|
||||
onHideSimilar: noti.notification.category
|
||||
? () =>
|
||||
dispatch(
|
||||
updateCategoryBlacklist([
|
||||
...notifications.blacklistedCategories,
|
||||
updateCategoryBlocklist([
|
||||
...notifications.blocklistedCategories,
|
||||
noti.notification.category!,
|
||||
]),
|
||||
)
|
||||
: null,
|
||||
onHidePlugin: () =>
|
||||
dispatch(
|
||||
updatePluginBlacklist([
|
||||
...notifications.blacklistedPlugins,
|
||||
updatePluginBlocklist([
|
||||
...notifications.blocklistedPlugins,
|
||||
noti.pluginId,
|
||||
]),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user