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

Sovrn connector UI #2579

Merged
merged 18 commits into from
Feb 16, 2023

Conversation

allisonking
Copy link
Contributor

@allisonking allisonking commented Feb 13, 2023

Closes #2458

Code Changes

There was unfortunately quite a bit of tech debt in this section of code with typescript being ignored and other eslint workarounds. I couldn't resist fixing it up (also because things were confusing me). These were:

  • Extracting filling in defaults to a helper function (with tests). Making copies of parameters instead of reassigning them
  • Refactoring skip logic on querying for connection schema
  • Fix bug that made connector types with only one tab not render properly

Actual feature changes

  • Update openapi typescript types to include latest email type endpoints
  • Add a new Email type ConnectorParameters.tsx (following the pattern of the other connector types)
    • This uses the same handleSubmit code as the Database type connector parameter, so I did some refactoring so they could both use the same logic
  • Cypress tests

Steps to Confirm

This is probably best QA'd alongside #2582

If you make a separate branch out of this one plus #2582, then you should be able to go through the whole flow:

  • Go through the same steps as in Sovrn Email Consent Connector #2543 except:
    • Instead of Because we can't pass in the ljt_readerID from the frontend yet, cache a fake one in the request runner service..., do the following:
      • Add a cookie to your page by opening up the inspector in your browser (opt+cmd+i on osx), entering the console, and setting your cookie via `document.cookie = "ljt_readerID=fides_test_reader_id;"
      • Issue a consent request via the UI to opt out of Email Marketing. In the network tab, you should see ljt_readerID show up in the payload for PATCH preferences under browser_identity
    • Instead of Add a sovrn consent email connector via the API:
      • Go through the admin UI and add a sovrn connector! You should be able to add it and also send a test email

Pre-Merge Checklist

Description Of Changes

Write some things here about the changes and any potential caveats

Comment on lines -126 to -130
if (step) {
setSelectedItem(
connector?.options[Number(step.stepId) - connector.options.length]
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really could not figure out the purpose of this line, and it caused a bug when there's only one tab available, so I got rid of it

Copy link
Contributor

Choose a reason for hiding this comment

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

Bravo tracking this down!

Comment on lines -73 to -81
useEffect(() => {
mounted.current = true;
if (connectionOption?.type !== SystemType.MANUAL) {
setSkip(false);
}
return () => {
mounted.current = false;
};
}, [connectionOption?.type]);
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 useEffect + skip pattern was hard to follow, so I refactored it and it seems to still work well

@@ -36,19 +39,14 @@ type ConnectorParametersProps = {
onTestConnectionClick: (value: any) => void;
};

export const ConnectorParameters: React.FC<ConnectorParametersProps> = ({
data,
export const useDatabaseConnector = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extracted this to a hook because the email connector uses the same API logic

}
return defaultValues;
return fillInDefaults(initialValues, data);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

basically an effort to remove duplicate code (note the two Object.entries()... that are the same above) and also to extract to a function that is tested

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

❗ No coverage uploaded for pull request base (fides_2394_sovrn_connector@e56bfdf). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@                      Coverage Diff                      @@
##             fides_2394_sovrn_connector    #2579   +/-   ##
=============================================================
  Coverage                              ?   86.05%           
=============================================================
  Files                                 ?      289           
  Lines                                 ?    15760           
  Branches                              ?     1983           
=============================================================
  Hits                                  ?    13562           
  Misses                                ?     1818           
  Partials                              ?      380           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@allisonking allisonking marked this pull request as ready for review February 13, 2023 23:17
@allisonking
Copy link
Contributor Author

Oh actually I forgot I still need to fix the Awaiting Email Send

@allisonking
Copy link
Contributor Author

image

Another option was:
image

I thought the first one looked slightly better, but it's easy enough to change (the second option uses whiteSpace="break-spaces" and removes the fixed width)

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

@allisonking could you actually change this so it makes a request that looks something like this? My latest commit on the backend branch yesterday where I change the expected format expects the advanced settings block.

{
    "recipient_email_address": "dawn@ethyca.com",
    "test_email_address": "dawn@ethyca.com",
    "advanced_settings": {
        "identity_types": {
            "email": false,
            "phone_number": false,
            "cookie_ids":  []
        }
    }
}

@cypress
Copy link

cypress bot commented Feb 15, 2023

Passing run #108 ↗︎

0 3 0 0 Flakiness 0

Details:

Merge 9e26755 into e56bfdf...
Project: fides Commit: 826feceff7 ℹ️
Status: Passed Duration: 00:38 💡
Started: Feb 15, 2023 4:25 PM Ended: Feb 15, 2023 4:26 PM

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

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

While I can't easily review the code, I QA'd this and it looks great to me. Nice with the one tab so DatasetConfigs aren't created. Thanks again for stubbing out the API response for now.

You're welcome to merge this into my backend base branch when ready!

@allisonking
Copy link
Contributor Author

Thanks @pattisdr ! requesting @TheAndrewJackson to review the code part. I think you've done the hard part of QA-ing it, so hopefully Andrew can just look through the code (not that that is easy either, sorry for all the changes... it took me a long time to wrap my head around how the connectors stuff worked)

@allisonking allisonking merged commit 08d3393 into fides_2394_sovrn_connector Feb 16, 2023
@allisonking allisonking deleted the aking/2458/sovrn-connector-ui branch February 16, 2023 16:20
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.

2 participants