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

fix(home): missing key and invalid dates in Recents cards #13291

Merged
merged 2 commits into from
Feb 23, 2021

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Feb 23, 2021

SUMMARY

Alternative solution to #13225

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

image

After

Snip20210222_34

TEST PLAN

Manual verification on the home page

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-io
Copy link

codecov-io commented Feb 23, 2021

Codecov Report

Merging #13291 (29a538c) into master (974f447) will increase coverage by 2.79%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13291      +/-   ##
==========================================
+ Coverage   77.14%   79.93%   +2.79%     
==========================================
  Files         865      298     -567     
  Lines       44961    24285   -20676     
  Branches     5415        0    -5415     
==========================================
- Hits        34686    19413   -15273     
+ Misses      10152     4872    -5280     
+ Partials      123        0     -123     
Flag Coverage Δ
cypress ?
javascript ?
python 79.93% <100.00%> (-0.88%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/views/core.py 71.82% <100.00%> (-3.56%) ⬇️
superset/sql_validators/postgres.py 50.00% <0.00%> (-50.00%) ⬇️
superset/views/database/views.py 62.69% <0.00%> (-24.88%) ⬇️
superset/databases/commands/create.py 83.67% <0.00%> (-8.17%) ⬇️
superset/databases/commands/update.py 85.71% <0.00%> (-8.17%) ⬇️
superset/sql_validators/base.py 93.33% <0.00%> (-6.67%) ⬇️
superset/db_engine_specs/sqlite.py 90.62% <0.00%> (-6.25%) ⬇️
superset/db_engine_specs/base.py 79.95% <0.00%> (-6.12%) ⬇️
superset/views/database/forms.py 83.33% <0.00%> (-5.56%) ⬇️
superset/db_engine_specs/presto.py 82.47% <0.00%> (-5.56%) ⬇️
... and 577 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 974f447...29a538c. Read the comment docs.

@ktmud ktmud changed the title fix(home): missing key and inval dates in Recents cards fix(home): missing key and invalid dates in Recents cards Feb 23, 2021
@junlincc
Copy link
Member

junlincc commented Feb 23, 2021

@yardz Hey Bruno, Jesse opened a PR as alternative of #13225, please review. 🙏

cc @pkdotson

@junlincc junlincc added the home:recent Related to the "recent" section of the Homepage label Feb 23, 2021
const TRANS_LAST_VIEWED = `Last viewed %s`;
const TRANS_LAST_MODIFIED = `Last modified %s`;

const getEntityTitle = (e: ActivityObject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@ktmud Just one question. Are you sure these are the returns?
As I don't know much about the application, I'm very cautious about typing
If you're sure, I agree

Copy link
Member Author

Choose a reason for hiding this comment

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

It's replicating the same logic as the deleted code. Just with some typing help.

return e.item_title || UNTITLED;
};

const getEntityIconName = (e: ActivityObject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here (and for the other functions)

onClick={() => {
window.location.href = url;
}}
key={url}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok

/**
* Recent activity objects fetched by `getRecentAcitivtyObjs`.
*/
type ActivityObject =
Copy link
Contributor

Choose a reason for hiding this comment

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

@ktmud Are you sure it's just these types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, as ActivityTable renders ActivityData and ActivityData comes from getRecentAcitivtyObjs, which then calls these API endpoints.

const getEntityTitle = (e: ActivityObject) => {
if ('dashboard_title' in e) return e.dashboard_title || UNTITLED;
if ('slice_name' in e) return e.slice_name || UNTITLED;
if ('label' in e) return e.label || UNTITLED;
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes the case when saved queries don't have a title (label).

Before

Snip20210222_37

After

Snip20210222_39

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, mostly style related or questions to verify

};

export default Chart;
Copy link
Member

Choose a reason for hiding this comment

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

Yikes, i don't even want to know why we have a Slice and a Chart type...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think one has stricter typing following the backend API response; another is for temporary chart state on the client side (we should probably consolidate these two).

Comment on lines 102 to 104
// translation keys for last action on
const TRANS_LAST_VIEWED = `Last viewed %s`;
const TRANS_LAST_MODIFIED = `Last modified %s`;
Copy link
Member

Choose a reason for hiding this comment

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

does this actually work? I would've guessed you'd need to put the actual strings in the t() functions

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I did put it into t() later. Just making the translation keys constants because they are used in multiple statements. I can move them closer to the actual t() calls to reduce confusion.

Copy link
Member

Choose a reason for hiding this comment

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

i was more wondering if the job that pulls all the strings to be translated is smart enough to know that these strings end up in a t() function

onClick={() => {
window.location.href = url;
}}
key={url}
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 guaranteed to be unique? The same item can't show up twice in the recent activity section?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's guaranteed. The recent_activity API removes duplicates and results for other tabs are just regular filtered lists which has guaranteed unique items.

const TRANS_LAST_VIEWED = `Last viewed %s`;
const TRANS_LAST_MODIFIED = `Last modified %s`;

const getEntityTitle = (e: ActivityObject) => {
Copy link
Member

Choose a reason for hiding this comment

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

I know this is just a refactor, but e is a pretty bad variable name (i read it as error or event first, not entity). Can we rename throughout to entity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

@ktmud ktmud merged commit af3a460 into apache:master Feb 23, 2021
@ktmud ktmud deleted the fix-welcomepage-key branch February 23, 2021 04:30
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.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 home:recent Related to the "recent" section of the Homepage size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants