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: rebuild the databases pages #68390

Merged
merged 1 commit into from
Aug 12, 2021
Merged

ui: rebuild the databases pages #68390

merged 1 commit into from
Aug 12, 2021

Conversation

matthewtodd
Copy link
Contributor

@matthewtodd matthewtodd commented Aug 3, 2021

Previously, the databases pages featured an older, outdated design. This
change aligns their UX with that of the other modern pages in the DB
console, statements, transactions, and sessions.

This is a first pass at the job. We will return to layer on more
features, including search, and more data, including node & region
information.

Addresses #65737.

Before After
Screen Shot 2021-08-05 at 4 54 31 PM Screen Shot 2021-08-03 at 2 50 12 PM
Screen Shot 2021-08-05 at 4 54 57 PM Screen Shot 2021-08-03 at 2 50 21 PM
Screen Shot 2021-08-05 at 5 03 37 PM (This overview of database grants no longer exists.)
(This rolled-up view of table grants did not previously exist.) Screen Shot 2021-08-03 at 2 50 27 PM
Screen Shot 2021-08-05 at 4 55 21 PM Screen Shot 2021-08-03 at 2 50 35 PM
Screen Shot 2021-08-05 at 4 55 28 PM Screen Shot 2021-08-03 at 2 50 41 PM

Release note (ui change): The databases pages in the DB console were
updated to bring them into alignment with our modern UX.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 53 of 64 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @matthewtodd)


pkg/ui/cluster-ui/src/databasePage/databasePage.tsx, line 1 at r1 (raw file):

// Copyright 2021 The Cockroach Authors.

nit: file name databaseDetailsPage


pkg/ui/cluster-ui/src/databasePage/databasePage.tsx, line 42 at r1 (raw file):

const sortableTableCx = classNames.bind(sortableTableStyles);

export interface DatabasePageDataTableDetails {

nit: add comments for all data interfaces


pkg/ui/cluster-ui/src/databasePage/databasePage.tsx, line 141 at r1 (raw file):

  }

  private changeView(view: ViewOption) {

nit: maybe a comment for now (or think of a clear name)


pkg/ui/cluster-ui/src/databasePage/databasePage.tsx, line 145 at r1 (raw file):

  }

  private columns(): ColumnDescriptor<DatabasePageDataTable>[] {

nit: separate between table and grant


pkg/ui/cluster-ui/src/databasePage/databasePage.tsx, line 274 at r1 (raw file):

  }

  private viewSelectionTitle(): string {

nit: inline this function


pkg/ui/cluster-ui/src/databasePage/databasePage.module.scss, line 1 at r1 (raw file):

// Copyright 2021 The Cockroach Authors.

nit: file name databaseDetailsPage


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 37 at r1 (raw file):

const sortableTableCx = classNames.bind(sortableTableStyles);

export interface DatabasesPageDataMissingTable {

nit: add comments for interfaces


pkg/ui/cluster-ui/src/databaseTablePage/databaseTablePage.tsx, line 16 at r1 (raw file):

import _ from "lodash";

import { AlignedIcon } from "src/icon/alignedIcon";

nit: group with icon import


pkg/ui/cluster-ui/src/databaseTablePage/databaseTablePage.tsx, line 35 at r1 (raw file):

}

export interface DatabaseTablePageDataDetails {

nit: add comments for interfaces


pkg/ui/cluster-ui/src/icon/alignedIcon.tsx, line 17 at r1 (raw file):

const cx = classNames.bind(styles);

export interface AlignedIconProps {

check titleWithIcon component


pkg/ui/cluster-ui/src/icon/icon.tsx, line 1 at r1 (raw file):

// Copyright 2021 The Cockroach Authors.

we might want to create a task for refactor current usage of icons, so they're all in this same place


pkg/ui/cluster-ui/src/storybook/fixtures/randomName.ts, line 1 at r1 (raw file):

// Copyright 2021 The Cockroach Authors.

check if these files are being added to the build


pkg/ui/src/util/fakeApi.ts, line 11 at r1 (raw file):

// licenses/APL.txt.

import * as $protobuf from "protobufjs";

nit: add comment about usage of this file (for testing)
add examples


pkg/ui/src/views/databases/databasePage/redux.spec.ts, line 196 at r1 (raw file):

    await driver.refreshDatabaseDetails();
    await driver.refreshTableDetails("foo");

create a test for checking two tables with different values


pkg/ui/src/views/databases/databasePage/redux.spec.ts, line 216 at r1 (raw file):

    fakeApi.stubTableDetails("things", "foo", {
      grants: [
        { user: "bloblaw", privileges: ["ALL"] },

nit: add another role to test the alphabetical order


pkg/ui/src/views/databases/databasesPage/redux.ts, line 27 at r1 (raw file):

const { DatabaseDetailsRequest, TableStatsRequest } = cockroach.server.serverpb;

export const mapStateToProps = createSelector(

consider extracting this outside of this redux to a place that can be used by crdb and cloud db (and serverless )


pkg/ui/src/views/databases/databasesPage/redux.ts, line 55 at r1 (raw file):

        // all of their individual stats.

        const possiblyMissingTables = stats

consider a different visual for the user when something is missing. Discuss with Anne possible solutions. We want the user to know that some data might be missing.

Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @maryliag)


pkg/ui/cluster-ui/src/icon/icon.tsx, line 1 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

we might want to create a task for refactor current usage of icons, so they're all in this same place

Done, #68501


pkg/ui/cluster-ui/src/storybook/fixtures/randomName.ts, line 1 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

check if these files are being added to the build

All clear!

$ grep randomName pkg/ui/cluster-ui/dist/main.js
$ grep randomRole pkg/ui/cluster-ui/dist/main.js
$ grep randomTablePrivilege pkg/ui/cluster-ui/dist/main.js
$

pkg/ui/src/views/databases/databasesPage/redux.ts, line 27 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

consider extracting this outside of this redux to a place that can be used by crdb and cloud db (and serverless )

Good idea, I think it'll make sense to do this extraction as we're starting to support cloud / serverless.


pkg/ui/src/views/databases/databasesPage/redux.ts, line 55 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

consider a different visual for the user when something is missing. Discuss with Anne possible solutions. We want the user to know that some data might be missing.

Good idea, I've captured a note to follow up with Anne when she gets back. It is unclear to me how common this case is and how much we need to design for it; just that's it's possible. In the meantime, per our brief conversation in today's standup, we'll look into it as part of a follow-on task, not for this PR.


pkg/ui/cluster-ui/src/icon/alignedIcon.tsx, line 17 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

check titleWithIcon component

Done, merged with the Icon component!


pkg/ui/src/views/databases/databasePage/redux.spec.ts, line 196 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

create a test for checking two tables with different values

Done.

@matthewtodd matthewtodd requested a review from a team August 5, 2021 21:05
Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 64 files at r1, 12 of 19 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @maryliag and @matthewtodd)


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 83 at r2 (raw file):

// those properties for the table directly.
export interface DatabasesPageDataMissingTable {
  loading: boolean;

why there is no need for loaded field here?


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 134 at r2 (raw file):

    }

    _.forEach(this.props.databases, database => {

Do we have a preference on when to use lodash vs the builtin functions of js array ?


pkg/ui/src/redux/analytics.ts, line 58 at r2 (raw file):

  },
  {
    match: new RegExp("/database/.+"),

Do matchers here run in sequential orders as they are defined? It seems like /database/.+ would also match /database/.+/grants


pkg/ui/src/views/databases/databaseTablePage/redux.spec.ts, line 107 at r2 (raw file):

    driver = new TestDriver(
      createAdminUIStore(createMemoryHistory()),
      "things",

super nit: got thrown off a bit reading through this, perhaps s/thing/fakeDbName/ and s/foo/fakeTableName/


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 34 at r2 (raw file):

} = cockroach.server.serverpb;

function normalizeRoles(raw: string[]): string[] {

nit: perhaps normalizeRolesOrdering ?


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 82 at r2 (raw file):

  ): DatabaseDetailsPageData => {
    return {
      loading: !!databaseDetails[database]?.inFlight,

what is this !! operator?


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 86 at r2 (raw file):

      name: database,
      tables: _.map(databaseDetails[database]?.data?.table_names, (table) => {
        const details = tableDetails[generateTableID(database, table)];

nit: save the tableID to avoid repeatedly calling generateTableID ?

Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 83 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

why there is no need for loaded field here?

Good call, this one breaks the pattern. I'll add a comment.


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 134 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

Do we have a preference on when to use lodash vs the builtin functions of js array ?

Oh, I didn't realize most of what I wanted to do was already on Array -- it's been a while for me! I think it makes sense to lean less on an external dependency where we can, so I'll be happy to remove lodash where possible.


pkg/ui/src/redux/analytics.ts, line 58 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

Do matchers here run in sequential orders as they are defined? It seems like /database/.+ would also match /database/.+/grants

Yes, the redaction function runs through these until it finds the first match; that's why the more specific matches come first in the list.


pkg/ui/src/views/databases/databaseTablePage/redux.spec.ts, line 107 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

super nit: got thrown off a bit reading through this, perhaps s/thing/fakeDbName/ and s/foo/fakeTableName/

Done.


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 34 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

nit: perhaps normalizeRolesOrdering ?

This function (and normalizePrivileges, below) does a little more than just ordering, so I kind of like normalize as it stands. Did it seem unclear?


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 82 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

what is this !! operator?

Ooh! It's a double-not -- you can pronounce it "bang bang!" -- good for turning "truthy" and "falsy" (false, null, undefined) into true and false. I'm using it here because databaseDetails[database] might be undefined, so inFlight might also be, and having a reliable boolean in the props made me and typescript a little happier. :-) Is there a more modern way to do this I don't know about?

Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng, @maryliag, and @matthewtodd)


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 134 at r2 (raw file):

Previously, matthewtodd (Matthew Todd) wrote…

Oh, I didn't realize most of what I wanted to do was already on Array -- it's been a while for me! I think it makes sense to lean less on an external dependency where we can, so I'll be happy to remove lodash where possible.

👍


pkg/ui/src/redux/analytics.ts, line 58 at r2 (raw file):

Previously, matthewtodd (Matthew Todd) wrote…

Yes, the redaction function runs through these until it finds the first match; that's why the more specific matches come first in the list.

👍


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 34 at r2 (raw file):

Previously, matthewtodd (Matthew Todd) wrote…

This function (and normalizePrivileges, below) does a little more than just ordering, so I kind of like normalize as it stands. Did it seem unclear?

👍


pkg/ui/src/views/databases/databaseDetailsPage/redux.ts, line 82 at r2 (raw file):

Previously, matthewtodd (Matthew Todd) wrote…

Ooh! It's a double-not -- you can pronounce it "bang bang!" -- good for turning "truthy" and "falsy" (false, null, undefined) into true and false. I'm using it here because databaseDetails[database] might be undefined, so inFlight might also be, and having a reliable boolean in the props made me and typescript a little happier. :-) Is there a more modern way to do this I don't know about?

Ah I see. I guess this is the price we pay for dynamic typing lol.

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 19 files at r2, 5 of 10 files at r3.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng, @maryliag, and @matthewtodd)


pkg/ui/cluster-ui/src/databaseTablePage/databaseTablePage.tsx, line 215 at r3 (raw file):

                    <SummaryCardItem
                      label="Indexes"
                      value={_.join(this.props.details.indexNames, ", ")}

nit: similar message as the others, you can join without the use of lodash


pkg/ui/cluster-ui/src/icon/icon.module.scss, line 9 at r3 (raw file):

// 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.

did you made a check on all places using icon to make sure none of them misaligned?


pkg/ui/src/views/databases/databasesPage/redux.ts, line 36 at r3 (raw file):

      loading: databases.inFlight,
      loaded: databases.valid,
      databases: _.map(databases.data?.databases, (database) => {

nit: use map directly on the array (other example on this same file, same for .each)


pkg/ui/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx, line 156 at r3 (raw file):

    }

    _.forEach(this.props.tables, table => {

nit: no need for lodash here either, all the forEach can be directly on the array


pkg/ui/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx, line 300 at r3 (raw file):

      {
        title: "Roles",
        cell: table => _.join(table.details.roles, ", "),

nit for all joins: table.details.roles.join(", ")

Previously, the databases pages featured an older, outdated design. This
change aligns their UX with that of the other modern pages in the DB
console, statements, transactions, and sessions.

This is a first pass at the job. We will return to layer on more
features, including search, and more data, including node & region
information.

Addresses #65737.

Release note (ui change): The databases pages in the DB console were
updated to bring them into alignment with our modern UX.
Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng, @maryliag, and @matthewtodd)


pkg/ui/cluster-ui/src/databasesPage/databasesPage.tsx, line 134 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

👍

#68820


pkg/ui/cluster-ui/src/icon/icon.module.scss, line 9 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

did you made a check on all places using icon to make sure none of them misaligned?

This was a new file that only the new components used, and I checked them all. I've since unrolled it because its strategy of using data-uris for svgs prevented us from using css to size and color the icons.


pkg/ui/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx, line 156 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: no need for lodash here either, all the forEach can be directly on the array

Agreed, pushed to #68820 since there are some semantic differences between _.forEach and Array.forEach when undefined is involved.

Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng, @maryliag, and @matthewtodd)


pkg/ui/cluster-ui/src/databaseTablePage/databaseTablePage.tsx, line 215 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: similar message as the others, you can join without the use of lodash

Bumped to #68820


pkg/ui/src/views/databases/databasesPage/redux.ts, line 36 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit: use map directly on the array (other example on this same file, same for .each)

Bumped to #68820

Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/ui/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx, line 300 at r3 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

nit for all joins: table.details.roles.join(", ")

Bumped to #68820

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this, new page looks awesome!
As long as all comments are addressed (and necessary new issues created):
:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)

Copy link
Contributor Author

@matthewtodd matthewtodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewtodd
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 12, 2021

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants