"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/sapp/sapp/frontend/src/Filter.js" between
pyre-check-0.0.53.tar.gz and pyre-check-0.0.54.tar.gz

About: Pyre is a performant type checker for Python (ships with Pysa, a security focused static analysis tool).

Filter.js  (pyre-check-0.0.53):Filter.js  (pyre-check-0.0.54)
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
* *
* @format * @format
* @flow * @flow
*/ */
import React, {useState} from 'react'; import React from 'react';
import {
Popover,
Button,
Form,
Input,
InputNumber,
Row,
Col,
Divider,
} from 'antd';
import {SearchOutlined} from '@ant-design/icons';
const Filter = (props: {refetch: any}) => { const Filter = (props: {refetch: any}) => {
const [codes, setCodes] = useState(''); const onFinish = values => {
const [file_names, setFileNames] = useState(''); const split = input => {
const [callables, setCallables] = useState(''); if (input !== '' && input !== undefined) {
const [min_trace_length_to_sinks, setMinLengthToSink] = useState(''); return input.trim().split(';');
const [max_trace_length_to_sinks, setMaxLengthToSink] = useState(''); }
const [min_trace_length_to_sources, setMinLengthToSource] = useState(''); return undefined;
const [max_trace_length_to_sources, setMaxLengthToSource] = useState(''); };
function parse_filter(filter) { let codes = split(values.codes);
if (filter !== '' && filter != null) { if (codes !== undefined) {
return filter.trim().split(';'); values.codes = codes.map(parseInt);
} else {
values.codes = undefined;
} }
return null;
}
const handleSubmit = event => { values.file_names = split(values.file_names);
event.preventDefault(); values.callables = split(values.callables);
let variables = {}; const parse_bound = input => {
let parsed = parse_filter(codes); if (input !== '' && input !== undefined) {
variables.codes = parsed !== null ? parsed.map(Number) : null; return parseInt(input.trim());
variables.names = parse_filter(file_names); }
variables.callables = parse_filter(callables); return undefined;
};
variables.min_trace_length_to_sinks =
parse_filter(min_trace_length_to_sinks) !== null values.min_trace_length_to_sinks = parse_bound(
? parseInt(parse_filter(min_trace_length_to_sinks)) values.min_trace_length_to_sinks,
: null; );
values.max_trace_length_to_sinks = parse_bound(
variables.max_trace_length_to_sinks = values.max_trace_length_to_sinks,
parse_filter(max_trace_length_to_sinks) !== null );
? parseInt(parse_filter(max_trace_length_to_sinks)) values.min_trace_length_to_sources = parse_bound(
: null; values.min_trace_length_to_sources,
);
variables.min_trace_length_to_sources = values.max_trace_length_to_sources = parse_bound(
parse_filter(min_trace_length_to_sources) !== null values.max_trace_length_to_sources,
? parseInt(parse_filter(min_trace_length_to_sources)) );
: null;
variables.max_trace_length_to_sources =
parse_filter(max_trace_length_to_sources) !== null
? parseInt(parse_filter(max_trace_length_to_sources))
: null;
props.refetch(variables); props.refetch(values);
}; };
const form = (
<div style={{width: '300px'}}>
<Form
labelCol={{span: 10}}
wrapperCol={{span: 30}}
name="basic"
initialValues={{remember: true}}
onFinish={onFinish}>
<Form.Item label="Codes" name="codes">
<Input />
</Form.Item>
<Form.Item label="File Names" name="file_names">
<Input />
</Form.Item>
<Form.Item label="Callables" name="callables">
<Input />
</Form.Item>
<Divider orientation="left" plain>
Trace Lengths
</Divider>
<Form.Item label="to Sinks">
<Row>
<Col span={8}>
<Form.Item
name="min_trace_length_to_sinks"
style={{marginBottom: 0}}>
<InputNumber placeholder="min" />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item
name="max_trace_length_to_sinks"
style={{marginBottom: 0}}>
<InputNumber placeholder="max" />
</Form.Item>
</Col>
</Row>
</Form.Item>
<Form.Item label="to Sources">
<Row>
<Col span={8}>
<Form.Item
name="min_trace_length_to_sources"
style={{marginBottom: 0}}>
<InputNumber placeholder="min" />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item
name="max_trace_length_to_sources"
style={{marginBottom: 0}}>
<InputNumber placeholder="max" />
</Form.Item>
</Col>
</Row>
</Form.Item>
<Form.Item wrapperCol={{offset: 10, span: 20}}>
<Button type="primary" htmlType="submit">
Apply
</Button>
</Form.Item>
</Form>
</div>
);
return ( return (
<> <>
<h2>Filter</h2> <div style={{textAlign: 'right', margin: '10px 0 -40px 0'}}>
<form onSubmit={handleSubmit}> <Popover content={form} placement="bottomRight" trigger="click">
<label> <Button icon={<SearchOutlined />}>Filter...</Button>
Codes </Popover>
<input </div>
type="text"
value={codes}
onChange={e => setCodes(e.target.value)}
/>
</label>
<br />
<label>
File Names
<input
type="text"
value={file_names}
onChange={e => setFileNames(e.target.value)}
/>
</label>
<br />
<label>
Callables
<input
type="text"
value={callables}
onChange={e => setCallables(e.target.value)}
/>
</label>
<br />
<label>
Min Trace Length To Sinks
<input
type="text"
value={min_trace_length_to_sinks}
onChange={e => setMinLengthToSink(e.target.value)}
/>
</label>
<br />
<label>
Max Trace Length to Sinks
<input
type="text"
value={max_trace_length_to_sinks}
onChange={e => setMaxLengthToSink(e.target.value)}
/>
</label>
<br />
<label>
Min Trace Length To Sources
<input
type="text"
value={min_trace_length_to_sources}
onChange={e => setMinLengthToSource(e.target.value)}
/>
</label>
<br />
<label>
Max Trace Length to Sources
<input
type="text"
value={max_trace_length_to_sources}
onChange={e => setMaxLengthToSource(e.target.value)}
/>
</label>
<br />
<input type="submit" value="Submit" />
</form>
</> </>
); );
}; };
export default Filter; export default Filter;
 End of changes. 8 change blocks. 
109 lines changed or deleted 117 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)