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

db-console: statement details component #162

Merged

Conversation

koorosh
Copy link
Collaborator

@koorosh koorosh commented Dec 17, 2020

db-console // StatementDetails component

Related to cockroachdb/cockroach#57372

This change extracts Statements details page and its dependent
components and styles.

  • most of the components moved without any changes, only import
    paths were adjusted
  • styles converted from Styl to SCSS
  • modified route paths to ensure they start with "/" root path
    (it ensures that routes behave the same way regardless to current
    path).
  • util directory now contain network and nodes subdirectories
    with logic specific to particular entities. It allows avoid extra logic
    in redux layer and keep it independently.

This change is Reviewable

@koorosh koorosh force-pushed the db-console--statement-details-extraction branch 3 times, most recently from 2a1c59d to a931e38 Compare December 21, 2020 12:20
@koorosh koorosh changed the title db-console: WIP. statement details pure component db-console: statement details component Dec 21, 2020
@koorosh koorosh marked this pull request as ready for review December 21, 2020 14:14
@koorosh koorosh requested review from dhartunian and vladlos and removed request for j-low and laurenbarker December 21, 2020 14:14
Copy link
Contributor

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

Just a few minor questions from me.

I don't like having a util directory that accumulates lots of stuff. Could we put the nodes and network code just in src?

@@ -99,7 +99,7 @@ export const Loading: React.FC<LoadingProps> = props => {

return (
<div className={cx("alerts-container", props.errorClassName)}>
{errorAlerts}
{React.Children.toArray(errorAlerts)}
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It fixes React error about missing key attribute for array of elements.
React.Children.toArray accepts an array of react elements and allows to set automatically key attribute if it's missed.

@@ -21,7 +21,7 @@ module.exports = {
'node_modules',
path.join(__dirname, 'src/fonts'),
],
extensions: [".ts", ".tsx", ".js", ".jsx", ".less"],
extensions: [".ts", ".tsx", ".js", ".jsx", ".less", ".scss"],
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we need to add this now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hm, this change looks useless, will revert it.

@koorosh
Copy link
Collaborator Author

koorosh commented Dec 24, 2020

I don't like having a util directory that accumulates lots of stuff. Could we put the nodes and network code just in src?

Agree

@koorosh koorosh force-pushed the db-console--statement-details-extraction branch from a931e38 to ff3fcb8 Compare December 24, 2020 13:01
@@ -1 +1,5 @@
export * from "./barCharts";
export * from "./rowsBrealdown";
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

@koorosh koorosh force-pushed the db-console--statement-details-extraction branch from ff3fcb8 to a7a4488 Compare January 11, 2021 09:08
@koorosh koorosh requested a review from nkodali as a code owner January 11, 2021 09:08
@koorosh koorosh requested a review from dhartunian January 11, 2021 09:09
@koorosh koorosh force-pushed the db-console--statement-details-extraction branch from a7a4488 to 6d8efa2 Compare January 11, 2021 12:23
Copy link
Contributor

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

LGTM, just one small question.

@@ -98,6 +98,7 @@ module.exports = {
test: /\.js$/,
loader: "source-map-loader",
},
{ test: /\.css$/, use: [ "style-loader", "css-loader" ] },
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are we loading raw CSS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Components which depend on Antd styles, have to load its CSS styles explicitly and we have Table component which depends on it:
https://github.com/cockroachdb/ui/pull/162/files#diff-70a6adf902647bd71cee4e2b65f55a1a999736c39698aef2ba64f1a70aedbadaR6

This change extracts Statements details page and its dependent
components and styles.
- most of the components moved without any changes, only import
paths were adjusted
- styles converted from Styl to SCSS
- modified route paths to ensure they start with "/" root path
(it ensures that routes behave the same way regardless to current
path).
- `util` directory now contain `network` and `nodes` subdirectories
with logic specific to particular entities. It allows avoid extra logic
in redux layer and keep it independently.
@koorosh koorosh force-pushed the db-console--statement-details-extraction branch from 6d8efa2 to ee7c427 Compare January 12, 2021 13:33
@koorosh koorosh requested a review from vladlos January 12, 2021 14:39
@koorosh koorosh merged commit 423de1a into cockroachdb:master Jan 13, 2021
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jan 19, 2021
58701: ui: statement details import r=koorosh a=koorosh

Related to #57372
Depends on cockroachdb/ui#162
Depends on cockroachdb/yarn-vendored#51

Statement details and Diagnostics view pages are moved out
to `admin-ui-components` package and now they are imported back
as a reusable components.

In addition to changed imports, StatementDetails component now exposes
additional props for Diagnostics view tab. Before, StatementDetails
component used Diagnostics view connected to store and now it uses
pure component. This change were made to provide single point of
integration to redux store (the same way as other components connected).

Tracking analytics functionality for Diagnostics view was initially called directly
from components and now it's refactored out of component and involved
with redux actions and sagas. It was necessary to exclude this logic from pure
components and allow client apps which integrate Statement details to implement
their own logic for tracking analytics if necessary.

TODO:
- [x]  remove all exported components from this code base to avoid duplicates.
- [x]  update `admin-ui-components` package version in `package.json`

Release note: None

Co-authored-by: Andrii Vorobiov <[email protected]>
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.

3 participants