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 2022/01/17 09:10:22 UTC

[GitHub] [superset] villebro commented on a change in pull request #17208: feat: Dynamic dashboard component

villebro commented on a change in pull request #17208:
URL: https://github.com/apache/superset/pull/17208#discussion_r785743112



##########
File path: superset-frontend/src/visualizations/dashboardComponents/TestComponent/TestComponent.tsx
##########
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { JsonObject } from '@superset-ui/core';
+
+// TODO: POC only component can be removed after PR approved
+const TestComponent = ({ dashboardData }: JsonObject) => (
+  <div>We have next keys: {Object.keys(dashboardData).join(', ')}</div>

Review comment:
       nit:
   ```suggestion
     <div>We have the following keys: {Object.keys(dashboardData).join(', ')}</div>
   ```

##########
File path: superset-frontend/src/dashboard/components/gridComponents/DynamicComponent.tsx
##########
@@ -0,0 +1,184 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { FC, Suspense } from 'react';
+import { JsonObject, t } from '@superset-ui/core';
+import backgroundStyleOptions from 'src/dashboard/util/backgroundStyleOptions';
+import cx from 'classnames';
+import { useSelector } from 'react-redux';
+import DragDroppable from '../dnd/DragDroppable';
+import { COLUMN_TYPE, ROW_TYPE } from '../../util/componentTypes';
+import WithPopoverMenu from '../menu/WithPopoverMenu';
+import ResizableContainer from '../resizable/ResizableContainer';
+import {
+  BACKGROUND_TRANSPARENT,
+  GRID_BASE_UNIT,
+  GRID_MIN_COLUMN_COUNT,
+} from '../../util/constants';
+import HoverMenu from '../menu/HoverMenu';
+import DeleteComponentButton from '../DeleteComponentButton';
+import BackgroundStyleDropdown from '../menu/BackgroundStyleDropdown';
+import dashboardComponents from '../../../visualizations/presets/dashboardComponents';
+import { RootState } from '../../types';
+import { NativeFiltersState } from '../../reducers/types';
+import { DataMaskStateWithId } from '../../../dataMask/types';
+
+type DashboardData = {

Review comment:
       nit: I'd rename this to `DashboardComponentMetadata` or something similar.

##########
File path: superset-frontend/src/setup/setupDasboardComponents.ts
##########
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+  This file can be overridden from outside by custom config, it will add/delete new components to existing config in
+  superset-frontend/src/visualizations/presets/dashboardComponents.ts file
+ */
+
+import dashboardComponentsRegistry from '../visualizations/presets/dashboardComponents';
+import test from '../visualizations/dashboardComponents/TestComponent';
+
+export default function setupDashboardComponents() {
+  // TODO: can be removed after POC approved
+  dashboardComponentsRegistry.set('test', test);

Review comment:
       Let's disable this by default and move instructions for enabling this test component in the PR description (I assume the import also needs to be commented out).
   ```suggestion
     // Add custom dashboard components here. Example:
     // dashboardComponentsRegistry.set('test', test);
   ```
   

##########
File path: superset-frontend/src/visualizations/dashboardComponents/TestComponent/index.ts
##########
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// TODO: POC only component can be removed after PR approved
+export default {
+  metadata: {
+    name: 'Test',
+    description: 'Test description',
+    iconName: 'filter',
+  },
+  loadComponent: () => import('./TestComponent'),

Review comment:
       Should we rather call this an "Example component" to disambiguate from regular tests?




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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