msyavuz commented on code in PR #36062:
URL: https://github.com/apache/superset/pull/36062#discussion_r2524016823
##########
superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts:
##########
@@ -80,6 +90,35 @@ export type Filter = {
description: string;
};
+export type ChartCustomization = {
+ id: string;
+ type: typeof ChartCustomizationType.ChartCustomization;
+ name: string;
+ filterType: string;
+ targets: [Partial<NativeFilterTarget>];
Review Comment:
Is this type correct? Is it really a single item in an array?
##########
superset-frontend/src/chartCustomizations/components/DynamicGroupBy/DynamicGroupByPlugin.tsx:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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 { ensureIsArray, ExtraFormData, t, tn } from '@superset-ui/core';
+import { useCallback, useEffect, useState } from 'react';
+import {
+ FormItem,
+ type FormItemProps,
+ Select,
+} from '@superset-ui/core/components';
+import { FilterPluginStyle, StatusMessage } from '../common';
+import { PluginFilterGroupByProps, ColumnOption, ColumnData } from './types';
+
+export default function PluginFilterDynamicGroupBy(
+ props: PluginFilterGroupByProps,
+) {
+ const {
+ data,
+ formData,
+ height,
+ width,
+ setDataMask,
+ setHoveredFilter,
+ unsetHoveredFilter,
+ setFocusedFilter,
+ unsetFocusedFilter,
+ setFilterActive,
+ filterState,
+ inputRef,
+ } = props;
+ const { defaultValue } = formData;
+
+ const [value, setValue] = useState<string[]>(
+ ensureIsArray<string>(defaultValue ?? []),
+ );
+
+ const handleChange = useCallback(
+ (values: string[] | string | undefined | null) => {
+ const resultValue: string[] = ensureIsArray<string>(values);
+
+ const extraFormData: ExtraFormData = {
+ custom_form_data: {
+ groupby: resultValue,
+ },
+ };
+
+ setValue(resultValue);
+ setDataMask({
+ extraFormData,
+ filterState: {
+ label: resultValue.join(', '),
+ value: resultValue.length ? resultValue : null,
+ },
+ });
+ },
+ [setDataMask],
+ );
+
+ useEffect(() => {
+ handleChange(defaultValue ?? []);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [JSON.stringify(defaultValue)]);
+
+ useEffect(() => {
+ handleChange(filterState.value ?? []);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [JSON.stringify(filterState.value)]);
Review Comment:
Can't we just include handleChange in the dependency array.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]