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

[ui] Separate Diffs and Versions from the /versions endpoint as far as Ember is concerned #24145

Conversation

philrenaud
Copy link
Contributor

This separates Diff objects from Version 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:

  • a request to /versions takes place to get job versions and its data is returned on page
  • a blocking query against /versions?index=num is opened, and resolved any time there is new version information / a new version
  • a request to /versions?diffs=true<&diffVersion=num takes place and only the .Diffs information is processed

This 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)

@computed('versions.[]')
diffs = [];

@computed('versions.[]', 'diffs.[]')
Copy link
Contributor Author

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 };
Copy link
Contributor Author

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,
},
};

Copy link
Contributor Author

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,
}),
Copy link
Contributor Author

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

@philrenaud philrenaud force-pushed the 24144-ui-a-new-version-run-in-the-background-incorrectly-displays-diffs-on-the-versions-page branch from bb02926 to e003878 Compare October 7, 2024 20:51
@philrenaud philrenaud force-pushed the 24144-ui-a-new-version-run-in-the-background-incorrectly-displays-diffs-on-the-versions-page branch from e003878 to 4a25e53 Compare October 7, 2024 20:54
Copy link

github-actions bot commented Oct 7, 2024

Ember Test Audit comparison

main 5804fe9 change
passes 1581 1581 0
failures 0 0 0
flaky 0 0 0
duration 11m 49s 734ms 11m 48s 189ms -01s 545ms

Copy link
Member

@tgross tgross left a 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. 😁

.changelog/24145.txt Outdated Show resolved Hide resolved
ui/app/models/job.js Outdated Show resolved Hide resolved
@philrenaud philrenaud force-pushed the 24144-ui-a-new-version-run-in-the-background-incorrectly-displays-diffs-on-the-versions-page branch from 3f79962 to f74bef3 Compare October 8, 2024 13:24
Copy link
Member

@mismithhisler mismithhisler left a comment

Choose a reason for hiding this comment

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

Works great!

@philrenaud philrenaud merged commit dc45066 into main Oct 8, 2024
23 checks passed
@philrenaud philrenaud deleted the 24144-ui-a-new-version-run-in-the-background-incorrectly-displays-diffs-on-the-versions-page branch October 8, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ui] A new version run in the background incorrectly displays diffs on the versions page
3 participants