Skip to content

Commit

Permalink
ui: Default sort by Execution Count column for Statements
Browse files Browse the repository at this point in the history
Before, default sorting was set to Latency column in
Statements page that was unintuitive.
Now it is sorted by Execution count column.

Release note (admin ui change): Change default sorting column on Statements
page to Execution Count

Release justification: bug fixes and low-risk updates to new functionality
  • Loading branch information
koorosh committed Mar 31, 2020
1 parent 8a50e9f commit 5c47160
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
34 changes: 34 additions & 0 deletions pkg/ui/src/views/statements/statementsPage.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

import React from "react";
import { assert } from "chai";
import { ReactWrapper } from "enzyme";

import { connectedMount } from "src/test-utils";
import StatementsPageConnected, {
StatementsPage,
StatementsPageProps,
StatementsPageState,
} from "src/views/statements/statementsPage";

describe("StatementsPage", () => {
describe("Statements table", () => {
it("sorts data by Execution Count DESC as default option", () => {
const rootWrapper = connectedMount(() => <StatementsPageConnected />);

const statementsPageWrapper: ReactWrapper<StatementsPageProps, StatementsPageState> = rootWrapper.find(StatementsPage).first();
const statementsPageInstance = statementsPageWrapper.instance();

assert.equal(statementsPageInstance.state.sortSetting.sortKey, 3);
assert.equal(statementsPageInstance.state.sortSetting.ascending, false);
});
});
});
12 changes: 7 additions & 5 deletions pkg/ui/src/views/statements/statementsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import "./statements.styl";

type ICollectedStatementStatistics = protos.cockroach.server.serverpb.StatementsResponse.ICollectedStatementStatistics;

interface StatementsPageProps {
interface OwnProps {
statements: AggregateStatistics[];
statementsError: Error | null;
apps: string[];
Expand All @@ -62,20 +62,22 @@ type PaginationSettings = {
current: number;
};

interface StatementsPageState {
export interface StatementsPageState {
sortSetting: SortSetting;
pagination: PaginationSettings;
search?: string;
}

export class StatementsPage extends React.Component<StatementsPageProps & RouteComponentProps<any>, StatementsPageState> {
export type StatementsPageProps = OwnProps & RouteComponentProps<any>;

export class StatementsPage extends React.Component<StatementsPageProps, StatementsPageState> {
activateDiagnosticsRef: React.RefObject<ActivateDiagnosticsModalRef>;

constructor(props: StatementsPageProps & RouteComponentProps<any>) {
constructor(props: StatementsPageProps) {
super(props);
const defaultState = {
sortSetting: {
sortKey: 6, // Latency column is default for sorting
sortKey: 3, // Sort by Execution Count column as default option
ascending: false,
},
pagination: {
Expand Down

0 comments on commit 5c47160

Please sign in to comment.