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

Migrate Embed Query Dialog to React #3783

Merged
merged 12 commits into from
May 15, 2019
Merged

Migrate Embed Query Dialog to React #3783

merged 12 commits into from
May 15, 2019

Conversation

gabrieldutra
Copy link
Member

@gabrieldutra gabrieldutra commented May 9, 2019

What type of PR is this? (check all applicable)

  • Refactor

Description

It was a pretty simple migration, so it seemed a good opportunity to explore Antd's Typography.

To make Typography's <code> better fit the current in Redash we can remove the gray background.

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

embed-query-dialog

Alert when embedding query containing text parameters
embed-query-alert (1)

visualization.id}?api_key=${query.api_key}&${query.getParameters().toUrlParams()}`;

let snapshotUrl;
if (window.snapshotUrlBuilder) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what this is for, but I just followed what was in the Angular version.

@gabrieldutra gabrieldutra self-assigned this May 9, 2019
<h5 className="m-t-0">IFrame Embed</h5>
<div className="m-b-10">
<Text data-test="EmbedIframe" copyable code>
{`<iframe src="${embedUrl}" width="720" height="391"></iframe>`}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@gabrieldutra I think it would be better to replace this with <textarea> - so user will be able to copy it manually and it will not require ellipsis (I personally use this dialog just to get embed URL when I need to test something, so it's a case for having all the code available).

Copy link
Member Author

Choose a reason for hiding this comment

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

I've considered using a TextArea too, but I thought the copy button could be a good feature. I'll check it with the TextArea 👍

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @kravets-levko that we shouldn't use an ellipsis here, but why a textarea?

@ranbena
Copy link
Contributor

ranbena commented May 9, 2019

Wdyt of the following design?

  1. Code block.
  2. Copy button appears in corner on hover.
  3. Allow setting iframe width / height.

Screen Shot 2019-05-09 at 10 58 45

@gabrieldutra
Copy link
Member Author

Wdyt of the following design?

Seems nice, perhaps without the Checkbox (not really necessary to make width and height disabled since it doesn't really change the behavior) or if you think it has a reason to be there, use a switch instead?

@ranbena
Copy link
Contributor

ranbena commented May 9, 2019

Seems nice, perhaps without the Checkbox (not really necessary to make width and height disabled since it doesn't really change the behavior) or if you think it has a reason to be there, use a switch instead?

I agree, it's not necessary - it serves as a hint for "normal" users that the current setting is default and doesn't require adjustment - "ignorable" if you will. Not a must.

(A switch I think would be too distracting tho)

@arikfr
Copy link
Member

arikfr commented May 9, 2019

My suggestions to address some common use cases with this dialog:

  1. Show a copy-able URL for the visualization (the one we use for the iframe). 99% of the times I used this dialog, I just needed to copy this URL :) We can call this "Public URL".
  2. As the next section, show the iframe.
  3. If the query has unsafe parameters (query.is_safe = true), then show a message saying you can't currently embed queries with parameters of type text. This is instead the embed URLs.

@gabrieldutra
Copy link
Member Author

gabrieldutra commented May 12, 2019

I've updated this based on your comments :), just need some final UI adjustments. @ranbena welcome to give your magic look to it already 😆

react-embed-query-dialog-code-block

My thoughts: now that it has two sections the default look for Form Labels (Width and Height) may be confusing, so it's better with a smaller font-weight (I think I'll add an <hr /> to separate sections too). Regarding the checkbox, after playing with the dialog I think it's better with it.

Those are my ideas, I'll update this tomorrow (technically just later today), but you can already give your comments.

@arikfr
Copy link
Member

arikfr commented May 12, 2019

Last version looks good 👌 One thing I would change: have the copy button always visible instead of only on hover.

Also, can you add a screenshot of the dialog when you try to embed with unsafe params?

@ranbena
Copy link
Contributor

ranbena commented May 12, 2019

Screen Shot 2019-05-12 at 5 16 42

@ranbena
Copy link
Contributor

ranbena commented May 12, 2019

I think it looks good as well 👌👌

Here's an updated version:
Screen Shot 2019-05-12 at 5 36 49

It's got:

  • persistent copy buttons - give the codebox padding-left: 27px padding-right: 27px (:laughing:) so button won't overlap code.
  • checkbox - has the effect of indenting the row which makes it clearer that it's iframe related
  • normal weighted labels
  • small input-numbers + width 72px

Copy link
Contributor

@ranbena ranbena left a comment

Choose a reason for hiding this comment

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

Looks great!

Just one request @gabrieldutra - change code block to border-radius: 2px (similar to Ant components) 🙏

Copy link
Member Author

@gabrieldutra gabrieldutra left a comment

Choose a reason for hiding this comment

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

Styling Update
Current:
embed-query-no-hr (1)

Alternatively with <hr> (it's sort of cool to separate stuff):
embed-query-hr (1)

  • I've updated the dialog's title: "Embed Code" -> "Embed Query", looks more related to what it is

Embed query spec

  • Now that it has a Public URL separate, no need for a regex 🙂.
  • With the new alert for unsafe parameters, the flow for getting the URL needs to be done differently (e.g: creating a query with safe parameters, saving the url and then changing it to have unsafe parameters). The simplest was to just remove the snapshot and moving the assertion to the Dialog. This generates a case uncovered from tests, so LMK if there's value on creating another test for the case I mentioned in the example;

CC: @rauchy

@@ -5,7 +5,7 @@ describe('Embedded Queries', () => {
cy.login();
});

it('are shared without parameters', () => {
it('can be shared without parameters', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Seemed a better naming to me.

@ranbena
Copy link
Contributor

ranbena commented May 14, 2019

Alternatively with <hr> (it's sort of cool to separate stuff)

With the right spacing it could be nice. <Divider dashed /> is also an option.

I personally though would instead go with m-b-30 for the top code block. Looks nice and clean.

<div class="m-b-30">
  <div class="code-block"></div>
</div>

I've updated the dialog's title: "Embed Code" -> "Embed Query", looks more related to what it is

👍

@arikfr arikfr merged commit 4f40237 into master May 15, 2019
@arikfr arikfr deleted the react-embed-query-dialog branch May 15, 2019 05:38
@arikfr
Copy link
Member

arikfr commented May 15, 2019

👌

harveyrendell pushed a commit to pushpay/redash that referenced this pull request Nov 14, 2019
* Update Antd

* Migrate Embed Query Dialog to React

* Update jest ScheduleDialog snapshot

* Add Alert for unsafe queries

* Add CodeBlock

* Add inputs to change iframe size

* Undo ant update

* Update share embed spec

* Update styling

* Change border-radius to 2px

* Update margin between Public URL and IFrame Embed
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.

4 participants