You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/02/21 18:35:42 UTC

[GitHub] graceguo-supercat closed pull request #4457: [explore] allow URL shortner even if no slice exist

graceguo-supercat closed pull request #4457: [explore] allow URL shortner even if no slice exist
URL: https://github.com/apache/incubator-superset/pull/4457
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/javascripts/explore/components/ExploreActionButtons.jsx b/superset/assets/javascripts/explore/components/ExploreActionButtons.jsx
index 74f9b73348..ec9d214c07 100644
--- a/superset/assets/javascripts/explore/components/ExploreActionButtons.jsx
+++ b/superset/assets/javascripts/explore/components/ExploreActionButtons.jsx
@@ -9,27 +9,28 @@ import { exportChart } from '../exploreUtils';
 
 const propTypes = {
   canDownload: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired,
-  slice: PropTypes.object,
   chartStatus: PropTypes.string,
   latestQueryFormData: PropTypes.object,
   queryResponse: PropTypes.object,
 };
 
 export default function ExploreActionButtons({
-    canDownload, slice, chartStatus, latestQueryFormData, queryResponse }) {
+    canDownload, chartStatus, latestQueryFormData, queryResponse }) {
   const exportToCSVClasses = cx('btn btn-default btn-sm', {
     'disabled disabledButton': !canDownload,
   });
   const doExportCSV = exportChart.bind(this, latestQueryFormData, 'csv');
   const doExportChart = exportChart.bind(this, latestQueryFormData, 'json');
 
-  if (slice) {
-    return (
-      <div className="btn-group results" role="group">
-        <URLShortLinkButton latestQueryFormData={latestQueryFormData} />
+  return (
+    <div className="btn-group results" role="group">
+      {latestQueryFormData &&
+        <URLShortLinkButton latestQueryFormData={latestQueryFormData} />}
 
-        <EmbedCodeButton latestQueryFormData={latestQueryFormData} />
+      {latestQueryFormData &&
+        <EmbedCodeButton latestQueryFormData={latestQueryFormData} />}
 
+      {latestQueryFormData &&
         <a
           onClick={doExportChart}
           className="btn btn-default btn-sm"
@@ -38,8 +39,8 @@ export default function ExploreActionButtons({
           rel="noopener noreferrer"
         >
           <i className="fa fa-file-code-o" /> .json
-        </a>
-
+        </a>}
+      {latestQueryFormData &&
         <a
           onClick={doExportCSV}
           className={exportToCSVClasses}
@@ -48,18 +49,13 @@ export default function ExploreActionButtons({
           rel="noopener noreferrer"
         >
           <i className="fa fa-file-text-o" /> .csv
-        </a>
-
-        <DisplayQueryButton
-          queryResponse={queryResponse}
-          latestQueryFormData={latestQueryFormData}
-          chartStatus={chartStatus}
-        />
-      </div>
-    );
-  }
-  return (
-    <DisplayQueryButton latestQueryFormData={latestQueryFormData} />
+        </a>}
+      <DisplayQueryButton
+        queryResponse={queryResponse}
+        latestQueryFormData={latestQueryFormData}
+        chartStatus={chartStatus}
+      />
+    </div>
   );
 }
 
diff --git a/superset/assets/spec/javascripts/explore/components/ExploreActionButtons_spec.jsx b/superset/assets/spec/javascripts/explore/components/ExploreActionButtons_spec.jsx
index 506dd23f97..545446ecbe 100644
--- a/superset/assets/spec/javascripts/explore/components/ExploreActionButtons_spec.jsx
+++ b/superset/assets/spec/javascripts/explore/components/ExploreActionButtons_spec.jsx
@@ -8,12 +8,7 @@ import ExploreActionButtons from
 describe('ExploreActionButtons', () => {
   const defaultProps = {
     canDownload: 'True',
-    slice: {
-      data: {
-        csv_endpoint: '',
-        json_endpoint: '',
-      },
-    },
+    latestQueryFormData: {},
     queryEndpoint: 'localhost',
   };
 


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services