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: select grants tab on table details page #73932

Merged
merged 1 commit into from
Dec 17, 2021
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 @@ -366,7 +366,7 @@ export class DatabaseDetailsPage extends React.Component<
),
cell: table => (
<Link
to={`/database/${this.props.name}/table/${table.name}`}
to={`/database/${this.props.name}/table/${table.name}?tab=grants`}
className={cx("icon__container")}
>
<DatabaseIcon className={cx("icon--s")} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
} from "src/storybook/fixtures";
import { DatabaseTablePage, DatabaseTablePageProps } from "./databaseTablePage";
import moment from "moment";
import * as H from "history";
const history = H.createHashHistory();

const withLoadingIndicator: DatabaseTablePageProps = {
databaseName: randomName(),
Expand All @@ -44,6 +46,14 @@ const withLoadingIndicator: DatabaseTablePageProps = {
stats: [],
lastReset: moment("2021-09-04T13:55:00Z"),
},
location: history.location,
history,
match: {
url: "",
path: history.location.pathname,
isExact: false,
params: {},
},
refreshTableDetails: () => {},
refreshTableStats: () => {},
refreshIndexStats: () => {},
Expand Down Expand Up @@ -114,6 +124,14 @@ const withData: DatabaseTablePageProps = {
],
lastReset: moment("2021-09-04T13:55:00Z"),
},
location: history.location,
history,
match: {
url: "",
path: history.location.pathname,
isExact: false,
params: {},
},
refreshTableDetails: () => {},
refreshTableStats: () => {},
refreshIndexStats: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import React from "react";
import { Col, Row, Tabs } from "antd";
import { RouteComponentProps } from "react-router-dom";
import classNames from "classnames/bind";
import _ from "lodash";
import { Tooltip } from "antd";
Expand All @@ -22,6 +23,7 @@ import { SqlBox } from "src/sql";
import { ColumnDescriptor, SortSetting, SortedTable } from "src/sortedtable";
import { SummaryCard, SummaryCardItem } from "src/summaryCard";
import * as format from "src/util/format";
import { syncHistory } from "src/util";

import styles from "./databaseTablePage.module.scss";
import { commonStyles } from "src/common";
Expand Down Expand Up @@ -129,10 +131,12 @@ export interface DatabaseTablePageActions {
}

export type DatabaseTablePageProps = DatabaseTablePageData &
DatabaseTablePageActions;
DatabaseTablePageActions &
RouteComponentProps;

interface DatabaseTablePageState {
sortSetting: SortSetting;
tab: string;
}

class DatabaseTableGrantsTable extends SortedTable<Grant> {}
Expand All @@ -145,18 +149,33 @@ export class DatabaseTablePage extends React.Component<
constructor(props: DatabaseTablePageProps) {
super(props);

const { history } = this.props;
const searchParams = new URLSearchParams(history.location.search);
const defaultTab = searchParams.get("tab") || "overview";

this.state = {
sortSetting: {
ascending: true,
},
tab: defaultTab,
};
}

componentDidMount() {
onTabChange = (tab: string): void => {
this.setState({ tab });
syncHistory(
{
tab: tab,
},
this.props.history,
);
};

componentDidMount(): void {
this.refresh();
}

componentDidUpdate() {
componentDidUpdate(): void {
this.refresh();
}

Expand Down Expand Up @@ -284,7 +303,7 @@ export class DatabaseTablePage extends React.Component<
},
];

render() {
render(): React.ReactElement {
return (
<div className="root table-area">
<section className={baseHeadingClasses.wrapper}>
Expand Down Expand Up @@ -313,7 +332,11 @@ export class DatabaseTablePage extends React.Component<
</section>

<section className={(baseHeadingClasses.wrapper, cx("tab-area"))}>
<Tabs className={commonStyles("cockroach--tabs")}>
<Tabs
className={commonStyles("cockroach--tabs")}
onChange={this.onTabChange}
activeKey={this.state.tab}
>
<TabPane tab="Overview" key="overview">
<Row gutter={18}>
<Col className="gutter-row" span={18}>
Expand Down