-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
[SIP-15] Adding initial framework #8398
Conversation
81ae5e0
to
1f285af
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
1f285af
to
d1d05b4
Compare
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.
a few comments on the JS stuff
superset/config.py
Outdated
# 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>.' |
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.
Maybe prefixing this with Action Required:
or something like that to make it more apparent what's needed?
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.
@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?
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.
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) }} /> |
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.
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>;
}
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.
But in general, this is super hacky.... maybe there's a way to do this without needing to use flash
?
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.
@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}$/; |
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'd pull this out to the top of the file and name is something like ISO_8601_REGEX_MATCH
dfc2925
to
f8b4b63
Compare
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. |
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.
nit: remove extra underscore here
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.
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.
ah i see.
type: 'HiddenControl', | ||
label: t('Time range endpoints'), | ||
hidden: true, | ||
description: t('Time range endpoints (SIP-15)'), |
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.
Should we elaborate more about SIP-15 here? Provide a link or something?
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.
@etr2460 this control is always hidden and only exists to ensure that associated form-data is preserved.
superset/config.py
Outdated
# 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>.' |
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.
You could always increase the max size of the toasts. It seems like a reasonable change
@etr2460 I addressed your comments. |
a8852e6
to
d051e8c
Compare
@etr2460 would you mind reviewing this again? |
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.
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. |
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.
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]})` : ''} |
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.
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); |
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.
same note here about the ternary. some newlines might also make this more readable.
superset/config.py
Outdated
|
||
|
||
# Note currently SIP-15 feature is WIP and should not be enabled. | ||
SIP_15_ENABLED = False |
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 this should all be above line 682, otherwise you'll be overriding custom configs here
@etr2460 I addressed your comments. |
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.
lgtm!
7c92647
to
8cf290b
Compare
* [sip-15] Adding initial framework * [toast] Addressing etr2460's comments * [fix] Addressing etr2460's comments
CATEGORY
Choose one
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:
now
,7 days ago
, etc.[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
SIP-15 enabled but chart not updated
SIP-15 enabled chart preview link
SIP-15 enabled and chart updated (via preview or save)
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS
to: @betodealmeida @etr2460 @michellethomas @mistercrunch @villebro
cc: @sylvia-tomiyama