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

[SIP-15] Adding initial framework #8398

Merged
merged 3 commits into from
Oct 28, 2019

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Oct 15, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

This PR provides the initial framework for SIP-15 which is currently behind a disabled feature flag. Note this is still WIP as SIP-15A also needs to be addressed prior to this feature being live.

Given that SIP-15 requires a rollout period (where users can preview and correct changes as necessary) the premise of this PR is to add the necessary wiring to allow users to:

  1. Explicitly see how the current time range endpoints behave. Note this is only when the chart references explicit times as opposed to now, 7 days ago, etc.
  2. Preview via link (restricted to owners) how their chart will behave when the [start, end] (or equivalent) interval is changed to [start, end).

Note the backend logic is behind a feature flag whereas the frontend logic which leverages the endpoints is not, i.e., the the endpoints prop is simply undefined. These endpoints will persist after SIP-15 has been rolled out (to provide more transparency as to how the time range endpoints behave though we'll simply hard code these).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Current

Screen Shot 2019-10-15 at 2 51 36 PM

Screen Shot 2019-10-18 at 10 32 37 AM

SIP-15 enabled but chart not updated

Screen Shot 2019-10-15 at 2 54 25 PM

Screen Shot 2019-10-15 at 3 31 24 PM

Screen Shot 2019-10-18 at 10 23 05 AM

SIP-15 enabled chart preview link

Screen Shot 2019-10-24 at 10 48 23 AM

SIP-15 enabled and chart updated (via preview or save)

Screen Shot 2019-10-15 at 2 58 43 PM

Screen Shot 2019-10-15 at 3 31 07 PM

Screen Shot 2019-10-18 at 10 31 36 AM

TEST PLAN

ADDITIONAL INFORMATION

REVIEWERS

to: @betodealmeida @etr2460 @michellethomas @mistercrunch @villebro
cc: @sylvia-tomiyama

@john-bodley john-bodley changed the title [sip-15] Adding initial framework [SIP-15] Adding initial framework Oct 15, 2019
@john-bodley john-bodley force-pushed the john-bodley--sip-15-messaging branch 7 times, most recently from 81ae5e0 to 1f285af Compare October 16, 2019 01:53
@codecov-io
Copy link

codecov-io commented Oct 16, 2019

Codecov Report

Merging #8398 into master will decrease coverage by 0.02%.
The diff coverage is 58.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8398      +/-   ##
==========================================
- Coverage   66.58%   66.56%   -0.03%     
==========================================
  Files         449      449              
  Lines       22525    22567      +42     
  Branches     2364     2367       +3     
==========================================
+ Hits        14999    15021      +22     
- Misses       7388     7408      +20     
  Partials      138      138
Impacted Files Coverage Δ
superset/viz.py 71.29% <ø> (ø) ⬆️
...rset/assets/src/messageToasts/components/Toast.jsx 93.75% <ø> (ø) ⬆️
...rset/assets/src/explore/controlPanels/sections.jsx 100% <ø> (ø) ⬆️
superset/utils/core.py 88.65% <100%> (+0.09%) ⬆️
superset/config.py 89.34% <100%> (+0.16%) ⬆️
superset/assets/src/explore/controls.jsx 42.18% <100%> (+0.91%) ⬆️
superset/views/utils.py 76.41% <15.78%> (-13.36%) ⬇️
superset/views/core.py 72.15% <60%> (-0.07%) ⬇️
superset/connectors/sqla/models.py 84.87% <83.33%> (-0.09%) ⬇️
.../explore/components/controls/DateFilterControl.jsx 40% <87.5%> (+2.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7f0be5...8cf290b. Read the comment docs.

@john-bodley john-bodley force-pushed the john-bodley--sip-15-messaging branch from 1f285af to d1d05b4 Compare October 16, 2019 04:47
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

a few comments on the JS stuff

# Note currently SIP-15 feature is WIP and should not be enabled.
SIP_15_ENABLED = False
SIP_15_DEFAULT_TIME_RANGE_ENDPOINTS = ["unknown", "inclusive"]
SIP_15_TOAST_MESSAGE = 'Preview then save your chart using the new time range endpoints <a href="{url}" class="alert-link">here</a>.'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe prefixing this with Action Required: or something like that to make it more apparent what's needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

@etr2460 one issue I ran into is that any more text would wrap in the toast which looked a tad weird. Do you know if these toasts can be resized?

Copy link
Member

Choose a reason for hiding this comment

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

You could always increase the max size of the toasts. It seems like a reasonable change

@@ -96,7 +97,7 @@ class Toast extends React.Component {
toastType === DANGER_TOAST && 'toast--danger',
)}
>
{text}
<div dangerouslySetInnerHTML={{ __html: dompurify.sanitize(text) }} />
Copy link
Member

Choose a reason for hiding this comment

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

we should really avoid dangerously setting html. Why not encode the URL in another way and then pull it out of the string? I know this is just to make flash work since it only accepts a string. But instead i'd send a flash something like:

Preview then save your chart using the new time range endpoints $$$SUPER_UNIQUE_TOKEN_FOR_ENCODING_LINK_FOR_HERE$$$http://superset.../

Then you could just do in a helper function:

const parts = str.split('$$$SUPER_UNIQUE_TOKEN_FOR_ENCODING_LINK_FOR_HERE$$$');
if (parts.length > 1) {
  return <div>{parts.length[0]} <a href={parts.length[1]}>here</a>.</div>;
} else {
  return <div>{parts.length[0]}</div>;
}

Copy link
Member

Choose a reason for hiding this comment

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

But in general, this is super hacky.... maybe there's a way to do this without needing to use flash?

Copy link
Member Author

Choose a reason for hiding this comment

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

@williaster thoughts?

@@ -494,7 +495,9 @@ export default class DateFilterControl extends React.Component {
}
render() {
let value = this.props.value || defaultProps.value;
value = value.split(SEPARATOR).map((v, idx) => v.replace('T00:00:00', '') || (idx === 0 ? '-∞' : '∞')).join(SEPARATOR);
const endpoints = this.props.endpoints;
const iso8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/;
Copy link
Member

Choose a reason for hiding this comment

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

I'd pull this out to the top of the file and name is something like ISO_8601_REGEX_MATCH

@john-bodley john-bodley force-pushed the john-bodley--sip-15-messaging branch 2 times, most recently from dfc2925 to f8b4b63 Compare October 18, 2019 17:23
SIP-15
------

`SIP-15 <https://github.com/apache/incubator-superset/issues/6360>`_ aims to ensure that time intervals are handled in a consistent and transparent manner for both the Druid and SQLAlchemy connectors.
Copy link
Member

Choose a reason for hiding this comment

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

nit: remove extra underscore here

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

ah i see.

type: 'HiddenControl',
label: t('Time range endpoints'),
hidden: true,
description: t('Time range endpoints (SIP-15)'),
Copy link
Member

Choose a reason for hiding this comment

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

Should we elaborate more about SIP-15 here? Provide a link or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

@etr2460 this control is always hidden and only exists to ensure that associated form-data is preserved.

# Note currently SIP-15 feature is WIP and should not be enabled.
SIP_15_ENABLED = False
SIP_15_DEFAULT_TIME_RANGE_ENDPOINTS = ["unknown", "inclusive"]
SIP_15_TOAST_MESSAGE = 'Preview then save your chart using the new time range endpoints <a href="{url}" class="alert-link">here</a>.'
Copy link
Member

Choose a reason for hiding this comment

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

You could always increase the max size of the toasts. It seems like a reasonable change

@john-bodley
Copy link
Member Author

@etr2460 I addressed your comments.

@john-bodley john-bodley force-pushed the john-bodley--sip-15-messaging branch 3 times, most recently from a8852e6 to d051e8c Compare October 24, 2019 23:48
@john-bodley
Copy link
Member Author

@etr2460 would you mind reviewing this again?

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

a few more comments

SIP-15
------

`SIP-15 <https://github.com/apache/incubator-superset/issues/6360>`_ aims to ensure that time intervals are handled in a consistent and transparent manner for both the Druid and SQLAlchemy connectors.
Copy link
Member

Choose a reason for hiding this comment

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

ah i see.

return (
<OverlayTrigger
key={timeFrame}
placement="left"
overlay={
<Tooltip id={`tooltip-${timeFrame}`}>
{nextState.since}<br />{nextState.until}
{nextState.since} {endpoints ? `(${endpoints[0]})` : ''}<br />{nextState.until} {endpoints ? `(${endpoints[1]})` : ''}
Copy link
Member

@etr2460 etr2460 Oct 28, 2019

Choose a reason for hiding this comment

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

these can be {endpoints && `(${endpoints[0]})`} instead of the ternary with the empty string

@@ -494,7 +497,8 @@ export default class DateFilterControl extends React.Component {
}
render() {
let value = this.props.value || defaultProps.value;
value = value.split(SEPARATOR).map((v, idx) => v.replace('T00:00:00', '') || (idx === 0 ? '-∞' : '∞')).join(SEPARATOR);
const endpoints = this.props.endpoints;
value = value.split(SEPARATOR).map((v, idx) => ISO_8601_REGEX_MATCH.test(v) ? v.replace('T00:00:00', '') + (endpoints ? ` (${endpoints[idx]})` : '') : v || (idx === 0 ? '-∞' : '∞')).join(SEPARATOR);
Copy link
Member

Choose a reason for hiding this comment

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

same note here about the ternary. some newlines might also make this more readable.



# Note currently SIP-15 feature is WIP and should not be enabled.
SIP_15_ENABLED = False
Copy link
Member

Choose a reason for hiding this comment

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

i think this should all be above line 682, otherwise you'll be overriding custom configs here

@john-bodley
Copy link
Member Author

@etr2460 I addressed your comments.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

lgtm!

@john-bodley john-bodley force-pushed the john-bodley--sip-15-messaging branch from 7c92647 to 8cf290b Compare October 28, 2019 20:11
@john-bodley john-bodley merged commit 8b74745 into apache:master Oct 28, 2019
@john-bodley john-bodley deleted the john-bodley--sip-15-messaging branch October 28, 2019 21:23
graceguo-supercat pushed a commit that referenced this pull request Nov 13, 2019
* [sip-15] Adding initial framework

* [toast] Addressing etr2460's comments

* [fix] Addressing etr2460's comments
@dpgaspar dpgaspar added v0.35 and removed v0.35 labels Dec 20, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants