Summary: This removes the Non-Sandy UI from the Flipper codebase. It is a pretty rough scan for unused components, over time when converting more advanced components to Ant design probably even more code can be removed. Partially used `npx ts-purge` to reveal never imported source files. Changelog: It is no longer possible to opt out of the new Sandy UI Reviewed By: jknoxville Differential Revision: D25825282 fbshipit-source-id: 9041dbc7e03bce0760c9a0a34f1877851b5f06cf
109 lines
2.8 KiB
TypeScript
109 lines
2.8 KiB
TypeScript
/**
|
|
* 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 {Button} from '../ui';
|
|
import React, {Component} from 'react';
|
|
import {connect} from 'react-redux';
|
|
import {State as Store} from '../reducers';
|
|
import {launchJsEmulator} from '../utils/js-client-server-utils/serverUtils';
|
|
import {updateSettings, Action} from '../reducers/settings';
|
|
import {Settings} from '../reducers/settings';
|
|
import {Collapse, Form, Input as AntInput} from 'antd';
|
|
import {Html5Outlined} from '@ant-design/icons';
|
|
|
|
type OwnProps = {
|
|
onHide: () => void;
|
|
};
|
|
|
|
type StateFromProps = {
|
|
settings: Settings;
|
|
};
|
|
|
|
type DispatchFromProps = {
|
|
updateSettings: (settings: Settings) => Action;
|
|
};
|
|
|
|
type State = {
|
|
url: string;
|
|
height: number;
|
|
width: number;
|
|
};
|
|
|
|
type Props = OwnProps & StateFromProps & DispatchFromProps;
|
|
class JSEmulatorLauncherSheet extends Component<Props, State> {
|
|
state: State = {...this.props.settings.jsApps.webAppLauncher};
|
|
|
|
applyChanges = async () => {
|
|
launchJsEmulator(this.state.url, this.state.height, this.state.width);
|
|
this.props.updateSettings({
|
|
...this.props.settings,
|
|
jsApps: {
|
|
webAppLauncher: {...this.state},
|
|
},
|
|
});
|
|
this.props.onHide();
|
|
};
|
|
|
|
onUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
this.setState({url: e.target.value});
|
|
};
|
|
|
|
onHeightChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
this.setState({height: Number(e.target.value)});
|
|
};
|
|
|
|
onWidthChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
this.setState({width: Number(e.target.value)});
|
|
};
|
|
|
|
render() {
|
|
const {url, height, width} = this.state;
|
|
return (
|
|
<Form labelCol={{span: 4}}>
|
|
<Form.Item label="Url">
|
|
<AntInput value={url} onChange={this.onUrlChange} />
|
|
</Form.Item>
|
|
<Form.Item label="Height">
|
|
<AntInput value={height} onChange={this.onHeightChange} />
|
|
</Form.Item>
|
|
<Form.Item label="Width">
|
|
<AntInput value={width} onChange={this.onWidthChange} />
|
|
</Form.Item>
|
|
<Form.Item wrapperCol={{offset: 4}}>
|
|
<Button onClick={this.applyChanges} type="primary">
|
|
Launch
|
|
</Button>
|
|
</Form.Item>
|
|
</Form>
|
|
);
|
|
}
|
|
}
|
|
|
|
const Launcher = connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
|
({settingsState}) => ({
|
|
settings: settingsState,
|
|
}),
|
|
{updateSettings},
|
|
)(JSEmulatorLauncherSheet);
|
|
|
|
export default Launcher;
|
|
|
|
export function JSEmulatorLauncherSheetSandy({onClose}: {onClose(): void}) {
|
|
return (
|
|
<Collapse>
|
|
<Collapse.Panel
|
|
extra={<Html5Outlined />}
|
|
header="Launch JS Web App"
|
|
key="launch-js-web-app">
|
|
<Launcher onHide={onClose} />
|
|
</Collapse.Panel>
|
|
</Collapse>
|
|
);
|
|
}
|