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
Update Experiment Assignment Query form to use EditSqlModal. #1370
Conversation
Your preview environment pr-1370-bttf has been deployed. Preview environment endpoints are available at: |
…ers know they need to customize it. Also simplifies the logic for showing the advanced mmode div.
GB-78 (Frontend) - Add component to experiment assignment builder
The |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…s based on what is passed in to the query, and we're no longer warning users if they don't include a dimension column, we're instead just removing it as a dimension so the experience is in-line with that of the useNameCols
await save(value.sql); | ||
})} | ||
close={close} | ||
error={testQueryResults?.error} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This reverts commit 64f73e9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the demo! Just one minor suggestion
save={async (userEnteredQuery) => { | ||
form.setValue("query", userEnteredQuery); | ||
}} | ||
validateResponse={(result) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably worth just defining this as a function outside of the component body ... just for readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10-4! Just updated that in this commit - thanks for your review!
Features and Changes
This PR updates the
AddEditExperimentAssignmentQueryModal
to consume the newEditSqlModal
that was introduced when we added support for theSchemaBrowser
. Initially, when we launched theSchemaBrowser
we didn't add support for it within theAddEditExperimentAssignmentQueryModal
as that modal had a few features unique to it - such as support forhasNameCol
and dimension columns.Previously, when building an experiment assignment query, the user would check the box if they would like to
useNameCols
and they would manually enter what dimension columns they wanted to include in the query. TheSqlInputField
then took the value of those features into account when determining therequiredColumns
.Now, we've introduced an "Advanced" section that is collapsed by default where the user can enable
useNameCols
and add dimensions. The existing "Test Query" logic is still in place - with this, if a user tests a query that contains both name columns, we will automatically enableuseNameCols
for them (the opposite is also true - if they haveuseNameCols
enabled, but the query doesn't contain either column, we'll automatically disableuseNameCols
for them. Likewise, if a user tests a query that has columns outside of the required columns, we'll automatically add that as a dimension column when they use the "Test Query" button, or if they save the form with "Test query before saving" checked.When it comes to dimension columns, the logic mirrors the above - if a dimension is included in the query, we'll automatically add it to the dimensions array, and the opposite is also true, if the user has entered a dimension into the dimensions array in the "advanced" section, but they don't include it in the query, rather than throwing an error, we just remove it from the dimensions array.
The only time we'll throw an error for a missing column is if the column isn't a dimension.
This feels little weird, but it is inline with the logic around
useNameColumns
and the UX if we don't do this is kinda weird. (E.X. We'd throw an error that they're missing a dimension, and they'd have to close theEditSqlModal
-> remove the dimension from the dimensions input in the advanced section, and then open theEditSqlModal
again.I've also added a warning message if the query isn't changed from the default sql value so users know they need to customize it.
And finally, this PR includes a checkbox within the
EditSqlModal
toTest Query Before Saving
- when checked, we'll test the query and if there are any errors, we'll surface those and block saving/closing the modal.Before
After
Testing
Create a new experiment assignment query, and write a valid sql query that does not include any additional columns and doesn't not include
experiment_name
andvariation_name
columns and ensure the query is saved successfully, and within Mongo the query object'shasNameCol
property is false, and thedimensions
array is empty.Create a new experiment assignment query, and write a valid sql query that DOES include an additional column (e.g. "browser"), but doesn't not include
experiment_name
andvariation_name
columns and ensure the query is saved successfully, and within Mongo the query object'shasNameCol
property is false, and thedimensions
array is empty.Create a new experiment assignment query, and write a valid sql query that DOES include an additional column (e.g. "browser"), but doesn't not include
experiment_name
andvariation_name
columns and when clicking theTest Query
the extra column is added as a dimension automatically.Create a new experiment assignment query, and write a valid sql query that DOES include an additional column (e.g. "browser"), and DOES include
experiment_name
andvariation_name
columns and that when clicking theTest Query
button, theuserEnteredHasNameCols
is flipped to true.Create a new experiment assignment query and write an invalid sql query, and ensure that clicking "Save" throws an error and blocks the user from being able to save the query. Now, uncheck the "Test before saving" box and click save again and ensure the form is closed and the query is saved, despite being invalid.
Create a new experiment assignment query and write an invalid sql query and click the "Test Query" button, ensure that an error message is displayed - now, fix the query, and click the "Save" button with the "Test before saving" box checked, and ensure the form is closed and the query is saved successfully.
Create a new experiment assignment query and don't toggle the "useNameCols" automatically, but instead write a query that is valid, and add
experiment_name
as a column and click the "Save" button with "Test before saving" box checked - ensure that an error is displayed telling the user to either removeexperiment_name
or addvariation_name
- Add variation name and click "Save" again and ensure the form closes and the query is saved. And ensureuseNameCols
has been automatically enabled.Now, open the same exp assignment query and remove both
experiment_name
andvariation_name
columns and click "Save" with "Test before saving" checked, and ensure it saves correctly, anduseNameCols
is now disabled in the "Advanced" sectionCreate a new experiment assignment query and write an valid sql query and click the "Test Query" button, ensure that rows are returned, now, remove a required column that ISN'T a dimension, and ensure you get an error message. Add that required column back in, and this time, add a dimension and click "Test Query" and ensure that the requiredColumns array is updated with the new dimension. And, lastly, remove the new dimension from the query and click "Save" with "Test query before saving" - Ensure it saves correctly, and the dimension has been removed successfully.
When we're rendering the modal, we're passing the error in via the error prop
Closes GB-78