Skip to content

Commit

Permalink
v1.201.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
varovaro committed Feb 17, 2025
2 parents 8855ebe + 39b7686 commit 566f931
Show file tree
Hide file tree
Showing 188 changed files with 2,067 additions and 1,962 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ updates:
- dependency-name: '@typescript-eslint/parser'
- dependency-name: eslint #6784
- dependency-name: fetch-mock
- dependency-name: react-router-dom
- dependency-name: react-datepicker
- dependency-name: recharts
- dependency-name: '@headlessui/react'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_e2e_puppeteer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite-dir: ['regression_suites', 'suite1', 'suite2', 'mobile']
suite-dir: ['suite1', 'suite2', 'mobile']
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.7-amd64
Expand Down
2 changes: 1 addition & 1 deletion app/react/App/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-named-as-default */
import React, { useState, useMemo } from 'react';
import PropTypes from 'prop-types';
import { Outlet, useLocation, useParams } from 'react-router-dom';
import { Outlet, useLocation, useParams } from 'react-router';
import { useAtom } from 'jotai';
import Notifications from 'app/Notifications';
import Cookiepopup from 'app/App/Cookiepopup';
Expand Down
2 changes: 1 addition & 1 deletion app/react/App/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation } from 'react-router';
import { bindActionCreators, Dispatch } from 'redux';
import { connect, ConnectedProps } from 'react-redux';
import { fromJS } from 'immutable';
Expand Down
4 changes: 2 additions & 2 deletions app/react/App/specs/Menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { I18NLink } from 'app/I18N';
import { renderConnected } from 'app/utils/test/renderConnected';
import { Menu } from '../Menu';

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router', () => ({
...jest.requireActual('react-router'),
useLocation: () => ({
search: '?q=(searchTerm:%27asd%27)',
}),
Expand Down
17 changes: 14 additions & 3 deletions app/react/App/specs/Routes.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import { LibraryTable } from 'app/Library/LibraryTable';
import { PageView } from 'app/Pages/PageView';
import { ViewerRoute } from 'app/Viewer/ViewerRoute';
import { LibraryMap } from 'app/Library/LibraryMap';
import LibraryRoot from 'app/Library/Library';

let settings: ClientSettings;
let userId: string;

jest.mock('app/appRoutes');

describe('Routes', () => {
beforeEach(() => {
settings = { home_page: '', defaultLibraryView: 'table', private: false };
Expand Down Expand Up @@ -54,8 +57,12 @@ describe('Routes', () => {
"/library/map/?searchTerm:'mySearch',types:!('63f64f8bd793c9aae9925032')";
const { element, parameters } = getIndexElement(settings, undefined);
expect(parameters).toBeUndefined();
expect(element).toMatchObject(<LibraryMap />);
expect(element.props.params).toMatchObject({
expect(element).toMatchObject(
<LibraryRoot>
<LibraryMap />
</LibraryRoot>
);
expect(element.props.children.props.params).toMatchObject({
q: "(searchTerm:'mySearch',types:!('63f64f8bd793c9aae9925032'))",
});
});
Expand All @@ -76,7 +83,11 @@ describe('Routes', () => {
describe('no logged in user', () => {
it('should render the default library view', () => {
const { element, parameters } = getIndexElement(settings, undefined);
expect(element).toMatchObject(<LibraryTable />);
expect(element).toMatchObject(
<LibraryRoot>
<LibraryTable />
</LibraryRoot>
);
expect(parameters).toBeUndefined();
});
});
Expand Down
2 changes: 1 addition & 1 deletion app/react/Attachments/components/ViewDocumentLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Link, useLocation } from 'react-router';
import { CurrentLocationLink } from 'app/Layout';
import { EntitySchema } from 'shared/types/entityType';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import React from 'react';
import { shallow } from 'enzyme';

Expand All @@ -13,8 +13,8 @@ const mockUseLocation = jest.fn().mockImplementation(() => ({
pathname: `?page=${pathname}`,
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router', () => ({
...jest.requireActual('react-router'),
useLocation: () => mockUseLocation(),
}));
const renderComponent = (entity: EntitySchema) => {
Expand Down
3 changes: 2 additions & 1 deletion app/react/Entities/components/EntityViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { Helmet } from 'react-helmet';
import { sortBy } from 'lodash';
import PropTypes from 'prop-types';
import { Icon } from 'UI';
import { withContext, withRouter } from 'app/componentWrappers';
Expand Down Expand Up @@ -417,7 +418,7 @@ EntityViewer.propTypes = {

const selectRelationTypes = createSelector(
s => s.relationTypes,
r => r.toJS()
r => sortBy(r.toJS(), 'name')
);

const mapStateToProps = state => {
Expand Down
2 changes: 1 addition & 1 deletion app/react/Forms/components/MultiSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-classes-per-file */
/* eslint-disable class-methods-use-this,max-lines */

import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import ShowIf from 'app/App/ShowIf';
import { filterOptions } from 'shared/optionsUtils';
import { t, Translate } from 'app/I18N';
Expand Down
2 changes: 1 addition & 1 deletion app/react/I18N/I18NLinkV2.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { NavLinkProps, NavLink } from 'react-router';
import { useAtomValue } from 'jotai';
import { NavLinkProps, NavLink } from 'react-router-dom';
import { localeAtom } from 'V2/atoms';

type I18NLinkProps = NavLinkProps & { to: string; activeClassname?: string };
Expand Down
16 changes: 8 additions & 8 deletions app/react/I18N/components/I18NLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { useNavigate, NavLink, useLocation } from 'react-router-dom';
import { useNavigate, NavLink, useLocation } from 'react-router';
import { omit } from 'lodash';

const defaultProps = {
Expand Down Expand Up @@ -48,20 +48,20 @@ const I18NLink = (props: I18NLinkProps) => {
}, delay);
};

const _navigate = () => {
navigate(to, { replace });
const _navigate = async () => {
await navigate(to, { replace });
scrollToHashWithRetry(location.hash);
};

const onClickHandler = (e: { preventDefault: () => void }) => {
const onClickHandler = async (e: { preventDefault: () => void }) => {
e.preventDefault();
if (disabled) return;

if (onClick && confirmTitle) {
props.mainContext.confirm({
accept: () => {
accept: async () => {
onClick(e);
_navigate();
await _navigate();
},
title: confirmTitle,
message: confirmMessage,
Expand All @@ -71,10 +71,10 @@ const I18NLink = (props: I18NLinkProps) => {

if (onClick) {
onClick(e);
_navigate();
await _navigate();
return;
}
_navigate();
await _navigate();
};

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions app/react/I18N/components/I18NMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable react/no-multi-comp */
/* eslint-disable react-hooks/rules-of-hooks */
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Location, useLocation } from 'react-router-dom';
import { Location, useLocation } from 'react-router';
import { useAtom, useAtomValue } from 'jotai';
import { ChevronUpIcon, ChevronDownIcon } from '@heroicons/react/20/solid';
import { LanguagesListSchema } from 'shared/types/commonTypes';
import { NeedAuthorization } from 'V2/Components/UI';
import { Translate, t } from 'app/I18N';
import { useOnClickOutsideElement } from 'app/utils/useOnClickOutsideElementHook';
import { NeedAuthorization } from 'V2/Components/UI';
import { inlineEditAtom, localeAtom, settingsAtom, userAtom } from 'V2/atoms';
import { Translate, t } from 'app/I18N';

const locationSearch = (location: Location) => {
const cleanSearch = location.search.split(/page=\d+|&page=\d+/).join('');
Expand Down
2 changes: 1 addition & 1 deletion app/react/I18N/components/specs/I18NLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/* eslint-disable max-statements */
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router';
import { I18NLink } from '../I18NLink';
import { MemoryRouter, Route, Routes } from 'react-router-dom';

describe('I18NLink', () => {
let props;
Expand Down
2 changes: 1 addition & 1 deletion app/react/I18N/components/specs/I18NMenu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import { act, fireEvent, RenderResult, screen, render } from '@testing-library/react';
import { Location, MemoryRouter } from 'react-router-dom';
import { Location, MemoryRouter } from 'react-router';
import { createStore, Provider } from 'jotai';
import { ClientUserSchema } from 'app/apiResponseTypes';
import { inlineEditAtom, localeAtom, settingsAtom, userAtom } from 'V2/atoms';
Expand Down
2 changes: 1 addition & 1 deletion app/react/I18N/specs/I18NLinkV2.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react';
import { render, RenderResult } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router';
import { TestAtomStoreProvider } from 'V2/testing';
import { localeAtom } from 'V2/atoms';
import { I18NLink } from '../I18NLinkV2';
Expand Down
2 changes: 1 addition & 1 deletion app/react/Layout/CurrentLocationLink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link, useLocation } from 'react-router-dom';
import { Link, useLocation } from 'react-router';

const validProps = props => {
const { to, ...valid } = props;
Expand Down
2 changes: 1 addition & 1 deletion app/react/Layout/DocumentsList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-lines */
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { toUrlParams } from 'shared/JSONRequest';
import rison from 'rison-node';
import { SearchBar } from 'app/Library/components/SearchBar';
Expand Down
4 changes: 2 additions & 2 deletions app/react/Layout/specs/CurrentLocationLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { shallow } from 'enzyme';
import { CurrentLocationLink } from '../CurrentLocationLink';

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router', () => ({
...jest.requireActual('react-router'),
useLocation: () => ({ pathname: 'pathanem', search: 'param=value&param2=value2' }),
}));

Expand Down
80 changes: 48 additions & 32 deletions app/react/Library/Library.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React from 'react';
import { Outlet, matchPath } from 'react-router';
import RouteHandler from 'app/App/RouteHandler';
import { actions } from 'app/BasicReducer';
import { enterLibrary, unsetDocuments, zoomIn, zoomOut } from 'app/Library/actions/libraryActions';
import DocumentsList from 'app/Library/components/DocumentsList';
import { requestState } from 'app/Library/helpers/requestState';
import LibraryLayout from 'app/Library/LibraryLayout';
import { wrapDispatch } from 'app/Multireducer';
import { withRouter } from 'app/componentWrappers';
import { trackPage } from 'app/App/GoogleAnalytics';
import { routes as appRoutes } from 'app/appRoutes';

class Library extends RouteHandler {
class LibraryRootComponent extends RouteHandler {
constructor(props, context) {
super(props, context);
this.superComponentWillReceiveProps = super.componentWillReceiveProps;
Expand All @@ -22,26 +20,51 @@ class Library extends RouteHandler {
this.state = { scrollCount: 0 };
}

static async requestState(requestParams, globalResources) {
return requestState(requestParams, globalResources);
}

urlHasChanged(nextProps) {
const nextSearchParams = new URLSearchParams(nextProps.location.search);
const currentSearchParams = new URLSearchParams(this.props.location.search);
return nextSearchParams.get('q') !== currentSearchParams.get('q');
}

componentWillUnmount() {
this.emptyState();
}

componentDidUpdate(prevProps) {
if (this.urlHasChanged(prevProps)) {
this.getClientState(this.props);
}
}

findMatchingRoute = (pathname, routes, parentPath = '') => {
let result = null;

routes.every(route => {
if (result !== null) {
return false;
}

const currentPath = `${parentPath}/${route.path || ''}`.replace('//', '/');
const match = matchPath({ path: currentPath, end: false }, pathname);

if (match) {
if (currentPath === pathname && route.handle?.library) result = route;

if (route.children) {
const childMatch = this.findMatchingRoute(pathname, route.children, currentPath);
if (childMatch) result = childMatch;
}
}
return true;
});

return result;
};

componentWillUnmount() {
const nextLocation = window?.location?.pathname;
const matchedRoute = this.findMatchingRoute(nextLocation, appRoutes);
if (!matchedRoute && !nextLocation.includes('library')) {
this.emptyState();
}
}

emptyState() {
wrapDispatch(this.context.store.dispatch, 'library')(unsetDocuments());
actions.set('library.sidepanel.quickLabelState', {});
Expand All @@ -56,26 +79,19 @@ class Library extends RouteHandler {
}

render() {
trackPage();
return (
<LibraryLayout
sidePanelMode={this.props.sidePanelMode}
scrollCallback={this.scrollCallback}
scrollCount={this.state.scrollCount}
>
<DocumentsList
storeKey="library"
CollectionViewer={this.props.viewer}
zoomIn={this.zoomIn}
zoomOut={this.zoomOut}
scrollCount={this.state.scrollCount}
/>
</LibraryLayout>
);
if (this.props.children) {
return this.props.children;
}

return <Outlet />;
}
}

const SSRLibrary = withRouter(Library);
const SSRLibrary = withRouter(LibraryRootComponent);

export const LibraryRoot = Object.assign(SSRLibrary, {
requestState: LibraryRootComponent.requestState,
});

export const LibraryCards = Object.assign(SSRLibrary, { requestState: Library.requestState });
export default Library;
export { LibraryRootComponent };
export default LibraryRoot;
Loading

0 comments on commit 566f931

Please sign in to comment.