Yarn workspaces

Summary:
1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code
2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later.

Reviewed By: jknoxville

Differential Revision: D20535782

fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1
This commit is contained in:
Anton Nikolaev
2020-03-20 13:31:37 -07:00
committed by Facebook GitHub Bot
parent 676d7bbd24
commit 863f89351e
340 changed files with 1635 additions and 294 deletions

View File

@@ -0,0 +1,172 @@
/**
* 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
*/
import {Notification} from '../plugin';
import {Actions} from './';
export type PluginNotification = {
notification: Notification;
pluginId: string;
client: null | string;
};
export type State = {
activeNotifications: Array<PluginNotification>;
invalidatedNotifications: Array<PluginNotification>;
blacklistedPlugins: Array<string>;
blacklistedCategories: Array<string>;
clearedNotifications: Set<string>;
};
type ActiveNotificationsAction = {
type: 'SET_ACTIVE_NOTIFICATIONS';
payload: {
notifications: Array<Notification>;
client: null | string;
pluginId: string;
};
};
export type Action =
| {
type: 'CLEAR_ALL_NOTIFICATIONS';
}
| {
type: 'SET_ACTIVE_NOTIFICATIONS';
payload: {
notifications: Array<Notification>;
client: null | string;
pluginId: string;
};
}
| {
type: 'UPDATE_PLUGIN_BLACKLIST';
payload: Array<string>;
}
| {
type: 'UPDATE_CATEGORY_BLACKLIST';
payload: Array<string>;
};
const INITIAL_STATE: State = {
activeNotifications: [],
invalidatedNotifications: [],
blacklistedPlugins: [],
blacklistedCategories: [],
clearedNotifications: new Set(),
};
export default function reducer(
state: State = INITIAL_STATE,
action: Actions,
): State {
switch (action.type) {
case 'SET_ACTIVE_NOTIFICATIONS': {
return activeNotificationsReducer(state, action);
}
case 'CLEAR_ALL_NOTIFICATIONS':
const markAsCleared = ({
pluginId,
notification: {id},
}: PluginNotification) =>
state.clearedNotifications.add(`${pluginId}#${id}`);
state.activeNotifications.forEach(markAsCleared);
state.invalidatedNotifications.forEach(markAsCleared);
// Q: Should this actually delete them, or just invalidate them?
return {
...state,
activeNotifications: [],
invalidatedNotifications: [],
};
case 'UPDATE_PLUGIN_BLACKLIST':
return {
...state,
blacklistedPlugins: action.payload,
};
case 'UPDATE_CATEGORY_BLACKLIST':
return {
...state,
blacklistedCategories: action.payload,
};
default:
return state;
}
}
function activeNotificationsReducer(
state: State,
action: ActiveNotificationsAction,
): State {
const {payload} = action;
const newActiveNotifications = [];
const newInactivatedNotifications = state.invalidatedNotifications;
const newIDs = new Set(payload.notifications.map((n: Notification) => n.id));
for (const activeNotification of state.activeNotifications) {
if (activeNotification.pluginId !== payload.pluginId) {
newActiveNotifications.push(activeNotification);
continue;
}
if (!newIDs.has(activeNotification.notification.id)) {
newInactivatedNotifications.push(activeNotification);
}
}
payload.notifications
.filter(
({id}: Notification) =>
!state.clearedNotifications.has(`${payload.pluginId}#${id}`),
)
.forEach((notification: Notification) => {
newActiveNotifications.push({
pluginId: payload.pluginId,
client: payload.client,
notification,
});
});
return {
...state,
activeNotifications: newActiveNotifications,
invalidatedNotifications: newInactivatedNotifications,
};
}
export function setActiveNotifications(payload: {
notifications: Array<Notification>;
client: null | string;
pluginId: string;
}): Action {
return {
type: 'SET_ACTIVE_NOTIFICATIONS',
payload,
};
}
export function clearAllNotifications(): Action {
return {
type: 'CLEAR_ALL_NOTIFICATIONS',
};
}
export function updatePluginBlacklist(payload: Array<string>): Action {
return {
type: 'UPDATE_PLUGIN_BLACKLIST',
payload,
};
}
export function updateCategoryBlacklist(payload: Array<string>): Action {
return {
type: 'UPDATE_CATEGORY_BLACKLIST',
payload,
};
}