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

release-23.1: ui: update sort setting on search criteria #99795

Merged
merged 1 commit into from
Mar 28, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const SchemaInsightsView: React.FC<SchemaInsightsViewProps> = ({
// redux changes and syncs the URL params with redux.
syncHistory(
{
ascending: sortSetting.ascending.toString(),
ascending: sortSetting.ascending?.toString(),
columnTitle: sortSetting.columnTitle,
...getFullFiltersAsStringRecord(filters),
[SCHEMA_INSIGHT_SEARCH_PARAM]: search,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ const statementsPagePropsFixture: StatementsPageProps = {
onFilterChange: noop,
onChangeLimit: noop,
onChangeReqSort: noop,
onApplySearchCriteria: noop,
};

export const statementsPagePropsWithRequestError: StatementsPageProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ cl-table-container {
margin-bottom: 0px;
}

.margin-bottom {
margin-bottom: 10px;
}

.root {
flex-grow: 0;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
updateSortSettingQueryParamsOnTab,
} from "src/sortedtable";
import { Search } from "src/search";
import { Pagination } from "src/pagination";
import { Pagination, ResultsPerPageLabel } from "src/pagination";
import {
calculateActiveFilters,
defaultFilters,
Expand Down Expand Up @@ -59,6 +59,7 @@ import {
SqlStatsSortType,
StatementsRequest,
createCombinedStmtsRequest,
SqlStatsSortOptions,
} from "src/api/statementsApi";
import ClearStats from "../sqlActivity/clearStats";
import LoadingError from "../sqlActivity/errorComponent";
Expand All @@ -83,8 +84,9 @@ import {
STATS_LONG_LOADING_DURATION,
stmtRequestSortOptions,
getSortLabel,
getSortColumn,
getSubsetWarning,
} from "src/util/sqlActivityConstants";
import { Button } from "src/button";
import { SearchCriteria } from "src/searchCriteria/searchCriteria";
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";

Expand Down Expand Up @@ -125,6 +127,7 @@ export interface StatementsPageDispatchProps {
onTimeScaleChange: (ts: TimeScale) => void;
onChangeLimit: (limit: number) => void;
onChangeReqSort: (sort: SqlStatsSortType) => void;
onApplySearchCriteria: (ts: TimeScale, limit: number, sort: string) => void;
}
export interface StatementsPageStateProps {
statements: AggregateStatistics[];
Expand Down Expand Up @@ -275,6 +278,13 @@ export class StatementsPage extends React.Component<
}
};

isSortSettingSameAsReqSort = (): boolean => {
return (
getSortColumn(this.state.reqSortSetting) ==
this.props.sortSetting.columnTitle
);
};

changeTimeScale = (ts: TimeScale): void => {
this.setState(prevState => ({
...prevState,
Expand All @@ -283,10 +293,30 @@ export class StatementsPage extends React.Component<
};

updateRequestParams = (): void => {
this.props.onChangeLimit(this.state.limit);
this.props.onChangeReqSort(this.state.reqSortSetting);
this.props.onTimeScaleChange(this.state.timeScale);
if (this.props.limit !== this.state.limit) {
this.props.onChangeLimit(this.state.limit);
}

if (this.props.reqSortSetting !== this.state.reqSortSetting) {
this.props.onChangeReqSort(this.state.reqSortSetting);
}

if (this.props.timeScale !== this.state.timeScale) {
this.props.onTimeScaleChange(this.state.timeScale);
}
if (this.props.onApplySearchCriteria) {
this.props.onApplySearchCriteria(
this.state.timeScale,
this.state.limit,
getSortLabel(this.state.reqSortSetting),
);
}
this.refreshStatements();
const ss: SortSetting = {
ascending: false,
columnTitle: getSortColumn(this.state.reqSortSetting),
};
this.changeSortSetting(ss);
};

resetPagination = (): void => {
Expand Down Expand Up @@ -478,6 +508,16 @@ export class StatementsPage extends React.Component<
this.setState(prevState => ({ ...prevState, reqSortSetting: newSort }));
};

hasReqSortOption = (): boolean => {
let found = false;
Object.values(SqlStatsSortOptions).forEach((option: SqlStatsSortType) => {
if (getSortColumn(option) == this.props.sortSetting.columnTitle) {
found = true;
}
});
return found;
};

renderStatements = (): React.ReactElement => {
const { pagination, filters, activeFilters } = this.state;
const {
Expand Down Expand Up @@ -598,6 +638,12 @@ export class StatementsPage extends React.Component<
<p className={timeScaleStylesCx("time-label")}>
Showing aggregated stats from{" "}
<span className={timeScaleStylesCx("bold")}>{period}</span>
{", "}
<ResultsPerPageLabel
pagination={{ ...pagination, total: data.length }}
pageName={"Statements"}
search={search}
/>
</p>
</PageConfigItem>
{hasAdminRole && (
Expand All @@ -620,6 +666,19 @@ export class StatementsPage extends React.Component<
onRemoveFilter={this.onSubmitFilters}
onClearFilters={this.onClearFilters}
/>
{!this.isSortSettingSameAsReqSort() && (
<InlineAlert
intent="warning"
title={getSubsetWarning(
"statement",
this.props.limit,
sortSettingLabel,
this.hasReqSortOption(),
this.props.sortSetting.columnTitle as StatisticTableColumnKeys,
)}
className={cx("margin-bottom")}
/>
)}
<StatementsSortedTable
className="statements-table"
data={data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ export const ConnectedStatementsPage = withRouter(
dispatch(updateStmtsPageLimitAction(limit)),
onChangeReqSort: (sort: SqlStatsSortType) =>
dispatch(updateStmsPageReqSortAction(sort)),
onApplySearchCriteria: (ts: TimeScale, limit: number, sort: string) =>
dispatch(
analyticsActions.track({
name: "Apply Search Criteria",
page: "Statements",
tsValue: ts.key,
limitValue: limit,
sortValue: sort,
}),
),
},
activePageProps: mapDispatchToRecentStatementsPageProps(dispatch),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ type Page =
| "Workload Insights - Statement"
| "Workload Insights - Transaction";

type ApplySearchCriteriaEvent = {
name: "Apply Search Criteria";
page: Page;
tsValue: string;
limitValue: number;
sortValue: string;
};

type BackButtonClick = {
name: "Back Clicked";
page: Page;
Expand Down Expand Up @@ -102,6 +110,7 @@ type TimeScaleChangeEvent = {
};

type AnalyticsEvent =
| ApplySearchCriteriaEvent
| BackButtonClick
| ColumnsChangeEvent
| FilterEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
SortSetting,
updateSortSettingQueryParamsOnTab,
} from "../sortedtable";
import { Pagination } from "../pagination";
import { Pagination, ResultsPerPageLabel } from "../pagination";
import { statisticsClasses } from "./transactionsPageClasses";
import {
aggregateAcrossNodeIDs,
Expand Down Expand Up @@ -54,6 +54,7 @@ import {
SqlStatsSortType,
createCombinedStmtsRequest,
StatementsRequest,
SqlStatsSortOptions,
} from "src/api/statementsApi";
import ColumnsSelector from "../columnsSelector/columnsSelector";
import { SelectOption } from "../multiSelectCheckbox/multiSelectCheckbox";
Expand All @@ -79,8 +80,9 @@ import {
STATS_LONG_LOADING_DURATION,
txnRequestSortOptions,
getSortLabel,
getSortColumn,
getSubsetWarning,
} from "src/util/sqlActivityConstants";
import { Button } from "src/button";
import { SearchCriteria } from "src/searchCriteria/searchCriteria";
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss";

Expand Down Expand Up @@ -131,6 +133,7 @@ export interface TransactionsPageDispatchProps {
columnTitle: string,
ascending: boolean,
) => void;
onApplySearchCriteria: (ts: TimeScale, limit: number, sort: string) => void;
}

export type TransactionsPageProps = TransactionsPageStateProps &
Expand Down Expand Up @@ -289,6 +292,13 @@ export class TransactionsPage extends React.Component<
}
};

isSortSettingSameAsReqSort = (): boolean => {
return (
getSortColumn(this.state.reqSortSetting) ==
this.props.sortSetting.columnTitle
);
};

onChangePage = (current: number): void => {
const { pagination } = this.state;
this.setState({ pagination: { ...pagination, current } });
Expand Down Expand Up @@ -391,10 +401,41 @@ export class TransactionsPage extends React.Component<
};

updateRequestParams = (): void => {
this.props.onChangeLimit(this.state.limit);
this.props.onChangeReqSort(this.state.reqSortSetting);
this.props.onTimeScaleChange(this.state.timeScale);
if (this.props.limit !== this.state.limit) {
this.props.onChangeLimit(this.state.limit);
}

if (this.props.reqSortSetting !== this.state.reqSortSetting) {
this.props.onChangeReqSort(this.state.reqSortSetting);
}

if (this.props.timeScale !== this.state.timeScale) {
this.props.onTimeScaleChange(this.state.timeScale);
}

if (this.props.onApplySearchCriteria) {
this.props.onApplySearchCriteria(
this.state.timeScale,
this.state.limit,
getSortLabel(this.state.reqSortSetting),
);
}
this.refreshData();
const ss: SortSetting = {
ascending: false,
columnTitle: getSortColumn(this.state.reqSortSetting),
};
this.onChangeSortSetting(ss);
};

hasReqSortOption = (): boolean => {
let found = false;
Object.values(SqlStatsSortOptions).forEach((option: SqlStatsSortType) => {
if (getSortColumn(option) == this.props.sortSetting.columnTitle) {
found = true;
}
});
return found;
};

renderTransactions(): React.ReactElement {
Expand Down Expand Up @@ -488,6 +529,7 @@ export class TransactionsPage extends React.Component<

const period = timeScaleToString(this.props.timeScale);
const sortSettingLabel = getSortLabel(this.props.reqSortSetting);

return (
<>
<h5 className={`${commonStyles("base-heading")} ${cx("margin-top")}`}>
Expand Down Expand Up @@ -527,6 +569,15 @@ export class TransactionsPage extends React.Component<
<p className={timeScaleStylesCx("time-label")}>
Showing aggregated stats from{" "}
<span className={timeScaleStylesCx("bold")}>{period}</span>
{", "}
<ResultsPerPageLabel
pagination={{
...pagination,
total: transactionsToDisplay.length,
}}
pageName={"Statements"}
search={search}
/>
</p>
</PageConfigItem>
{hasAdminRole && (
Expand All @@ -549,6 +600,19 @@ export class TransactionsPage extends React.Component<
onRemoveFilter={this.onSubmitFilters}
onClearFilters={this.onClearFilters}
/>
{!this.isSortSettingSameAsReqSort() && (
<InlineAlert
intent="warning"
title={getSubsetWarning(
"transaction",
this.props.limit,
sortSettingLabel,
this.hasReqSortOption(),
this.props.sortSetting.columnTitle as StatisticTableColumnKeys,
)}
className={cx("margin-bottom")}
/>
)}
<TransactionsTable
columns={displayColumns}
transactions={transactionsToDisplay}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ export const TransactionsPageConnected = withRouter(
dispatch(updateTxnsPageLimitAction(limit)),
onChangeReqSort: (sort: SqlStatsSortType) =>
dispatch(updateTxnsPageReqSortAction(sort)),
onApplySearchCriteria: (ts: TimeScale, limit: number, sort: string) =>
dispatch(
analyticsActions.track({
name: "Apply Search Criteria",
page: "Transactions",
tsValue: ts.key,
limitValue: limit,
sortValue: sort,
}),
),
},
activePageProps: mapDispatchToRecentTransactionsPageProps(dispatch),
}),
Expand Down
Loading