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

🪟 Per-Stream state new flow #14634

Merged
merged 29 commits into from
Jul 19, 2022
Merged

🪟 Per-Stream state new flow #14634

merged 29 commits into from
Jul 19, 2022

Conversation

timroes
Copy link
Collaborator

@timroes timroes commented Jul 12, 2022

What

Fixes #14560

Partial reset possible:
screenshot-20220713-114036

Full reset required:
screenshot-20220713-114300

TODOs

  • Unit tests
  • Proper typings for ModalService input/output
  • Finish and cleanup modal service
  • Proper warning modal
  • Finalize wording
  • Remove secondaryButton from ConfirmationModal again
  • Switch to new update API once merged

@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Jul 12, 2022
@@ -114,59 +99,62 @@ export const ReplicationView: React.FC<ReplicationViewProps> = ({ onAfterSaveSch
if (activeUpdatingSchemaMode) {
setActiveUpdatingSchemaMode(false);
}

formikHelpers?.resetForm({ values });
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ The onSubmit function was never called with the formikHelpers parameters specified, so this should have never been called.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just have to make sure that after saving, the confirmation modal to discard chagnes does not appear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
};

const onEnterRefreshCatalogMode = async () => {
const onRefreshSourceSchema = async () => {
setSaved(false);
Copy link
Collaborator Author

@timroes timroes Jul 13, 2022

Choose a reason for hiding this comment

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

ℹ️ This (and the setSaved(false) call below) solves some issue that the "This connection was saved" reappears again after an error vanished, despite no new save has happened.

Comment on lines -158 to -169
const openResetDataModal = useCallback(() => {
openConfirmationModal({
title: "form.resetData",
text: "form.changedColumns",
submitButtonText: "form.reset",
cancelButtonText: "form.noNeed",
onSubmit: async () => {
await onReset?.();
closeConfirmationModal();
},
});
}, [closeConfirmationModal, onReset, openConfirmationModal]);
Copy link
Collaborator Author

@timroes timroes Jul 13, 2022

Choose a reason for hiding this comment

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

ℹ️ This was the old "should we reset or not" modal when the configuration inside the stream changed, but the stream wasn't manually refreshed.

Note: The warning shown here even was very much off, what actually happened. We showed "You have changed which column is used to detect new records for a stream. You may want to reset the data in your stream.", though we showed this also for other types of catalog changes (e.g. sync mode change).

Comment on lines 121 to 132
const openResetDataModal = (values: ValuesProps) => {
openConfirmationModal({
title: "connection.updateSchema",
text: "connection.updateSchemaText",
submitButtonText: "connection.updateSchema",
submitButtonDataId: "refresh",
onSubmit: async () => {
await onSubmit(values);
closeConfirmationModal();
},
});
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ This was the old "we'll need to reset your data", when a "Source schema refresh" has happened before.

const requireFullReset = stateType === ConnectionStateType.legacy;
return (
<div className={styles.resetWarningModal}>
{/* TODO: This should use proper text stylings once we have them available. */}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ This TODO is meant to stay inside, and hopefully we can build out the proper text styles soon, so use them here.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is an issue for that, it could be helpful to link it in this comment so that its easy to find all of the related TODOs in the code

@timroes timroes changed the title [WIP] new per stream flow 🪟 Per-Stream state new flow Jul 14, 2022
@timroes timroes marked this pull request as ready for review July 14, 2022 08:20
@timroes timroes requested a review from a team as a code owner July 14, 2022 08:20
@Amruta-Ranade Amruta-Ranade added area/documentation Improvements or additions to documentation team/documentation labels Jul 14, 2022
const service: ModalServiceContextType = useMemo(
() => ({
openModal: (options) => {
resultSubjectRef.current = new Subject();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ Why solving this with an observable here, despite only needing a one time resolved value. The problem is, that we can't control a Promise from the outside, so we'd need to instantiate a promise here and store a reference to it's resolve/reject method in a ref for later consumption. I had this first, and the whole component read way worse imho, thus I switched this over to use a simple subject and convert that later to a promise.

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Code looks good

@edmundito
Copy link
Contributor

edmundito commented Jul 15, 2022

Code is good, but I ran into a situation while testing:

  1. Add a new table to the source
  2. Open the replication settings
  3. Refresh the schema
  4. Hit save without changing the stream configuration (new table is unchecked)

I didn't change anything about the streams, but I still got the dialog to reset the schema. This also happens if I modify a disabled stream.

@edmundito
Copy link
Contributor

Another thing I noticed: After adding the new table and saving the schema, the stream disappears from the list. But when I reload the replication page, it appears again.

@edmundito
Copy link
Contributor

Another thing about the modal, for me it makes more sense that it shows the "Save and Reset" as a button rather than a checkbox. so the user has three CTAs:

  1. Cancel
  2. Save
  3. Save and Reset streams

@timroes
Copy link
Collaborator Author

timroes commented Jul 15, 2022

Another thing about the modal, for me it makes more sense that it shows the "Save and Reset" as a button rather than a checkbox. so the user has three CTAs:

  1. Cancel
  2. Save
  3. Save and Reset streams

The problem is we really want to discourage saving without resetting, thus this layout. Cc @andyjih happy to get your input on that question, checkbox vs three buttons?

@timroes
Copy link
Collaborator Author

timroes commented Jul 15, 2022

Code is good, but I ran into a situation while testing:

  1. Add a new table to the source
  2. Open the replication settings
  3. Refresh the schema
  4. Hit save without changing the stream configuration (new table is unchecked)

I didn't change anything about the streams, but I still got the dialog to reset the schema. This also happens if I modify a disabled stream.

That is so far actually intended behavior, since the catalog changed (despite the stream not being enabled that changed).

@andyjih @lmossman I wonder if we should actually only compare enabled streams in the original and the catalog we're about to send? And only if there's a difference in the enabled ones show that modal?

@lmossman
Copy link
Contributor

That is so far actually intended behavior, since the catalog changed (despite the stream not being enabled that changed).

@andyjih @lmossman I wonder if we should actually only compare enabled streams in the original and the catalog we're about to send? And only if there's a difference in the enabled ones show that modal?

@timroes I believe this is actually how it already works in the backend - we only compare the configured catalog that the frontend passes us with the configured catalog that is stored in the database, and those configured catalogs only contain streams that are enabled. So I think it will be a purely frontend change to bring it in line with this behavior, which we should do so that they are consistent

@lmossman
Copy link
Contributor

lmossman commented Jul 17, 2022

@timroes you should rebase or merge master again, as on Friday I merged a fix for a bug I found in the updateNew endpoint: #14763

@timroes
Copy link
Collaborator Author

timroes commented Jul 18, 2022

, and those configured catalogs only contain streams that are enabled.

Just for double checking: At the moment (before and with this PR) we're sending to the backend also all non-enabled streams, and have selected: false set on them. So with the change of only comparing active streams, we'd compare on a subset of what we're sending to the backend. This would still though be the desired behavior?

@timroes
Copy link
Collaborator Author

timroes commented Jul 19, 2022

Added the change to only compare selected streams for showing the modal.

@timroes
Copy link
Collaborator Author

timroes commented Jul 19, 2022

Another thing I noticed: After adding the new table and saving the schema, the stream disappears from the list. But when I reload the replication page, it appears again.

This is caused by some issue in the API. I filed #14839 to get this fixed.

@timroes
Copy link
Collaborator Author

timroes commented Jul 19, 2022

@edmundito Could you give this another look? With Andy out, Charles and I would prefer merging the changes (once BE is fixed) for now as it is, and do a separate PR for cleaning up the modal (wording + design) once Andy will be available again.

airbyte-webapp/src/locales/en.json Outdated Show resolved Hide resolved
airbyte-webapp/src/locales/en.json Outdated Show resolved Hide resolved
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Code changes look good. Will approve pending @andyjih's comments on the wording for final approval.

timroes and others added 3 commits July 19, 2022 18:19
Co-authored-by: Andy Jih <andyjih@users.noreply.github.com>
Co-authored-by: Andy Jih <andyjih@users.noreply.github.com>
@timroes timroes requested a review from andyjih July 19, 2022 17:21
@timroes timroes merged commit 87dcfd2 into master Jul 19, 2022
@timroes timroes deleted the tim/per-stream-flow branch July 19, 2022 19:01
mfsiega-airbyte pushed a commit that referenced this pull request Jul 21, 2022
* [WIP] new per stream flow

* Start work on ModalSerice

* Continue work

* Fix typo

* Change wording

* Add todos and remove dead code

* Remove dead message

* Adjust to new API

* Adjust to new modal changes

* Remove debug output

* Fix e2e test

* Add data-testids

* Adjust for PR review

* Switch to new ModalFooter/Body components

* Add ModalService tests

* Downgrade user-events again

* Only compare selected streams

* Update airbyte-webapp/src/locales/en.json

Co-authored-by: Andy Jih <andyjih@users.noreply.github.com>

* Update airbyte-webapp/src/locales/en.json

Co-authored-by: Andy Jih <andyjih@users.noreply.github.com>

* Remove redundant space

Co-authored-by: Andy Jih <andyjih@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform team/documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Per-Stream adjust frontend flow
6 participants