Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 14 additions & 25 deletions src/legacy/ui/public/vis/editors/config/editor_config_providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EditorConfigProviderRegistry {
current: EditorParamConfig,
merged: EditorParamConfig,
paramName: string
): { fixedValue?: any; base?: number } {
): { fixedValue: unknown } | { base: number } | {} {
if (
this.isFixedParam(current) &&
this.isFixedParam(merged) &&
Expand Down Expand Up @@ -128,37 +128,26 @@ class EditorConfigProviderRegistry {
current: TimeIntervalParam,
merged: EditorParamConfig,
paramName: string
): { timeBase?: string; default?: string } {
): { timeBase: string; default: string } {
if (current.default !== current.timeBase) {
throw new Error(`Tried to provide differing default and timeBase values for ${paramName}.`);
}

if (this.isTimeBaseParam(current) && this.isTimeBaseParam(merged)) {
if (this.isTimeBaseParam(merged)) {
// In case both had where interval values, just use the least common multiple between both intervals
try {
const timeBase = leastCommonInterval(current.timeBase, merged.timeBase);
return {
default: timeBase,
timeBase,
};
} catch (e) {
throw e;
}
}

if (this.isTimeBaseParam(current)) {
try {
parseEsInterval(current.timeBase);
return {
default: current.timeBase,
timeBase: current.timeBase,
};
} catch (e) {
throw e;
}
const timeBase = leastCommonInterval(current.timeBase, merged.timeBase);
return {
default: timeBase,
timeBase,
};
}

return {};
// This code is simply here to throw an error in case the `timeBase` is not a valid ES interval
parseEsInterval(current.timeBase);
return {
default: current.timeBase,
timeBase: current.timeBase,
};
}

private mergeConfigs(configs: EditorConfig[]): EditorConfig {
Expand Down