From 3cd5f108b1689a62a53c1b2ed9f77a18fc601e1d Mon Sep 17 00:00:00 2001
From: Mauro Amico <mauro.amico@gmail.com>
Date: Tue, 1 Oct 2024 09:38:07 +0200
Subject: [PATCH] fix: bug related to svg in cardreadmore

---
 .../Listing/CardWithSlideUpTextTemplate.jsx   |   8 +-
 .../components/theme/View/disabled_View.jsx   | 308 ------------------
 .../volto/helpers/Api/disabled_Api.js         | 131 --------
 3 files changed, 7 insertions(+), 440 deletions(-)
 delete mode 100644 src/customizations/volto/components/theme/View/disabled_View.jsx
 delete mode 100644 src/customizations/volto/helpers/Api/disabled_Api.js

diff --git a/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx b/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx
index b97a6f49b..7848d9ed2 100644
--- a/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx
+++ b/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx
@@ -76,8 +76,14 @@ const CardWithSlideUpTextTemplate = (props) => {
                     <p>{item.description}</p>
                   )}
                   <div className="read-more">
+                    {/*
+                    because of https://developer.chrome.com/blog/migrate-way-from-data-urls-in-svg-use
+                    current implementation of Icon in CardReadMore component is not working.
+                    we disable it for now.
+                    iconName="it-arrow-right"
+                    */}
                     <CardReadMore
-                      iconName="it-arrow-right"
+                      iconName={false}
                       tag={UniversalLink}
                       item={!isEditMode ? item : null}
                       href={isEditMode ? '#' : null}
diff --git a/src/customizations/volto/components/theme/View/disabled_View.jsx b/src/customizations/volto/components/theme/View/disabled_View.jsx
deleted file mode 100644
index bb7180db7..000000000
--- a/src/customizations/volto/components/theme/View/disabled_View.jsx
+++ /dev/null
@@ -1,308 +0,0 @@
-/**
- * backport https://github.com/plone/volto/pull/4854
- *
- * View container.
- * @module components/theme/View/View
- */
-
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import { compose } from 'redux';
-import { Redirect } from 'react-router-dom';
-import { Portal } from 'react-portal';
-import { injectIntl } from 'react-intl';
-import qs from 'query-string';
-
-import {
-  ContentMetadataTags,
-  Comments,
-  Tags,
-  Toolbar,
-} from '@plone/volto/components';
-import { listActions, getContent } from '@plone/volto/actions';
-import {
-  BodyClass,
-  getBaseUrl,
-  flattenToAppURL,
-  getLayoutFieldname,
-  hasApiExpander,
-} from '@plone/volto/helpers';
-
-import config from '@plone/volto/registry';
-
-/**
- * View container class.
- * @class View
- * @extends Component
- */
-class View extends Component {
-  /**
-   * Property types.
-   * @property {Object} propTypes Property types.
-   * @static
-   */
-  static propTypes = {
-    actions: PropTypes.shape({
-      object: PropTypes.arrayOf(PropTypes.object),
-      object_buttons: PropTypes.arrayOf(PropTypes.object),
-      user: PropTypes.arrayOf(PropTypes.object),
-    }),
-    listActions: PropTypes.func.isRequired,
-    /**
-     * Action to get the content
-     */
-    getContent: PropTypes.func.isRequired,
-    /**
-     * Pathname of the object
-     */
-    pathname: PropTypes.string.isRequired,
-    location: PropTypes.shape({
-      search: PropTypes.string,
-      pathname: PropTypes.string,
-    }).isRequired,
-    /**
-     * Version id of the object
-     */
-    versionId: PropTypes.string,
-    /**
-     * Content of the object
-     */
-    content: PropTypes.shape({
-      /**
-       * Layout of the object
-       */
-      layout: PropTypes.string,
-      /**
-       * Allow discussion of the object
-       */
-      allow_discussion: PropTypes.bool,
-      /**
-       * Title of the object
-       */
-      title: PropTypes.string,
-      /**
-       * Description of the object
-       */
-      description: PropTypes.string,
-      /**
-       * Type of the object
-       */
-      '@type': PropTypes.string,
-      /**
-       * Subjects of the object
-       */
-      subjects: PropTypes.arrayOf(PropTypes.string),
-      is_folderish: PropTypes.bool,
-    }),
-    error: PropTypes.shape({
-      /**
-       * Error type
-       */
-      status: PropTypes.number,
-    }),
-  };
-
-  /**
-   * Default properties.
-   * @property {Object} defaultProps Default properties.
-   * @static
-   */
-  static defaultProps = {
-    actions: null,
-    content: null,
-    versionId: null,
-    error: null,
-  };
-
-  state = {
-    hasObjectButtons: null,
-    isClient: false,
-  };
-
-  componentDidMount() {
-    // Do not trigger the actions action if the expander is present
-    if (!hasApiExpander('actions', getBaseUrl(this.props.pathname))) {
-      this.props.listActions(getBaseUrl(this.props.pathname));
-    }
-    this.props.getContent(
-      getBaseUrl(this.props.pathname),
-      this.props.versionId,
-    );
-    this.setState({ isClient: true });
-  }
-
-  /**
-   * Component will receive props
-   * @method componentWillReceiveProps
-   * @param {Object} nextProps Next properties
-   * @returns {undefined}
-   */
-  UNSAFE_componentWillReceiveProps(nextProps) {
-    if (nextProps.pathname !== this.props.pathname) {
-      // Do not trigger the actions action if the expander is present
-      if (!hasApiExpander('actions', getBaseUrl(nextProps.pathname))) {
-        this.props.listActions(getBaseUrl(nextProps.pathname));
-      }
-      this.props.getContent(
-        getBaseUrl(nextProps.pathname),
-        this.props.versionId,
-      );
-    }
-
-    if (nextProps.actions.object_buttons) {
-      const objectButtons = nextProps.actions.object_buttons;
-      this.setState({
-        hasObjectButtons: !!objectButtons.length,
-      });
-    }
-  }
-
-  /**
-   * Default fallback view
-   * @method getViewDefault
-   * @returns {string} Markup for component.
-   */
-  getViewDefault = () => config.views.defaultView;
-
-  /**
-   * Get view by content type
-   * @method getViewByType
-   * @returns {string} Markup for component.
-   */
-  getViewByType = () =>
-    config.views.contentTypesViews[this.props.content['@type']] || null;
-
-  /**
-   * Get view by content layout property
-   * @method getViewByLayout
-   * @returns {string} Markup for component.
-   */
-  getViewByLayout = () =>
-    config.views.layoutViews[
-      this.props.content[getLayoutFieldname(this.props.content)]
-    ] || null;
-
-  /**
-   * Cleans the component displayName (specially for connected components)
-   * which have the Connect(componentDisplayName)
-   * @method cleanViewName
-   * @param  {string} dirtyDisplayName The displayName
-   * @returns {string} Clean displayName (no Connect(...)).
-   */
-  cleanViewName = (dirtyDisplayName) =>
-    dirtyDisplayName
-      .replace('Connect(', '')
-      .replace('injectIntl(', '')
-      .replace(')', '')
-      .replace('connect(', '')
-      .toLowerCase();
-
-  /**
-   * Render method.
-   * @method render
-   * @returns {string} Markup for the component.
-   */
-  render() {
-    const { views } = config;
-    const status = __SERVER__
-      ? this.props.error?.status
-      : this.props.error?.code;
-    // Checking to see if it's a 3XX HTTP status code. error.status only works on the server
-    if (['301', '302', '307', '308'].includes(status?.toString())) {
-      const redirectUrl = __SERVER__
-        ? this.props.error.response.headers.location
-        : this.props.error.url;
-      let redirect = flattenToAppURL(redirectUrl);
-      // We can hit situations where we end up being redirected to an api route. We don't want that so lets remove ++api++.
-      redirect = redirect.replace('/++api++', '').replace(/\?.*/, '');
-      return <Redirect to={`${redirect}${this.props.location.search}`} />;
-    } else if (this.props.error && !this.props.connectionRefused) {
-      let FoundView;
-      if (this.props.error.status === undefined) {
-        // For some reason, while development and if CORS is in place and the
-        // requested resource is 404, it returns undefined as status, then the
-        // next statement will fail
-        FoundView = views.errorViews.corsError;
-      } else {
-        FoundView = views.errorViews[this.props.error.status.toString()];
-      }
-      if (!FoundView) {
-        FoundView = views.errorViews['404']; // default to 404
-      }
-      return (
-        <div id="view">
-          <FoundView {...this.props} />
-        </div>
-      );
-    }
-    if (!this.props.content) {
-      return <span />;
-    }
-    const RenderedView =
-      this.getViewByLayout() || this.getViewByType() || this.getViewDefault();
-
-    return (
-      <div id="view">
-        <ContentMetadataTags content={this.props.content} />
-        {/* Body class if displayName in component is set */}
-        <BodyClass
-          className={
-            RenderedView.displayName
-              ? `view-${this.cleanViewName(RenderedView.displayName)}`
-              : null
-          }
-        />
-        <RenderedView
-          key={this.props.content['@id']}
-          content={this.props.content}
-          location={this.props.location}
-          token={this.props.token}
-          history={this.props.history}
-        />
-        {config.settings.showTags &&
-          this.props.content.subjects &&
-          this.props.content.subjects.length > 0 && (
-            <Tags tags={this.props.content.subjects} />
-          )}
-        {/* Add opt-in social sharing if required, disabled by default */}
-        {/* In the future this might be parameterized from the app config */}
-        {/* <SocialSharing
-          url={typeof window === 'undefined' ? '' : window.location.href}
-          title={this.props.content.title}
-          description={this.props.content.description || ''}
-        /> */}
-        {this.props.content.allow_discussion && (
-          <Comments pathname={this.props.pathname} />
-        )}
-        {this.state.isClient && (
-          <Portal node={document.getElementById('toolbar')}>
-            <Toolbar pathname={this.props.pathname} inner={<span />} />
-          </Portal>
-        )}
-      </div>
-    );
-  }
-}
-
-export default compose(
-  injectIntl,
-  connect(
-    (state, props) => ({
-      actions: state.actions.actions,
-      token: state.userSession.token,
-      content: state.content.data,
-      error: state.content.get.error,
-      apiError: state.apierror.error,
-      connectionRefused: state.apierror.connectionRefused,
-      pathname: props.location.pathname,
-      versionId:
-        qs.parse(props.location.search) &&
-        qs.parse(props.location.search).version,
-    }),
-    {
-      listActions,
-      getContent,
-    },
-  ),
-)(View);
diff --git a/src/customizations/volto/helpers/Api/disabled_Api.js b/src/customizations/volto/helpers/Api/disabled_Api.js
deleted file mode 100644
index 22e8db4ce..000000000
--- a/src/customizations/volto/helpers/Api/disabled_Api.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * backport https://github.com/plone/volto/pull/4854
- *
- * Api helper.
- * @module helpers/Api
- */
-
-import superagent from 'superagent';
-import Cookies from 'universal-cookie';
-import config from '@plone/volto/registry';
-import { addHeadersFactory } from '@plone/volto/helpers/Proxy/Proxy';
-import { stripQuerystring } from '@plone/volto/helpers';
-
-const methods = ['get', 'post', 'put', 'patch', 'del'];
-
-/**
- * Format the url.
- * @function formatUrl
- * @param {string} path Path (or URL) to be formatted.
- * @returns {string} Formatted path.
- */
-function formatUrl(path) {
-  const { settings } = config;
-  const APISUFIX = settings.legacyTraverse ? '' : '/++api++';
-
-  if (path.startsWith('http://') || path.startsWith('https://')) return path;
-
-  const adjustedPath = path[0] !== '/' ? `/${path}` : path;
-  let apiPath = '';
-  if (settings.internalApiPath && __SERVER__) {
-    apiPath = settings.internalApiPath;
-  } else if (settings.apiPath) {
-    apiPath = settings.apiPath;
-  }
-
-  return `${apiPath}${APISUFIX}${adjustedPath}`;
-}
-
-/**
- * Api class.
- * @class Api
- */
-class Api {
-  /**
-   * Constructor
-   * @method constructor
-   * @constructs Api
-   */
-  constructor(req) {
-    const cookies = new Cookies();
-
-    methods.forEach((method) => {
-      this[method] = (
-        path,
-        { params, data, type, headers = {}, checkUrl = false } = {},
-      ) => {
-        let request;
-        let promise = new Promise((resolve, reject) => {
-          request = superagent[method](formatUrl(path));
-
-          if (params) {
-            request.query(params);
-          }
-
-          let authToken;
-          if (req) {
-            // We are in SSR
-            authToken = req.universalCookies.get('auth_token');
-            request.use(addHeadersFactory(req));
-          } else {
-            authToken = cookies.get('auth_token');
-          }
-          if (authToken) {
-            request.set('Authorization', `Bearer ${authToken}`);
-          }
-
-          request.set('Accept', 'application/json');
-
-          if (type) {
-            request.type(type);
-          }
-
-          Object.keys(headers).forEach((key) => request.set(key, headers[key]));
-
-          if (__SERVER__ && checkUrl && ['get', 'head'].includes(method)) {
-            request.redirects(0);
-          }
-
-          if (data) {
-            request.send(data);
-          }
-
-          request.end((err, response) => {
-            if (
-              checkUrl &&
-              request.url &&
-              request.xhr &&
-              encodeURI(stripQuerystring(request.url)) !==
-                stripQuerystring(request.xhr.responseURL)
-            ) {
-              if (request.xhr.responseURL?.length === 0) {
-                return reject({
-                  code: 408,
-                  status: 408,
-                  url: request.xhr.responseURL,
-                });
-              }
-              return reject({
-                code: 301,
-                url: request.xhr.responseURL,
-              });
-            }
-
-            if (['301', '302', '307', '308'].includes(err?.status?.toString())) {
-              return reject({
-                code: err.status,
-                url: err.response.headers.location,
-              });
-            }
-
-            return err ? reject(err) : resolve(response.body || response.text);
-          });
-        });
-        promise.request = request;
-        return promise;
-      };
-    });
-  }
-}
-
-export default Api;