Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Default sort by Execution Count column for Statements #46780

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
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
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