Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

EVG-19954: Force save when changing providers #2028

Merged
merged 9 commits into from
Sep 18, 2023

Conversation

sophstad
Copy link
Contributor

@sophstad sophstad commented Sep 8, 2023

EVG-19954

Description

  • Show a modal prompting the user to save if they have modified the provider and attempt to navigate to a different distro settings tab

Screenshots

image

Testing

  • Add integration tests

@cypress
Copy link

cypress bot commented Sep 8, 2023

Passing run #12716 ↗︎

0 580 7 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

codegen
Project: Spruce Commit: 57686df0dd
Status: Passed Duration: 17:48 💡
Started: Sep 15, 2023 3:55 PM Ended: Sep 15, 2023 4:13 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@sophstad sophstad requested a review from a team September 8, 2023 18:24
@sophstad sophstad marked this pull request as ready for review September 8, 2023 20:42
@@ -12,4 +12,48 @@ describe("using the distro dropdown", () => {
cy.location("pathname").should("not.contain", "localhost");
cy.location("pathname").should("contain", "rhel71-power8-large");
});

it("warns when navigating away from distro settings with unsaved changes and allows returning to distro settings", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It may be more organized to put these tests under a describe statement labeled "Warning modal"

Comment on lines 28 to 29
Because you have modified the distro provider, your changes must be
saved before navigating to a new page.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Because you have modified the distro provider, your changes must be
saved before navigating to a new page.
Your distro provider changes must be saved or reverted before navigating to a new page.

});

const handleSave = () => {
// Only perform the save operation is the tab is valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Only perform the save operation is the tab is valid.
// Only perform the save operation if the tab is valid.

const handleSave = () => {
// Only perform the save operation is the tab is valid.
// eslint-disable-next-line no-prototype-builtins
if (formToGqlMap.hasOwnProperty(tab)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of implies that the modal may appear when it's not supposed to. Do you know how to get it in that state -- I wasn't able to.

Copy link
Contributor Author

@sophstad sophstad Sep 15, 2023

Choose a reason for hiding this comment

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

Interestingly, omitting this check introduces a CodeQL error. You can see that here: #2014 (review)

Edit: looks like using Object.prototype introduces the same problem!

Comment on lines +73 to +74
// eslint-disable-next-line no-prototype-builtins
if (formToGqlMap.hasOwnProperty(tab)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-prototype-builtins
if (formToGqlMap.hasOwnProperty(tab)) {
if (Object.prototype.hasOwnProperty.call(formToGqlMap, tab) {

@sophstad sophstad requested a review from SupaJoon September 15, 2023 15:51
@sophstad sophstad added this pull request to the merge queue Sep 18, 2023
Merged via the queue into evergreen-ci:main with commit 34da89a Sep 18, 2023
2 checks passed
@sophstad sophstad deleted the EVG-19954 branch September 18, 2023 14:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants