Skip to content

Commit

Permalink
Web console: fix tab duplication (apache#15457) (apache#15508)
Browse files Browse the repository at this point in the history
* fix duplication

* includeFuture defaults to true

Co-authored-by: Vadim Ogievetsky <[email protected]>
  • Loading branch information
LakshSingla and vogievetsky authored Dec 7, 2023
1 parent f7e34e7 commit 889f03b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 4 additions & 2 deletions web-console/src/components/rule-editor/rule-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ export const RuleEditor = React.memo(function RuleEditor(props: RuleEditorProps)
{RuleUtil.hasIncludeFuture(rule) && (
<Switch
className="include-future"
checked={rule.includeFuture || false}
checked={RuleUtil.getIncludeFuture(rule)}
label="Include future"
disabled={disabled}
onChange={() => {
onChange?.(RuleUtil.changeIncludeFuture(rule, !rule.includeFuture));
onChange?.(
RuleUtil.changeIncludeFuture(rule, !RuleUtil.getIncludeFuture(rule)),
);
}}
/>
)}
Expand Down
3 changes: 2 additions & 1 deletion web-console/src/druid-models/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Column, QueryResult, SqlExpression, SqlQuery, SqlWithQuery } from '@dru
import {
deepGet,
deleteKeys,
formatDuration,
formatInteger,
nonEmptyArray,
oneOf,
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 11 additions & 5 deletions web-console/src/utils/load-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

Expand All @@ -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;
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion web-console/src/views/workbench-view/workbench-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class WorkbenchView extends React.PureComponent<WorkbenchViewProps, Workb
const newTabEntry: TabEntry = {
id,
tabName: tabEntry.tabName + ' (copy)',
query: tabEntry.query,
query: tabEntry.query.changeLastExecution(undefined),
};
this.handleQueriesChange(
tabEntries.slice(0, i + 1).concat(newTabEntry, tabEntries.slice(i + 1)),
Expand Down

0 comments on commit 889f03b

Please sign in to comment.