Skip to content

Settings > Application Settings > Replication tab enhancements#9388

Open
elsamaryv wants to merge 1 commit intoManageIQ:masterfrom
elsamaryv:settings-replication-form-enhancements
Open

Settings > Application Settings > Replication tab enhancements#9388
elsamaryv wants to merge 1 commit intoManageIQ:masterfrom
elsamaryv:settings-replication-form-enhancements

Conversation

@elsamaryv
Copy link
Contributor

@elsamaryv elsamaryv commented Apr 1, 2025

Converts Settings > Replication tab to React. Also includes jest and cypress tests.

Before

replication tab (old) 1 replication tab (old) 2

Add subscription
Add subscription - before

Validation failure
Validation failure - old

After

replication tab (new) 1

Add subscription modal
add-sub-modal

Subscription table
sub_table_with_btns

Validation failure
Validation failure

Edit subscription
Edit sub modal

@elsamaryv elsamaryv changed the title [WIP] Settings > Application Settings > Replication tab enhancements Settings > Application Settings > Replication tab enhancements Apr 7, 2025
@elsamaryv elsamaryv marked this pull request as ready for review April 7, 2025 13:17
@elsamaryv elsamaryv requested a review from a team as a code owner April 7, 2025 13:17
@miq-bot miq-bot removed the wip label Apr 9, 2025
@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from 56e0cc4 to f026475 Compare April 22, 2025 10:29
@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch 2 times, most recently from 10d350f to 84156ea Compare July 28, 2025 10:31
@GilbertCherrie
Copy link
Member

Also, the cypress tests are consistently failing, we need to get them passing some what consistently or we can't merge this

@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from e8709bb to 7356151 Compare September 3, 2025 10:53
@Fryguy
Copy link
Member

Fryguy commented Oct 29, 2025

@elsamaryv Is this ready to go? @GilbertCherrie can you review?

@elsamaryv
Copy link
Contributor Author

@elsamaryv Is this ready to go? @GilbertCherrie can you review?

Not yet, the PR needs to be reviewed again.

@GilbertCherrie GilbertCherrie mentioned this pull request Feb 19, 2026
9 tasks
@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from 7356151 to a119af0 Compare March 4, 2026 11:59
@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from a119af0 to d6f2982 Compare March 4, 2026 12:09
Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

Overall, this looks great - awesome work. I think there's a little cleanup here, but overall I'm good. @asirvadAbrahamVarghese can you please also review, particularly the cypress tests as I didn't dig deep into those.

<div className="subscriptions-button" style={{ display: 'flex', flexDirection: 'row-reverse' }}>
<Button
kind="primary"
className="subscription-add bx--btn bx--btn--primary pull-right"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also remove the Carbon v10 classes (bx--) and the pull-right class as well? - that shouldn’t have any impact and isn't necessary since we’re already aligning that using flex (also, that’s a mix of Bootstrap and Carbon)

onCancel={onCancel}
canReset
buttonsLabels={{
submitLabel: __('Save'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be wrong here, but shouldn’t the Save button be disabled when the type select has no value (i.e., set to None)?
Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially, the dropdown shows 'None', and the Save button is disabled because no replication role has been selected yet. However, if the user changes the replication type and later decides to set it back to 'None', that action should still be allowed.

<MiqFormRenderer
schema={createSubscriptionSchema()}
componentMapper={componentMapper}
initialValues={selectedSubscription || {}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be a bug, or I might have misunderstood the functionality

I believe this was also done previously by someone else, adding a new subscription preserves the previous state (the last entered data)

Adding a Subscription:
Image

Image

Then trying to add another one:
Image

Previous record values are populated automatically:
Image

onCancel={handleModalClose}
canReset
buttonsLabels={{
submitLabel: __('Accept'),
Copy link
Contributor

Choose a reason for hiding this comment

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

The modal’s submit button should have its text as “Accept” or “Add.” I’ve seen “Add” more often, but I’m not entirely sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before -
Accept btn old

After -
Accept btn

"Accept" button doesn't doesn't trigger any API calls. In the angular code, it only stores the subscription data to the local array. Would it make sense to rename it to "Save" in the subscription modal?

@Fryguy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previous workflow -

Replication.workflow.with.angular.code.mov

Copy link
Member

Choose a reason for hiding this comment

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

I don't really have a preference. If we're moving to a modal, it makes sense to match the pattern of other modal's, which sounds like Add is the better choice. I don't like Save in the modal because it doesn't actually save anywhere until the entire form is saved, so Add is better.

@@ -0,0 +1,281 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about Jest, do we actually need it? I thought the idea was to eventually remove Jest completely and move fully to Cypress(including component testing).

cc: @GilbertCherrie @Fryguy

Copy link
Member

Choose a reason for hiding this comment

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

Jest is convenient for running unit tests, whereas Cypress is more for integration tests - the former is fast and easier to run locally, particularly for small functions - the latter is better for testing across boundaries, particularly without the mocking hitting the real API and Rails backend

They both have their place and I'm ok with both kinds of tests where appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah we should still have both Jest and Cypress tests as part of our react conversion

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, makes sense. In that case we’ll probably hit Enzyme as a blocker soon, especially with the React upgrade since it likely won’t support React 18+. We’ll need to move to RTL

cy.get(`input[name="${PASSWORD_INPUT_NAME}"]`).type(TEST_PASSWORD);
cy.get(`input[name="${PORT_INPUT_NAME}"]`).type(TEST_PORT);

cy.contains(`${MODAL_SELECTOR} button`, ACCEPT_BUTTON_TEXT).should('not.be.disabled').click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we usecy.getFormButtonByTypeWithText here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, that might end up selecting buttons from the main form, right?


it('Validate reset functionality', () => {
cy.get(`select[name="${REPLICATION_TYPE_SELECT_NAME}"]`).select(REPLICATION_TYPE_REMOTE);
cy.contains('button', RESET_BUTTON_TEXT).click();
Copy link
Contributor

Choose a reason for hiding this comment

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

May be we can use cy.getFormButtonByTypeWithText here

});

it('Validate update subscription', () => {
addSubscription();
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a thought, if you feel adding data through the UI isn’t necessary everywhere, using factories can be a big help.

.should('be.visible')
.click();

cy.get(SUBSCRIPTIONS_TABLE_SELECTOR)
Copy link
Contributor

Choose a reason for hiding this comment

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

We also have a command for table data assertions: cy.gtlGetRows. It can return data from the table based on the column index which can make this easier.

@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from 2c8b671 to 14bc598 Compare March 9, 2026 04:49
componentMapper={componentMapper}
onSubmit={onSave}
onCancel={onCancel}
canReset
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm, should reset also wipe the table data?

Image Image

Now selecting the type as "Global" again repopulates the data, is that expected?
Image

Copy link
Member

@Fryguy Fryguy Mar 16, 2026

Choose a reason for hiding this comment

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

Reset should go to what it was before any changes were made. If the table had data already, then it should restore the original data. Code-wise a reset could just be implemented as a reload of the component.

Copy link
Contributor

@asirvadAbrahamVarghese asirvadAbrahamVarghese left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great now, lit work - just one small question here

  • @GilbertCherrie I believe you already reviewed this before Carbon11 migration, could you take another quick look?
  • @Fryguy could you also check the comment about the modal button name here?

@Fryguy
Copy link
Member

Fryguy commented Mar 16, 2026

Thanks - I replied above.

@GilbertCherrie
Copy link
Member

GilbertCherrie commented Mar 16, 2026

@elsamaryv looks good. The cypress test failures are sporatic and unrelated.

The only 2 minor issues I found in the PR:

  1. You don't need a cancel button on this form. I checked the old form and there is no cancel button there. This can be removed using the <MiqFormRenderer> prop cancancel={false}.
  2. Not sure what we want to do with the reset button here as pointed out above. @Fryguy the old form only resets new data (such as new rows added to the table) where as the new form resets the entire form back to None. Do we want to try and replicate the old form Reset?

@Fryguy
Copy link
Member

Fryguy commented Mar 16, 2026

Reset should reset back to whatever is saved in the database. If the table had data at the start it should reset back to that.

@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from 0daaaa7 to 045f67f Compare March 17, 2026 11:07
@elsamaryv elsamaryv force-pushed the settings-replication-form-enhancements branch from 045f67f to a2993cd Compare March 17, 2026 11:20
@miq-bot
Copy link
Member

miq-bot commented Mar 17, 2026

Checked commit elsamaryv@a2993cd with ruby 3.3.10, rubocop 1.56.3, haml-lint 0.72.0, and yamllint 1.37.1
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@elsamaryv
Copy link
Contributor Author

@elsamaryv looks good. The cypress test failures are sporatic and unrelated.

The only 2 minor issues I found in the PR:

  1. You don't need a cancel button on this form. I checked the old form and there is no cancel button there. This can be removed using the <MiqFormRenderer> prop cancancel={false}.
  2. Not sure what we want to do with the reset button here as pointed out above. @Fryguy the old form only resets new data (such as new rows added to the table) where as the new form resets the entire form back to None. Do we want to try and replicate the old form Reset?

The Cancel button has been removed, and the Reset button is now functioning as expected—it restores the values to what’s currently saved in the database. Please review, @GilbertCherrie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants