From 0b34799d32381e54897da4bac825901bff430165 Mon Sep 17 00:00:00 2001 From: David Griffon Date: Mon, 23 Sep 2024 10:32:03 +0200 Subject: [PATCH] QA-15281 : remove RXJS usage from design-system-kit (#277) --- packages/design-system-kit/package.json | 3 +- .../src/actions/DisplayAction.jsx | 42 ++----------------- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/packages/design-system-kit/package.json b/packages/design-system-kit/package.json index 9ef3abb6..fff5a260 100644 --- a/packages/design-system-kit/package.json +++ b/packages/design-system-kit/package.json @@ -22,8 +22,7 @@ "license": "MIT", "peerDependencies": { "@material-ui/core": "^3.9.3", - "react": "^16.8.0", - "rxjs": "^6.4.0" + "react": "^16.8.0" }, "dependencies": { "@material-ui/core": "^3.9.3", diff --git a/packages/design-system-kit/src/actions/DisplayAction.jsx b/packages/design-system-kit/src/actions/DisplayAction.jsx index 7df41f70..54fa58e7 100644 --- a/packages/design-system-kit/src/actions/DisplayAction.jsx +++ b/packages/design-system-kit/src/actions/DisplayAction.jsx @@ -2,8 +2,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import {actionsRegistry} from './actionsRegistry'; import * as _ from 'lodash'; -import {Observable, combineLatest, of} from 'rxjs'; -import {first} from 'rxjs/operators'; let count = 0; @@ -56,44 +54,12 @@ class DisplayActionComponent extends React.Component { subscription.unsubscribe(); } - let enhancedContext = {...context}; + const enhancedContext = {...context}; if (enhancedContext.init) { enhancedContext.init(enhancedContext, _.omit(this.props, ['context'])); } - // Check observers - const observersObj = _.pickBy(enhancedContext, value => value instanceof Observable); - const keys = Object.keys(observersObj); - - if (keys.length > 0) { - // Prepare an updateContext method for subscription - first set it as synchronous update of the context object - const update = v => { - if (this.innerRef.current) { - this.innerRef.current.setState(v); - } else { - enhancedContext = _.assign(enhancedContext, v); - } - }; - - // Concat with a sync observer to always get an initial value - const observers = Object.values(observersObj); - - keys.forEach(k => _.set(enhancedContext, k, null)); - - // Related to https://jira.jahia.org/browse/QA-11271 - // this empty subscription is auto cancelled with the first operator - // and resolve a problem where the observer was never resolved is some cases - _.each(observers, observer => observer.pipe(first()).subscribe()); - - // Combine all observers into one - const combinedObserver = combineLatest(...observers, (...vals) => _.zipObject(keys, vals)); - this.subscription = combinedObserver.subscribe(v => update(v)); - if (this.props.observerRef) { - this.props.observerRef(combinedObserver); - } - } else if (this.props.observerRef) { - this.props.observerRef(of(null)); - } + console.warn('Action won\'t be updated anymore, please use @jahia/ui-extender actions components instead'); return ; } @@ -111,13 +77,11 @@ class DisplayActionComponent extends React.Component { } DisplayActionComponent.defaultProps = { - observerRef: null }; DisplayActionComponent.propTypes = { context: PropTypes.object.isRequired, - render: PropTypes.func.isRequired, - observerRef: PropTypes.func + render: PropTypes.func.isRequired }; const shallowEquals = (obj1, obj2) =>