chore: make TS enums strictly PascalCase (#26875)

This commit is contained in:
Ville Brofeldt
2024-01-31 17:40:44 -08:00
committed by GitHub
parent 959a5a5ad6
commit 19f8405bc0
362 changed files with 2002 additions and 2032 deletions

View File

@@ -56,8 +56,8 @@ export type GetTableSize = () => Partial<StickyState> | undefined;
export type SetStickyState = (size?: Partial<StickyState>) => void;
export enum ReducerActions {
init = 'init', // this is from global reducer
setStickyState = 'setStickyState',
Init = 'init', // this is from global reducer
SetStickyState = 'setStickyState',
}
export type ReducerAction<
@@ -341,7 +341,7 @@ function useInstance<D extends object>(instance: TableInstance<D>) {
const setStickyState = useCallback(
(size?: Partial<StickyState>) => {
dispatch({
type: ReducerActions.setStickyState,
type: ReducerActions.SetStickyState,
size,
});
},
@@ -395,7 +395,7 @@ export default function useSticky<D extends object>(hooks: Hooks<D>) {
ReducerActions,
{ size: StickyState }
>;
if (action.type === ReducerActions.init) {
if (action.type === ReducerActions.Init) {
return {
...newState,
sticky: {
@@ -403,7 +403,7 @@ export default function useSticky<D extends object>(hooks: Hooks<D>) {
},
};
}
if (action.type === ReducerActions.setStickyState) {
if (action.type === ReducerActions.SetStickyState) {
const { size } = action;
if (!size) {
return { ...newState };

View File

@@ -81,10 +81,10 @@ const ACTION_KEYS = {
* Return sortType based on data type
*/
function getSortTypeByDataType(dataType: GenericDataType): DefaultSortTypes {
if (dataType === GenericDataType.TEMPORAL) {
if (dataType === GenericDataType.Temporal) {
return 'datetime';
}
if (dataType === GenericDataType.STRING) {
if (dataType === GenericDataType.String) {
return 'alphanumeric';
}
return 'basic';

View File

@@ -39,12 +39,12 @@ import { updateExternalFormData } from './DataTable/utils/externalAPIs';
*/
export function getQueryMode(formData: TableChartFormData) {
const { query_mode: mode } = formData;
if (mode === QueryMode.aggregate || mode === QueryMode.raw) {
if (mode === QueryMode.Aggregate || mode === QueryMode.Raw) {
return mode;
}
const rawColumns = formData?.all_columns;
const hasRawColumns = rawColumns && rawColumns.length > 0;
return hasRawColumns ? QueryMode.raw : QueryMode.aggregate;
return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate;
}
const buildQuery: BuildQuery<TableChartFormData> = (
@@ -62,7 +62,7 @@ const buildQuery: BuildQuery<TableChartFormData> = (
extra_form_data?.time_grain_sqla || formData.time_grain_sqla;
let formDataCopy = formData;
// never include time in raw records mode
if (queryMode === QueryMode.raw) {
if (queryMode === QueryMode.Raw) {
formDataCopy = {
...formData,
include_time: false,
@@ -73,7 +73,7 @@ const buildQuery: BuildQuery<TableChartFormData> = (
let { metrics, orderby = [], columns = [] } = baseQueryObject;
let postProcessing: PostProcessingRule[] = [];
if (queryMode === QueryMode.aggregate) {
if (queryMode === QueryMode.Aggregate) {
metrics = metrics || [];
// override orderby with timeseries metric when in aggregation mode
if (sortByMetric) {
@@ -161,7 +161,7 @@ const buildQuery: BuildQuery<TableChartFormData> = (
if (
metrics?.length &&
formData.show_totals &&
queryMode === QueryMode.aggregate
queryMode === QueryMode.Aggregate
) {
extraQueries.push({
...queryObject,

View File

@@ -50,14 +50,14 @@ import { PAGE_SIZE_OPTIONS } from './consts';
function getQueryMode(controls: ControlStateMapping): QueryMode {
const mode = controls?.query_mode?.value;
if (mode === QueryMode.aggregate || mode === QueryMode.raw) {
if (mode === QueryMode.Aggregate || mode === QueryMode.Raw) {
return mode as QueryMode;
}
const rawColumns = controls?.all_columns?.value as
| QueryFormColumn[]
| undefined;
const hasRawColumns = rawColumns && rawColumns.length > 0;
return hasRawColumns ? QueryMode.raw : QueryMode.aggregate;
return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate;
}
/**
@@ -68,8 +68,8 @@ function isQueryMode(mode: QueryMode) {
getQueryMode(controls) === mode;
}
const isAggMode = isQueryMode(QueryMode.aggregate);
const isRawMode = isQueryMode(QueryMode.raw);
const isAggMode = isQueryMode(QueryMode.Aggregate);
const isRawMode = isQueryMode(QueryMode.Raw);
const validateAggControlValues = (
controls: ControlStateMapping,
@@ -86,8 +86,8 @@ const queryMode: ControlConfig<'RadioButtonControl'> = {
label: t('Query mode'),
default: null,
options: [
[QueryMode.aggregate, QueryModeLabel[QueryMode.aggregate]],
[QueryMode.raw, QueryModeLabel[QueryMode.raw]],
[QueryMode.Aggregate, QueryModeLabel[QueryMode.Aggregate]],
[QueryMode.Raw, QueryModeLabel[QueryMode.Raw]],
],
mapStateToProps: ({ controls }) => ({ value: getQueryMode(controls) }),
rerender: ['all_columns', 'groupby', 'metrics', 'percent_metrics'],
@@ -501,7 +501,7 @@ const config: ControlPanelConfig = {
? colnames
.filter(
(colname: string, index: number) =>
coltypes[index] === GenericDataType.NUMERIC,
coltypes[index] === GenericDataType.Numeric,
)
.map(colname => ({
value: colname,

View File

@@ -32,9 +32,9 @@ export * from './types';
const metadata = new ChartMetadata({
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Behavior.DRILL_BY,
Behavior.InteractiveChart,
Behavior.DrillToDetail,
Behavior.DrillBy,
],
category: t('Table'),
canBeAnnotationTypes: ['EVENT', 'INTERVAL'],

View File

@@ -62,7 +62,7 @@ const processDataRecords = memoizeOne(function processDataRecords(
return data || [];
}
const timeColumns = columns.filter(
column => column.dataType === GenericDataType.TEMPORAL,
column => column.dataType === GenericDataType.Temporal,
);
if (timeColumns.length > 0) {
@@ -122,8 +122,8 @@ const processColumns = memoizeOne(function processColumns(
isPercentMetric && verboseMap?.hasOwnProperty(key.replace('%', ''))
? `%${verboseMap[key.replace('%', '')]}`
: verboseMap?.[key] || key;
const isTime = dataType === GenericDataType.TEMPORAL;
const isNumber = dataType === GenericDataType.NUMERIC;
const isTime = dataType === GenericDataType.Temporal;
const isNumber = dataType === GenericDataType.Numeric;
const savedFormat = columnFormats?.[key];
const savedCurrency = currencyFormats?.[key];
const numberFormat = config.d3NumberFormat || savedFormat;
@@ -172,7 +172,7 @@ const processColumns = memoizeOne(function processColumns(
key,
label,
dataType,
isNumeric: dataType === GenericDataType.NUMERIC,
isNumeric: dataType === GenericDataType.Numeric,
isMetric,
isPercentMetric,
formatter,
@@ -257,7 +257,7 @@ const transformProps = (
}
const data = processDataRecords(baseQuery?.data, columns);
const totals =
showTotals && queryMode === QueryMode.aggregate
showTotals && queryMode === QueryMode.Aggregate
? totalQuery?.data[0]
: undefined;
const columnColorFormatters =
@@ -266,7 +266,7 @@ const transformProps = (
return {
height,
width,
isRawRecords: queryMode === QueryMode.raw,
isRawRecords: queryMode === QueryMode.Raw,
data,
totals,
columns,

View File

@@ -60,7 +60,7 @@ export function formatColumnValue(
value: DataRecordValue,
) {
const { dataType, formatter, config = {} } = column;
const isNumber = dataType === GenericDataType.NUMERIC;
const isNumber = dataType === GenericDataType.Numeric;
const smallNumberFormatter =
config.d3SmallNumberFormat === undefined
? formatter