From 889f03b755231a9e764f89cf042e5e0148a4526d Mon Sep 17 00:00:00 2001 From: Laksh Singla Date: Thu, 7 Dec 2023 21:12:02 +0530 Subject: [PATCH] Web console: fix tab duplication (#15457) (#15508) * fix duplication * includeFuture defaults to true Co-authored-by: Vadim Ogievetsky --- .../src/components/rule-editor/rule-editor.tsx | 6 ++++-- .../src/druid-models/execution/execution.ts | 3 ++- web-console/src/utils/load-rule.ts | 16 +++++++++++----- .../src/views/workbench-view/workbench-view.tsx | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/web-console/src/components/rule-editor/rule-editor.tsx b/web-console/src/components/rule-editor/rule-editor.tsx index 3f72a8ca4119..8c40ede1ac54 100644 --- a/web-console/src/components/rule-editor/rule-editor.tsx +++ b/web-console/src/components/rule-editor/rule-editor.tsx @@ -200,11 +200,13 @@ export const RuleEditor = React.memo(function RuleEditor(props: RuleEditorProps) {RuleUtil.hasIncludeFuture(rule) && ( { - onChange?.(RuleUtil.changeIncludeFuture(rule, !rule.includeFuture)); + onChange?.( + RuleUtil.changeIncludeFuture(rule, !RuleUtil.getIncludeFuture(rule)), + ); }} /> )} diff --git a/web-console/src/druid-models/execution/execution.ts b/web-console/src/druid-models/execution/execution.ts index 1899f1260724..3e8b3af6d6b1 100644 --- a/web-console/src/druid-models/execution/execution.ts +++ b/web-console/src/druid-models/execution/execution.ts @@ -21,6 +21,7 @@ import { Column, QueryResult, SqlExpression, SqlQuery, SqlWithQuery } from '@dru import { deepGet, deleteKeys, + formatDuration, formatInteger, nonEmptyArray, oneOf, @@ -563,7 +564,7 @@ export class Execution { break; case 'SUCCESS': - label = 'Segments loaded successfully in ' + segmentStatus.duration + 'ms.'; + label = `Segments loaded successfully in ${formatDuration(segmentStatus.duration)}`; break; default: diff --git a/web-console/src/utils/load-rule.ts b/web-console/src/utils/load-rule.ts index 29e620848496..a32422bbb6a4 100644 --- a/web-console/src/utils/load-rule.ts +++ b/web-console/src/utils/load-rule.ts @@ -57,8 +57,9 @@ export class RuleUtil { static ruleToString(rule: Rule): string { const params: string[] = []; - if (RuleUtil.hasPeriod(rule)) - params.push(`${rule.period}${rule.includeFuture ? '+future' : ''}`); + if (RuleUtil.hasPeriod(rule)) { + params.push(`${rule.period}${RuleUtil.getIncludeFuture(rule) ? '+future' : ''}`); + } if (RuleUtil.hasInterval(rule)) params.push(rule.interval || '?'); if (RuleUtil.canHaveTieredReplicants(rule)) params.push(`${RuleUtil.totalReplicas(rule)}x`); @@ -69,20 +70,21 @@ export class RuleUtil { const newRule = deepSet(rule, 'type', type); if (RuleUtil.hasPeriod(newRule)) { - if (!newRule.period) newRule.period = 'P1M'; + newRule.period ??= 'P1M'; + newRule.includeFuture ??= true; } else { delete newRule.period; delete newRule.includeFuture; } if (RuleUtil.hasInterval(newRule)) { - if (!newRule.interval) newRule.interval = '2010-01-01/2020-01-01'; + newRule.interval ??= '2010-01-01/2020-01-01'; } else { delete newRule.interval; } if (RuleUtil.canHaveTieredReplicants(newRule)) { - if (!newRule.tieredReplicants) newRule.tieredReplicants = { _default_tier: 2 }; + newRule.tieredReplicants ??= { _default_tier: 2 }; } else { delete newRule.tieredReplicants; } @@ -102,6 +104,10 @@ export class RuleUtil { return RuleUtil.hasPeriod(rule) && rule.type !== 'dropBeforeByPeriod'; } + static getIncludeFuture(rule: Rule): boolean { + return rule.includeFuture ?? true; + } + static changeIncludeFuture(rule: Rule, includeFuture: boolean): Rule { return deepSet(rule, 'includeFuture', includeFuture); } diff --git a/web-console/src/views/workbench-view/workbench-view.tsx b/web-console/src/views/workbench-view/workbench-view.tsx index 097dfd2e4af2..9c859f9b4625 100644 --- a/web-console/src/views/workbench-view/workbench-view.tsx +++ b/web-console/src/views/workbench-view/workbench-view.tsx @@ -496,7 +496,7 @@ export class WorkbenchView extends React.PureComponent