You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/04/01 18:58:30 UTC

[GitHub] [incubator-superset] graceguo-supercat commented on a change in pull request #7180: fix: do not crash when a vis type is disabled.

graceguo-supercat commented on a change in pull request #7180: fix: do not crash when a vis type is disabled.
URL: https://github.com/apache/incubator-superset/pull/7180#discussion_r271006366
 
 

 ##########
 File path: superset/assets/src/explore/components/controls/VizTypeControl.jsx
 ##########
 @@ -132,44 +115,50 @@ export default class VizTypeControl extends React.PureComponent {
         </div>
       </div>);
   }
+
   render() {
     const { filter, showModal } = this.state;
     const { value } = this.props;
 
-    const registry = getChartMetadataRegistry();
-    const types = this.sortVizTypes(registry.entries());
-    const filteredTypes = filter.length > 0
-      ? types.filter(type => type.value.name.toLowerCase().includes(filter.toLowerCase()))
-      : types;
-
-    const selectedType = registry.get(value);
+    const filterString = filter.toLowerCase();
+    const filteredTypes = DEFAULT_ORDER
+      .filter(type => registry.has(type))
+      .map(type => ({
+        key: type,
+        value: registry.get(type),
+      }))
+      .concat(registry.entries().filter(({ key }) => !typesWithDefaultOrder.has(key)))
+      .filter(entry => entry.value.name.toLowerCase().includes(filterString));
 
-    const imgPerRow = 6;
     const rows = [];
-    for (let i = 0; i <= filteredTypes.length; i += imgPerRow) {
+    for (let i = 0; i <= filteredTypes.length; i += IMAGE_PER_ROW) {
       rows.push(
         <Row key={`row-${i}`}>
-          {filteredTypes.slice(i, i + imgPerRow).map(entry => (
-            <Col md={12 / imgPerRow} key={`grid-col-${entry.key}`}>
+          {filteredTypes.slice(i, i + IMAGE_PER_ROW).map(entry => (
+            <Col md={12 / IMAGE_PER_ROW} key={`grid-col-${entry.key}`}>
               {this.renderItem(entry)}
             </Col>
           ))}
         </Row>);
     }
+
     return (
       <div>
-        <ControlHeader
-          {...this.props}
-        />
+        <ControlHeader {...this.props} />
         <OverlayTrigger
           placement="right"
           overlay={
-            <Tooltip id={'error-tooltip'}>{t('Click to change visualization type')}</Tooltip>
+            <Tooltip id="error-tooltip">{t('Click to change visualization type')}</Tooltip>
           }
         >
-          <Label onClick={this.toggleModal} style={{ cursor: 'pointer' }}>
-            {selectedType.name}
-          </Label>
+          <React.Fragment>
+            <Label onClick={this.toggleModal} style={LABEL_STYLE}>
+              {registry.has(value) ? registry.get(value).name : `${value}`}
+            </Label>
+            {(!registry.has(value) && <div className="text-danger">
+              <i className="fa fa-exclamation-circle text-danger" /> <small>This visualization type is not supported.</small>
 
 Review comment:
   `This visualization type is not supported` should be wrapped in i18n (t function)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org