Files
flipper/desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchConfig.tsx
Andrey Goncharov 294f39eceb Allow freeform entries for enum terms
Summary: Solves https://fb.workplace.com/groups/flippersupport/posts/1726178417862809/?comment_id=1726429847837666&reply_comment_id=1730206487460002

Reviewed By: passy

Differential Revision: D51497924

fbshipit-source-id: d0737b2b82f29ff8ae654e7cad2ef1daa8244756
2023-11-21 11:40:23 -08:00

98 lines
2.1 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// Mostly matches https://www.internalfb.com/code/www/html/intern/js/ui/PowerSearch/PowerSearchExampleConfig.js
export type NullishFilterValueType = 'NO_VALUE';
export type StringFilterValueType = 'STRING';
export type StringSetFilterValueType = 'STRING_SET';
export type IntegerFilterValueType = 'INTEGER';
export type FloatFilterValueType = 'FLOAT';
export type EnumFilterValueType = 'ENUM' | 'ENUM_SET';
export type AbsoluteDateFilterValueType = 'ABSOLUTE_DATE';
export type NullishOperatorConfig = {
valueType: NullishFilterValueType;
key: string;
label: string;
};
export type StringOperatorConfig = {
valueType: StringFilterValueType;
key: string;
label: string;
};
export type StringSetOperatorConfig = {
valueType: StringSetFilterValueType;
key: string;
label: string;
};
export type IntegerOperatorConfig = {
valueType: IntegerFilterValueType;
key: string;
label: string;
};
export type FloatOperatorConfig = {
valueType: FloatFilterValueType;
key: string;
label: string;
precision?: number;
};
/**
* { value: label }
*/
export type EnumLabels = {[key: string | number]: string | number};
export type EnumOperatorConfig = {
valueType: EnumFilterValueType;
key: string;
label: string;
enumLabels: EnumLabels;
allowFreeform?: boolean;
};
export type AbsoluteDateOperatorConfig = {
valueType: AbsoluteDateFilterValueType;
key: string;
label: string;
dateOnly?: boolean;
minValue?: Date;
maxValue?: Date;
};
export type OperatorConfig =
| NullishOperatorConfig
| StringOperatorConfig
| StringSetOperatorConfig
| IntegerOperatorConfig
| FloatOperatorConfig
| EnumOperatorConfig
| AbsoluteDateOperatorConfig;
export type FieldConfig = {
key: string;
label: string;
operators: {[key: string]: OperatorConfig};
useWholeRow?: boolean;
};
export type PowerSearchConfig = {
fields: {[key: string]: FieldConfig};
};