Add deprecation notice notification
Summary: Add deprecation notice device icon and notification Reviewed By: lblasa Differential Revision: D34582475 fbshipit-source-id: 90fde15caf1925b42f50fbfc77dece88c82833cf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ed6e589bec
commit
5068c8273b
@@ -80,6 +80,7 @@ export type ClientQuery = {
|
|||||||
readonly device: string;
|
readonly device: string;
|
||||||
readonly device_id: string;
|
readonly device_id: string;
|
||||||
readonly sdk_version?: number;
|
readonly sdk_version?: number;
|
||||||
|
rsocket?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClientDescription = {
|
export type ClientDescription = {
|
||||||
@@ -105,7 +106,7 @@ export type FlipperServerEvents = {
|
|||||||
'server-state': {state: FlipperServerState; error?: string};
|
'server-state': {state: FlipperServerState; error?: string};
|
||||||
'server-error': any;
|
'server-error': any;
|
||||||
notification: {
|
notification: {
|
||||||
type: 'error';
|
type: 'success' | 'info' | 'error' | 'warning';
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ export interface ServerEventsListener {
|
|||||||
onClientMessage(clientId: string, payload: string): void;
|
onClientMessage(clientId: string, payload: string): void;
|
||||||
|
|
||||||
onClientSetupError(clientQuery: ClientQuery, error: any): void;
|
onClientSetupError(clientQuery: ClientQuery, error: any): void;
|
||||||
|
|
||||||
|
onDeprecationNotice: (message: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
Logger,
|
Logger,
|
||||||
UninitializedClient,
|
UninitializedClient,
|
||||||
reportPlatformFailures,
|
reportPlatformFailures,
|
||||||
|
FlipperServerEvents,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import CertificateProvider from '../utils/CertificateProvider';
|
import CertificateProvider from '../utils/CertificateProvider';
|
||||||
import {ClientConnection, ConnectionStatus} from './ClientConnection';
|
import {ClientConnection, ConnectionStatus} from './ClientConnection';
|
||||||
@@ -169,8 +170,17 @@ export class ServerController
|
|||||||
clientConnection: ClientConnection,
|
clientConnection: ClientConnection,
|
||||||
downgrade?: boolean,
|
downgrade?: boolean,
|
||||||
): Promise<ClientDescription> {
|
): Promise<ClientDescription> {
|
||||||
const {app, os, device, device_id, sdk_version, csr, csr_path, medium} =
|
const {
|
||||||
clientQuery;
|
app,
|
||||||
|
os,
|
||||||
|
device,
|
||||||
|
device_id,
|
||||||
|
sdk_version,
|
||||||
|
csr,
|
||||||
|
csr_path,
|
||||||
|
medium,
|
||||||
|
rsocket,
|
||||||
|
} = clientQuery;
|
||||||
const transformedMedium = transformCertificateExchangeMediumToType(medium);
|
const transformedMedium = transformCertificateExchangeMediumToType(medium);
|
||||||
console.info(
|
console.info(
|
||||||
`[conn] Connection established: ${app} on ${device_id}. Medium ${medium}. CSR: ${csr_path}`,
|
`[conn] Connection established: ${app} on ${device_id}. Medium ${medium}. CSR: ${csr_path}`,
|
||||||
@@ -185,6 +195,7 @@ export class ServerController
|
|||||||
device_id,
|
device_id,
|
||||||
sdk_version,
|
sdk_version,
|
||||||
medium: transformedMedium,
|
medium: transformedMedium,
|
||||||
|
rsocket,
|
||||||
},
|
},
|
||||||
{csr, csr_path},
|
{csr, csr_path},
|
||||||
downgrade,
|
downgrade,
|
||||||
@@ -513,6 +524,15 @@ export class ServerController
|
|||||||
this.flipperServer.pluginManager.stopAllServerAddOns(id);
|
this.flipperServer.pluginManager.stopAllServerAddOns(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDeprecationNotice(message: string) {
|
||||||
|
const notification: FlipperServerEvents['notification'] = {
|
||||||
|
type: 'warning',
|
||||||
|
title: 'Deprecation notice',
|
||||||
|
description: message,
|
||||||
|
};
|
||||||
|
this.flipperServer.emit('notification', notification);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionTracker {
|
class ConnectionTracker {
|
||||||
|
|||||||
@@ -105,9 +105,10 @@ class ServerRSocket extends ServerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const clientQuery: SecureClientQuery = JSON.parse(payload.data);
|
const clientQuery: SecureClientQuery = JSON.parse(payload.data);
|
||||||
|
clientQuery.rsocket = true;
|
||||||
// TODO: Add a migration guide
|
// TODO: Add a migration guide
|
||||||
console.warn(
|
this.listener.onDeprecationNotice(
|
||||||
`[conn] RSockets are being deprecated at Flipper. Please, migrate to WebSockets. App: ${clientQuery.app}. Device: ${clientQuery.device}.`,
|
`[conn] RSockets are being deprecated at Flipper. Please, use the latest Flipper client in your app to migrate to WebSockets. App: ${clientQuery.app}. Device: ${clientQuery.device}.`,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.listener.onSecureConnectionAttempt(clientQuery);
|
this.listener.onSecureConnectionAttempt(clientQuery);
|
||||||
|
|||||||
@@ -63,4 +63,5 @@ export const createMockSEListener = (): ServerEventsListener => ({
|
|||||||
onError: jest.fn(),
|
onError: jest.fn(),
|
||||||
onClientMessage: jest.fn(),
|
onClientMessage: jest.fn(),
|
||||||
onClientSetupError: jest.fn(),
|
onClientSetupError: jest.fn(),
|
||||||
|
onDeprecationNotice: jest.fn(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function connectFlipperServerToStore(
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
) {
|
) {
|
||||||
server.on('notification', ({type, title, description}) => {
|
server.on('notification', ({type, title, description}) => {
|
||||||
const text = `[$type] ${title}: ${description}`;
|
const text = `[${type}] ${title}: ${description}`;
|
||||||
console.warn(text);
|
console.warn(text);
|
||||||
notification.open({
|
notification.open({
|
||||||
message: title,
|
message: title,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Button, Dropdown, Menu, Radio, Typography} from 'antd';
|
import {Button, Dropdown, Menu, Radio, Tooltip, Typography} from 'antd';
|
||||||
import {
|
import {
|
||||||
AppleOutlined,
|
AppleOutlined,
|
||||||
AndroidOutlined,
|
AndroidOutlined,
|
||||||
@@ -102,7 +102,14 @@ export function AppSelector() {
|
|||||||
}>
|
}>
|
||||||
<AppInspectButton title="Select the device / app to inspect">
|
<AppInspectButton title="Select the device / app to inspect">
|
||||||
<Layout.Horizontal gap center>
|
<Layout.Horizontal gap center>
|
||||||
<AppIcon appname={client?.query.app} device={selectedDevice} />
|
{client?.query.rsocket ? (
|
||||||
|
<DeprecationIcon />
|
||||||
|
) : (
|
||||||
|
<AppIcon
|
||||||
|
appname={client?.query.app}
|
||||||
|
device={selectedDevice}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Layout.Container grow shrink>
|
<Layout.Container grow shrink>
|
||||||
<Text strong>{client?.query.app ?? ''}</Text>
|
<Text strong>{client?.query.app ?? ''}</Text>
|
||||||
<Text>{selectedDevice?.title || 'Available devices'}</Text>
|
<Text>{selectedDevice?.title || 'Available devices'}</Text>
|
||||||
@@ -181,6 +188,21 @@ function AppIcon({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DeprecationIcon() {
|
||||||
|
return (
|
||||||
|
<Tooltip title="RSockets are being deprecated at Flipper. Please, use the latest Flipper client in your app to migrate to WebSockets.">
|
||||||
|
<AppIconContainer style={{background: theme.warningColor}}>
|
||||||
|
<Glyph
|
||||||
|
name="caution-triangle"
|
||||||
|
size={24}
|
||||||
|
variant="outline"
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
</AppIconContainer>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const AppIconContainer = styled.div({
|
const AppIconContainer = styled.div({
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
width: 36,
|
width: 36,
|
||||||
|
|||||||
@@ -615,5 +615,8 @@
|
|||||||
],
|
],
|
||||||
"app-cms": [
|
"app-cms": [
|
||||||
16
|
16
|
||||||
|
],
|
||||||
|
"caution-triangle-outline": [
|
||||||
|
24
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user