[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r185149117 ## File path: superset/assets/javascripts/explore/components/ExploreViewContainer.jsx ## @@ -157,27 +151,6 @@ class ExploreViewContainer extends React.Component { } } - addHistory({ isReplace = false, title }) { Review comment: @ttannis can we just keep `addHistory` as untouched as possible? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r180230983 ## File path: superset/assets/javascripts/components/URLShortLinkButton.jsx ## @@ -1,13 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Popover, OverlayTrigger } from 'react-bootstrap'; -import CopyToClipboard from './../../components/CopyToClipboard'; -import { getShortUrl } from '../../../utils/common'; -import { getExploreLongUrl } from '../exploreUtils'; -import { t } from '../../locales'; +import CopyToClipboard from './CopyToClipboard'; +import { getShortUrl } from '../../utils/common'; +import { t } from '../locales'; const propTypes = { - latestQueryFormData: PropTypes.object.isRequired, + url: PropTypes.string, + emailSubject: PropTypes.string, Review comment: Set either `.isRequired` OR set `defaultProps` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r180230983 ## File path: superset/assets/javascripts/components/URLShortLinkButton.jsx ## @@ -1,13 +1,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Popover, OverlayTrigger } from 'react-bootstrap'; -import CopyToClipboard from './../../components/CopyToClipboard'; -import { getShortUrl } from '../../../utils/common'; -import { getExploreLongUrl } from '../exploreUtils'; -import { t } from '../../locales'; +import CopyToClipboard from './CopyToClipboard'; +import { getShortUrl } from '../../utils/common'; +import { t } from '../locales'; const propTypes = { - latestQueryFormData: PropTypes.object.isRequired, + url: PropTypes.string, + emailSubject: PropTypes.string, Review comment: Now that `emailSubject` and `emailContent` are the props, we should pass them good values where the components are used. Also always is `.isRequired` OR set `defaultProps` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179328605 ## File path: superset/assets/javascripts/dashboard/dashboardUtils.js ## @@ -0,0 +1,17 @@ +/* eslint camelcase: 0 */ +import URI from 'urijs'; + +export function getURIDirectory(dashboard) { Review comment: that logic already exists in the backend, you could add a line `'url': self.url,` here: https://github.com/apache/incubator-superset/blob/master/superset/models/core.py#L378 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179325525 ## File path: superset/assets/javascripts/dashboard/components/Dashboard.jsx ## @@ -153,6 +157,27 @@ class Dashboard extends React.PureComponent { return this.props.filters[sliceId]; } + addHistory({ isReplace = false, title }) { +const payload = { ...this.props.dashboard.metadata }; +const longUrl = getDashboardLongUrl(this.props.dashboard); +if (isReplace) { + history.replaceState( Review comment: nit: this would fit on a single line This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179328605 ## File path: superset/assets/javascripts/dashboard/dashboardUtils.js ## @@ -0,0 +1,17 @@ +/* eslint camelcase: 0 */ +import URI from 'urijs'; + +export function getURIDirectory(dashboard) { Review comment: that logic already exists in the backend, you could add a line `'url': self.url,` here: https://github.com/apache/incubator-superset/blob/master/superset/models/core.py#L378 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179325754 ## File path: superset/assets/javascripts/dashboard/dashboardUtils.js ## @@ -0,0 +1,17 @@ +/* eslint camelcase: 0 */ +import URI from 'urijs'; + +export function getURIDirectory(dashboard) { + // Building the directory part of the URI + const dashboardId = dashboard.slug || dashboard.id; + const directory = '/superset/dashboard/' + dashboardId + '/'; Review comment: nit we prefer template literals as in ```javascript `/superset/dashboard/${dashboardId}/` ``` instead of `+` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179326670 ## File path: superset/assets/javascripts/components/URLShortLinkButton.jsx ## @@ -25,20 +27,20 @@ export default class URLShortLinkButton extends React.Component { } getCopyUrl() { -const longUrl = getExploreLongUrl(this.props.latestQueryFormData); +const longUrl = (this.props.type === 'Dashboard') ? getDashboardLongUrl(this.props.context) : getExploreLongUrl(this.props.context); Review comment: Now that this is becoming a more general-purpose component, a better prop would be `url`, and for the component to not be aware of the context beyond that. The caller can run context-specific logic like `getDashboardLongUrl ` Let's make the component more generic. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179344205 ## File path: superset/assets/javascripts/dashboard/components/Dashboard.jsx ## @@ -153,6 +157,27 @@ class Dashboard extends React.PureComponent { return this.props.filters[sliceId]; } + addHistory({ isReplace = false, title }) { Review comment: I'm confused about this method: * why using destructuring in the function parameters? * why do we need to alter the browser history? * `title` is never passed to it, won't that lead to clearing the title? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179326998 ## File path: superset/assets/javascripts/components/URLShortLinkButton.jsx ## @@ -25,20 +27,20 @@ export default class URLShortLinkButton extends React.Component { } getCopyUrl() { -const longUrl = getExploreLongUrl(this.props.latestQueryFormData); +const longUrl = (this.props.type === 'Dashboard') ? getDashboardLongUrl(this.props.context) : getExploreLongUrl(this.props.context); getShortUrl(longUrl, this.onShortUrlSuccess.bind(this)); } renderPopover() { -const emailBody = t('Check out this slice: %s', this.state.shortUrl); +const emailBody = t('Check out this %s: %s', this.props.type.toLowerCase(), this.state.shortUrl); Review comment: `emailBody` and `emailSubject` could be the prop to make the component more generic This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] mistercrunch commented on a change in pull request #4760: URL shortner for dashboards
mistercrunch commented on a change in pull request #4760: URL shortner for dashboards URL: https://github.com/apache/incubator-superset/pull/4760#discussion_r179344602 ## File path: superset/assets/javascripts/components/URLShortLinkButton.jsx ## @@ -25,20 +27,20 @@ export default class URLShortLinkButton extends React.Component { } getCopyUrl() { -const longUrl = getExploreLongUrl(this.props.latestQueryFormData); +const longUrl = (this.props.type === 'Dashboard') ? getDashboardLongUrl(this.props.context) : getExploreLongUrl(this.props.context); Review comment: Also not sure why `getDashboardLongUrl` is necessary in the first place, can we just use `window.location`? Assuming we want the current state of the dashboard (with current filters), `window.location` should be in sync at that point. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services