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

feat: owners profile icon on dataset list view #10041

Merged
merged 4 commits into from Jun 15, 2020

Conversation

lilykuang
Copy link
Member

@lilykuang lilykuang commented Jun 11, 2020

SUMMARY

This profile icon is part of the dataset redesign SIP-34.

  • Add a new react component react-avatar
  • Add owners column to dataset list view
  • Implement circle icon with owner's initials as owners' profile icon
  • owners column displays maximum of 5 icons
  • When :hover, tooltip should contain the owner's name

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

updated color scheme:
Screen Shot 2020-06-12 at 9 44 20 AM

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2020

Codecov Report

Merging #10041 into master will increase coverage by 1.61%.
The diff coverage is 61.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10041      +/-   ##
==========================================
+ Coverage   68.88%   70.49%   +1.61%     
==========================================
  Files         584      585       +1     
  Lines       31058    31074      +16     
  Branches     3180     3185       +5     
==========================================
+ Hits        21393    21905     +512     
+ Misses       9555     9060     -495     
+ Partials      110      109       -1     
Flag Coverage Δ
#cypress 53.90% <ø> (+0.07%) ⬆️
#javascript 59.49% <61.11%> (+<0.01%) ⬆️
#python 70.07% <ø> (+2.72%) ⬆️
Impacted Files Coverage Δ
superset-frontend/src/components/AvatarIcon.tsx 58.33% <58.33%> (ø)
...set-frontend/src/views/datasetList/DatasetList.tsx 56.14% <66.66%> (+0.58%) ⬆️
.../src/dashboard/components/gridComponents/Chart.jsx 88.76% <0.00%> (-1.13%) ⬇️
superset/views/dashboard/filters.py 95.23% <0.00%> (-0.22%) ⬇️
superset/utils/core.py 89.03% <0.00%> (-0.16%) ⬇️
superset/dashboards/filters.py 96.55% <0.00%> (-0.12%) ⬇️
superset/security/manager.py 89.04% <0.00%> (-0.08%) ⬇️
superset/views/database/forms.py 90.69% <0.00%> (ø)
superset/views/database/decorators.py 96.15% <0.00%> (ø)
...et-frontend/src/dashboard/components/Dashboard.jsx 84.33% <0.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54c6ddb...a5d5ce0. Read the comment docs.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

a few comments, looks like a cool new feature!

const { tableName, firstName, lastName, userName, iconSize } = this.props;
const uniqueKey = tableName.concat('_', userName);
const fullName = firstName.concat(' ', lastName);
const colors = [
Copy link
Member

Choose a reason for hiding this comment

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

can we pull this array out into a constant so that it doesn't get rebuilt on every render?

Copy link
Member

Choose a reason for hiding this comment

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

Curious where those colors came from. We should use the main palette (https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-color/src/colorSchemes/categorical/airbnb.ts) for now and eventually the pretty SIP-34 ones.
Screen Shot 2020-06-11 at 10 08 47 PM

name={fullName}
size={iconSize}
round
style={{ margin: '0px 5px' }}
Copy link
Member

Choose a reason for hiding this comment

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

can we use the className attribute and apply a class to this instead of inlining styles?

Copy link
Member

Choose a reason for hiding this comment

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

Since we may want consistent avatar styles, any additional CSS will likely need to be set globally. If margin is the only style we will set for the avatar (which probably can be changed to either a variable or proportional to iconSize), I think it's OK to use inline style.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, looking at this closer, it seems like this styling should be on a wrapper around the avatar, perhaps an AvatarGroup component? Since it seems like this styling is only needed when displaying multiple avatars next to each other

Copy link
Member

Choose a reason for hiding this comment

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

or wrap it with emotion styled


interface Props {
firstName: string;
iconSize: string;
Copy link
Member

Choose a reason for hiding this comment

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

can this be a number instead? Seems a bit odd as a string and react-avatar seems to accept either a number of a string

Copy link
Member Author

Choose a reason for hiding this comment

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

@etr2460 I have tried using a number but size of react-avatar could only accept string

userName: string;
}

export default class AvatarIcon extends PureComponent<Props> {
Copy link
Member

Choose a reason for hiding this comment

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

Since this component only has a render function, maybe we should make it a functional component instead?

export default class AvatarIcon extends PureComponent<Props> {
render() {
const { tableName, firstName, lastName, userName, iconSize } = this.props;
const uniqueKey = tableName.concat('_', userName);
Copy link
Member

Choose a reason for hiding this comment

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

since unique key is only used in one place, instead of defining as a constant it might be cleaner to set it directly on the key attribute

Copy link
Member Author

Choose a reason for hiding this comment

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

export default class AvatarIcon extends PureComponent<Props> {
render() {
const { tableName, firstName, lastName, userName, iconSize } = this.props;
const uniqueKey = tableName.concat('_', userName);
Copy link
Member

Choose a reason for hiding this comment

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

nit: prefer ${tableName}_${userName}

render() {
const { tableName, firstName, lastName, userName, iconSize } = this.props;
const uniqueKey = tableName.concat('_', userName);
const fullName = firstName.concat(' ', lastName);
Copy link
Member

Choose a reason for hiding this comment

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

nit: prefer ${firstName} ${lastName}

@@ -140,6 +140,7 @@
"re-resizable": "^4.3.1",
"react": "^16.13.0",
"react-ace": "^5.10.0",
"react-avatar": "^3.9.7",
Copy link
Member

Choose a reason for hiding this comment

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

Is this something that we might want to migrate away from in the future if the Antd discussions we were talking about in the meetup today come to fruition? I see that antd has an avatar component already: https://ant.design/components/avatar/

Copy link
Member

Choose a reason for hiding this comment

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

Possibly, but we can't block forward progress based on a pre-SIP discussion for something that may or may not pass a vote. Should AntD come to fruition, we can swap out components later.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying to block progress, moreso wondering if since we're adding a new library anyway if we should think ahead. Either way, whichever you think is best works

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jun 12, 2020
@lilykuang lilykuang requested review from etr2460 and nytai June 12, 2020 17:07
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

a couple other nits, but approving to unblock since i'm going to be away from my laptop for most of today

@@ -140,6 +140,7 @@
"re-resizable": "^4.3.1",
"react": "^16.13.0",
"react-ace": "^5.10.0",
"react-avatar": "^3.9.7",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying to block progress, moreso wondering if since we're adding a new library anyway if we should think ahead. Either way, whichever you think is best works

const fullName = `${firstName} ${lastName}`;

return (
<ConfigProvider colors={colorList && colorList.colors}>
Copy link
Member

Choose a reason for hiding this comment

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

what happens if this is undefined? Does react-avatar have a sane fallback?

Copy link
Member Author

Choose a reason for hiding this comment

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

react-avatar has fallback colors

overlay={<Tooltip id={`${uniqueKey}-tooltip`}>{fullName}</Tooltip>}
>
<StyledAvatar
key={`${uniqueKey}`}
Copy link
Member

Choose a reason for hiding this comment

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

this can be key={uniqueKey}

<StyledAvatar
key={`${uniqueKey}`}
name={fullName}
size={`${iconSize}`}
Copy link
Member

Choose a reason for hiding this comment

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

this can be size={iconSize}

@@ -54,13 +62,14 @@ interface State {
}

interface Dataset {
changed_by: string;
Copy link
Member

Choose a reason for hiding this comment

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

thanks for the abc!

@pull-request-size pull-request-size bot added size/M and removed size/L labels Jun 12, 2020
@nytai nytai merged commit 98ab95e into apache:master Jun 15, 2020
@nytai nytai deleted the lily/datasets/owner-profile-icon branch June 15, 2020 16:52
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants