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(uaa-integration): Parse Versions Response from UAA #3385
Conversation
@@ -83,9 +84,7 @@ const CollapsedVersion = (props: Props): React.Node => { | |||
aria-label={intl.formatMessage(messages.getVersionInfo)} | |||
className="bcs-Version-info" | |||
data-resin-target={ACTIVITY_TARGETS.VERSION_CARD} | |||
onClick={() => { | |||
onInfo({ versions }); |
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.
What's passed into this cb is only used when hasVersions
prop is false
and onVersionHistoryClick
prop is passed into BUIE. There doesn't seem to be a standardized format, since the CollapsedVersion and Version components pass back different data. Because UAA doesn't have the versions
array like the v2 api, I decided to use the end version of the event and match what was passed in the Version.js
component (id
and version_number
). This cb is not used in EUA.
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.
question: does the version_end
always the represent current version even if a previous version was promoted?
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.
yup
@@ -26,6 +26,7 @@ type Props = { | |||
id: string, | |||
modified_by: User, | |||
onInfo?: Function, | |||
shouldUseUAA?: boolean, |
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'm not seeing where this is being used here. Can it be removed?
onClick={() => { | ||
onInfo({ id, version_number }); | ||
}} | ||
onClick={() => onInfo({ id, version_number })} |
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.
This change may un-intentionally be returning a value in the onClick when it wasn't before. I think it might be better to leave it in brackets or type the onInfo
prop to show it returns void or undefined (same in CollapsedVersion
).
onClick={() => { | ||
onInfo({ versions }); | ||
}} | ||
onClick={() => onInfo(shouldUseUAA ? { id, version_number: version_end } : { versions })} |
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.
Might be returning a value now implicitly from the arrow function
} | ||
} | ||
|
||
return versionsItem; |
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 wondering if there would be a way to extract and organize some of this into separate functions to help reduce the length of the getParsedFileActivitiesResponse
function? I'm also fine with leaving as-is if you don't think that would make sense here.
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.
Yeah, thought about it, there isn't really benefits to splitting though since the logic isn't reusable, and the switch statements make it more readable as well.
@@ -148,6 +148,15 @@ describe('elements/content-sidebar/ActivityFeed/activity-feed/ActivityFeed', () | |||
expect(wrapper.find('EmptyState').exists()).toBe(true); | |||
}); | |||
|
|||
test('should not render empty state when UAA is enabled and there is 1 version (current version from file) and the start and end version are the same', () => { |
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.
Was this meant to be "should render empty.." instead of "should not render"?
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.
Good catch
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.
Looks good to me!
@@ -83,9 +84,7 @@ const CollapsedVersion = (props: Props): React.Node => { | |||
aria-label={intl.formatMessage(messages.getVersionInfo)} | |||
className="bcs-Version-info" | |||
data-resin-target={ACTIVITY_TARGETS.VERSION_CARD} | |||
onClick={() => { | |||
onInfo({ versions }); |
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.
question: does the version_end
always the represent current version even if a previous version was promoted?
src/elements/content-sidebar/activity-feed/activity-feed/__tests__/ActivityFeed.test.js
Outdated
Show resolved
Hide resolved
src/elements/content-sidebar/activity-feed/activity-feed/__tests__/ActivityFeed.test.js
Outdated
Show resolved
Hide resolved
src/elements/content-sidebar/activity-feed/activity-feed/ActivityFeed.js
Show resolved
Hide resolved
versionsItem.uploader_display_name = versionsItem.action_by[0].name; | ||
} | ||
|
||
versionsItem.action_by.map(collaborator => { |
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 a little odd to use map
without intending to use the returned array. I think this might be a good use case for reduce
:
versionsItem.collaborators = versionsItem.action_by.reduce( ... , {});
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.
Leaning for keeping it for now since we've used map
in a few other place. Going through another round of manual testing for the logic change also is a big time sink.
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.
semantically it feels a little wrong to use a map
in this case over something like a forEach
since the goal is to populate a separate object instead of using the returned array
with the reduce it could be:
versionsItem.collaborators = versionsItem.action_by.reduce((collaborators, collaborator) =>
({ ...collaborators, [collaborator.id]: { ...collaborator } }), {});
although you could leave it as-is if the current implementation is easier to read
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.
lgtm!
versionsItem.uploader_display_name = versionsItem.action_by[0].name; | ||
} | ||
|
||
versionsItem.action_by.map(collaborator => { |
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.
semantically it feels a little wrong to use a map
in this case over something like a forEach
since the goal is to populate a separate object instead of using the returned array
with the reduce it could be:
versionsItem.collaborators = versionsItem.action_by.reduce((collaborators, collaborator) =>
({ ...collaborators, [collaborator.id]: { ...collaborator } }), {});
although you could leave it as-is if the current implementation is easier to read
@@ -471,6 +471,11 @@ export const ACTIVITY_FILTER_OPTION_RESOLVED: 'resolved' = 'resolved'; | |||
export const ACTIVITY_FILTER_OPTION_TASKS: 'tasks' = 'tasks'; | |||
export const ACTIVITY_FILTER_OPTION_UNRESOLVED: 'open' = 'open'; | |||
|
|||
/* ------------------ File Activity Action Types ----------- */ | |||
export const ACTION_TYPE_CREATED: 'created' = 'created'; |
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'm not sure if there's a concept of "action type" for other features but if there was we could change to FILE_ACTIVITY_ACTION_TYPE_[...]
to be more specific
The UAA response gives a Versions activity event that is different than the v2 Versions API that we are currently using. We must parse the response and add the needed fields that our UI components need to render Version events.
One big difference with this change is that the latest version events do not have
promotion
context, unlike the v2 API. So if the user has promoted a version and that version is the most recent version, they can only see that version was promoted by clicking the info button and looking at the version history. The team has had discussions around this and is okay with this tradeoff, we will look into adding the promotion context into the UAA response in the future.UAA:
Multiple version events
Multiple upload collaborators
Version events with comments between
new file upload, no events
V2 Versions:
Multiple version events
Multiple upload collaborators
Version events with comments between
new file upload, no events