michael-s-molina commented on a change in pull request #18793:
URL: https://github.com/apache/superset/pull/18793#discussion_r810064693
##########
File path:
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts
##########
@@ -25,40 +25,48 @@ import {
FilterConfiguration,
NativeFilterType,
Divider,
- t,
NativeFilterTarget,
+ logging,
} from '@superset-ui/core';
+import { isEqual } from 'lodash';
import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants';
-import {
- FilterRemoval,
- NativeFiltersForm,
- FilterHierarchy,
- FilterHierarchyNode,
-} from './types';
+import { FilterRemoval, NativeFiltersForm } from './types';
export const REMOVAL_DELAY_SECS = 5;
+export const hasCircularDependency = (
+ form: FormInstance<NativeFiltersForm>,
+ filterConfigMap: Record<string, Filter | Divider>,
+ filterId: string,
+ trace: string[] = [],
+) => {
+ if (trace.includes(filterId)) {
+ return true;
+ }
+ const formItem = form.getFieldValue('filters')?.[filterId];
+ const configItem = filterConfigMap[filterId];
+ const dependencies: string[] = formItem
+ ? 'dependencies' in formItem && formItem.dependencies
+ : 'cascadeParentIds' in configItem && configItem?.cascadeParentIds;
+
+ if (dependencies) {
+ let result = false;
+ dependencies.forEach(dependency => {
+ result ||= hasCircularDependency(form, filterConfigMap, dependency, [
Review comment:
Great tip!
--
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]