-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[ui] Separate Diffs and Versions from the /versions endpoint as far as Ember is concerned #24145
[ui] Separate Diffs and Versions from the /versions endpoint as far as Ember is concerned #24145
Conversation
@computed('versions.[]') | ||
diffs = []; | ||
|
||
@computed('versions.[]', 'diffs.[]') |
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.
the @computed
prefix to this getter indicates something that should trigger an update.
@@ -38,7 +40,8 @@ export default class JobVersionsStream extends Component { | |||
} | |||
} | |||
|
|||
return { version, meta }; | |||
const diff = this.diffs.objectAt(index); | |||
return { version, meta, diff }; |
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 is the component layer where we opt to join the Version and its Diff, which are otherwise same-indexed objects in separate arrays.
refreshModel: true, | ||
}, | ||
}; | ||
|
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.
Now that the route doesn't care about Diff data (the controller does), we don't need to make it concerned with queryParams / it doesn't need to re-fetch the versions when the user switches the comparison version via dropdown
related: buildURL(`${jobURL}/versions`, { namespace, diffs: true }), | ||
related: buildURL(`${jobURL}/versions`, { | ||
namespace, | ||
}), |
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.
We no longer need to get .Diffs[]
on initial model load
bb02926
to
e003878
Compare
e003878
to
4a25e53
Compare
Ember Test Audit comparison
|
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, with one non-blocking question just for my education. 😁
3f79962
to
f74bef3
Compare
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.
Works great!
This separates
Diff
objects fromVersion
objects at the route/model layer, preferring to join them at component/view layer.For context: a diff living at
versions[].diff
has made sense prior to #24055, since a version diff was only ever against its previous version.Now that we can modify the "version to diff against" on the versions page, that model comes with side-effects (like the bug the Jira ticket uncovers, where a newly-pushed version would unblock the /versions query, but no update the diffs' position until refresh)
Now when you load the /versions page, 3 things happen:
/versions
takes place to get job versions and its data is returned on page/versions?index=num
is opened, and resolved any time there is new version information / a new version/versions?diffs=true<&diffVersion=num
takes place and only the.Diffs
information is processedThis is a little inefficient from a fetch perspective, but preserves a lot of conventions in our frontend (like "Watch the versions relationship on this job") and seems like the idiomatic way to do it.
Resolves #24144 (Jira)