You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2021/10/27 21:17:00 UTC
[superset] 02/02: chore(Dashboard): Disable save button in Native
Filters when an error is present (#17037)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch 1.4
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 5d43a5926cdae83a045d7be495dc7546246cda04
Author: Geido <60...@users.noreply.github.com>
AuthorDate: Thu Oct 21 16:43:58 2021 +0300
chore(Dashboard): Disable save button in Native Filters when an error is present (#17037)
* Disable save on error
* Remove removed erroredFilter
* Fix cdisabled check
---
.../FiltersConfigModal/FiltersConfigModal.tsx | 20 ++++++++++++++++----
.../FiltersConfigModal/Footer/Footer.tsx | 3 +++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.tsx
index 0709d8d..61788cf 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigModal.tsx
@@ -16,10 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React, { useCallback, useMemo, useState, useRef } from 'react';
-import { uniq, debounce, isEqual, sortBy } from 'lodash';
-import { t, styled } from '@superset-ui/core';
-import { SLOW_DEBOUNCE } from 'src/constants';
+import React, {
+ useEffect,
+ useCallback,
+ useMemo,
+ useState,
+ useRef,
+} from 'react';
+import { uniq, isEqual, sortBy, debounce } from 'lodash';
+import { t, styled, SLOW_DEBOUNCE } from '@superset-ui/core';
import { Form } from 'src/common/components';
import { StyledModal } from 'src/components/Modal';
import ErrorBoundary from 'src/components/ErrorBoundary';
@@ -305,6 +310,12 @@ export function FiltersConfigModal({
[handleErroredFilters],
);
+ useEffect(() => {
+ setErroredFilters(prevErroredFilters =>
+ prevErroredFilters.filter(f => !removedFilters[f]),
+ );
+ }, [removedFilters]);
+
return (
<StyledModalWrapper
visible={isOpen}
@@ -321,6 +332,7 @@ export function FiltersConfigModal({
onDismiss={() => setSaveAlertVisible(false)}
onCancel={handleCancel}
handleSave={handleSave}
+ canSave={!erroredFilters.length}
saveAlertVisible={saveAlertVisible}
onConfirmCancel={handleConfirmCancel}
/>
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/Footer/Footer.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/Footer/Footer.tsx
index a55a87c..4c2f774 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/Footer/Footer.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/Footer/Footer.tsx
@@ -27,9 +27,11 @@ type FooterProps = {
onConfirmCancel: OnClickHandler;
onDismiss: OnClickHandler;
saveAlertVisible: boolean;
+ canSave?: boolean;
};
const Footer: FC<FooterProps> = ({
+ canSave = true,
onCancel,
handleSave,
onDismiss,
@@ -60,6 +62,7 @@ const Footer: FC<FooterProps> = ({
{t('Cancel')}
</Button>
<Button
+ disabled={!canSave}
key="submit"
buttonStyle="primary"
onClick={handleSave}