Skip to content
Snippets Groups Projects
Unverified Commit c210984c authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Remove flow from parameters (#19218)

parent fad4bc8a
No related branches found
No related tags found
No related merge requests found
......@@ -6,19 +6,8 @@ import Icon from "metabase/components/Icon";
import _ from "underscore";
import type {
ParameterMappingUIOption,
ParameterTarget,
} from "metabase-types/types/Parameter";
type Props = {
target: ?ParameterTarget,
onChange: (target: ?ParameterTarget) => void,
mappingOptions: ParameterMappingUIOption[],
};
export default class ParameterTargetList extends React.Component {
props: Props;
props;
render() {
const { target, mappingOptions } = this.props;
......
......@@ -8,21 +8,8 @@ import SelectButton from "metabase/components/SelectButton";
import _ from "underscore";
import cx from "classnames";
import type {
ParameterMappingUIOption,
ParameterTarget,
} from "metabase-types/types/Parameter";
type Props = {
target: ?ParameterTarget,
onChange: (target: ?ParameterTarget) => void,
mappingOptions: ParameterMappingUIOption[],
placeholder?: string,
children?: React.Element | (any => React.Element),
};
export default class ParameterTargetWidget extends React.Component {
constructor(props: Props) {
constructor(props) {
super(props);
this.popover = React.createRef();
......
......@@ -11,27 +11,6 @@ import {
} from "metabase/components/sortable";
import { getVisibleParameters } from "metabase/parameters/utils/ui";
import type { ParameterId, Parameter } from "metabase-types/types/Parameter";
import type { DashboardWithCards } from "metabase-types/types/Dashboard";
type Props = {
className?: string,
parameters: Parameter[],
dashboard?: DashboardWithCards,
editingParameter?: ?Parameter,
isFullscreen?: boolean,
isNightMode?: boolean,
hideParameters?: ?string, // comma separated list of slugs
isEditing?: boolean,
vertical?: boolean,
commitImmediately?: boolean,
setParameterIndex?: (parameterId: ParameterId, index: number) => void,
setEditingParameter?: (parameterId: ParameterId) => void,
};
const StaticParameterWidgetList = ({
children,
onSortStart,
......@@ -70,18 +49,12 @@ function ParametersList({
setParameterIndex,
removeParameter,
setEditingParameter,
}: Props) {
}) {
const handleSortStart = () => {
document.body.classList.add("grabbing");
};
const handleSortEnd = ({
oldIndex,
newIndex,
}: {
oldIndex: number,
newIndex: number,
}) => {
const handleSortEnd = ({ oldIndex, newIndex }) => {
document.body.classList.remove("grabbing");
if (setParameterIndex) {
setParameterIndex(parameters[oldIndex].id, newIndex);
......
......@@ -10,26 +10,14 @@ import FilterOptions from "metabase/query_builder/components/filters/FilterOptio
import { generateTimeFilterValuesDescriptions } from "metabase/lib/query_time";
import { dateParameterValueToMBQL } from "metabase/parameters/utils/mbql";
import type { OperatorName } from "metabase/query_builder/components/filters/pickers/DatePicker";
import type {
FieldFilter,
LocalFieldReference,
} from "metabase-types/types/Query";
type UrlEncoded = string;
// Use a placeholder value as field references are not used in dashboard filters
const noopRef: LocalFieldReference = null;
const noopRef = null;
function getFilterValueSerializer(
func: (val1: string, val2: string) => UrlEncoded,
) {
function getFilterValueSerializer(func) {
return filter => func(filter[2], filter[3], filter[4] || {});
}
const serializersByOperatorName: {
[id: OperatorName]: (FieldFilter) => UrlEncoded,
} = {
const serializersByOperatorName = {
previous: getFilterValueSerializer(
(value, unit, options = {}) =>
`past${-value}${unit}s${options["include-current"] ? "~" : ""}`,
......@@ -48,7 +36,7 @@ const serializersByOperatorName: {
function getFilterOperator(filter) {
return DATE_OPERATORS.find(op => op.test(filter));
}
function filterToUrlEncoded(filter: FieldFilter): ?UrlEncoded {
function filterToUrlEncoded(filter) {
const operator = getFilterOperator(filter);
if (operator) {
......@@ -58,7 +46,7 @@ function filterToUrlEncoded(filter: FieldFilter): ?UrlEncoded {
}
}
const prefixedOperators: Set<OperatorName> = new Set([
const prefixedOperators = new Set([
"before",
"after",
"on",
......@@ -73,18 +61,11 @@ function getFilterTitle(filter) {
return prefix + desc;
}
type Props = {
setValue: (value: ?string) => void,
onClose: () => void,
};
type State = { filter: FieldFilter };
export default class DateAllOptionsWidget extends Component {
props: Props;
state: State;
props;
state;
constructor(props: Props) {
constructor(props) {
super(props);
this.state = {
......@@ -98,7 +79,7 @@ export default class DateAllOptionsWidget extends Component {
static propTypes = {};
static defaultProps = {};
static format = (urlEncoded: ?string) => {
static format = urlEncoded => {
if (urlEncoded == null) {
return null;
}
......@@ -112,7 +93,7 @@ export default class DateAllOptionsWidget extends Component {
this.props.onClose();
};
setFilter = (filter: FieldFilter) => {
setFilter = filter => {
this.setState({ filter });
};
......
......@@ -23,7 +23,7 @@ export function createParameter(option, parameters = []) {
return setParameterName(parameter, name);
}
export function setParameterName(parameter, name: string) {
export function setParameterName(parameter, name) {
if (!name) {
name = "unnamed";
}
......@@ -35,7 +35,7 @@ export function setParameterName(parameter, name: string) {
};
}
export function setParameterDefaultValue(parameter, value: string) {
export function setParameterDefaultValue(parameter, value) {
return {
...parameter,
default: value,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment