-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Conversation
0c951fc
to
b33fe7f
Compare
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
b33fe7f
to
d9fde12
Compare
const TRANS_LAST_VIEWED = `Last viewed %s`; | ||
const TRANS_LAST_MODIFIED = `Last modified %s`; | ||
|
||
const getEntityTitle = (e: ActivityObject) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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).
// translation keys for last action on | ||
const TRANS_LAST_VIEWED = `Last viewed %s`; | ||
const TRANS_LAST_MODIFIED = `Last modified %s`; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
SUMMARY
Last modified xxx
format consistent. Let Recent activity cards use backend humanized relative dates, too.Viewed
cards because that's what they are.Alternative solution to #13225
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
TEST PLAN
Manual verification on the home page
ADDITIONAL INFORMATION