You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "michael-s-molina (via GitHub)" <gi...@apache.org> on 2023/02/03 14:57:24 UTC

[GitHub] [superset] michael-s-molina commented on a diff in pull request #22982: fix: Prevents last temporal filter removal

michael-s-molina commented on code in PR #22982:
URL: https://github.com/apache/superset/pull/22982#discussion_r1095894048


##########
superset-frontend/src/explore/components/ControlPanelsContainer.tsx:
##########
@@ -482,28 +488,21 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
         : baseDescription;
 
     if (name === 'adhoc_filters') {
-      restProps.confirmDeletion = {
-        triggerCondition: (
-          valueToBeDeleted: Record<string, any>,
-          values: Record<string, any>[],
-        ) => {
-          const isTemporalRange = (filter: Record<string, any>) =>
-            filter.operator === Operators.TEMPORAL_RANGE;
-          if (isTemporalRange(valueToBeDeleted)) {
-            const count = values.filter(isTemporalRange).length;
-            if (count < 2) {
-              return true;
-            }
+      restProps.canDelete = (
+        valueToBeDeleted: Record<string, any>,
+        values: Record<string, any>[],
+      ) => {
+        const isTemporalRange = (filter: Record<string, any>) =>
+          filter.operator === Operators.TEMPORAL_RANGE;
+        if (isTemporalRange(valueToBeDeleted)) {
+          const count = values.filter(isTemporalRange).length;
+          if (count < 2) {

Review Comment:
   👍🏼 



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx:
##########
@@ -217,23 +213,16 @@ const DndFilterSelect = (props: DndFilterSelectProps) => {
 
   const onClickClose = useCallback(
     (index: number) => {
-      if (confirmDeletion) {
-        const { confirmationText, confirmationTitle, triggerCondition } =
-          confirmDeletion;
-        if (triggerCondition(values[index], values)) {
-          confirm({
-            title: confirmationTitle,
-            content: confirmationText,
-            onOk() {
-              removeValue(index);
-            },
-          });
+      if (canDelete) {
+        const result = canDelete(values[index], values);

Review Comment:
   👍🏼 



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