Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Browse files Browse the repository at this point in the history
…4850/add-graceful-shutdown-to-worker
  • Loading branch information
Joao-vi committed Oct 24, 2024
2 parents 8df7ff1 + e3368a9 commit 29750d0
Show file tree
Hide file tree
Showing 41 changed files with 1,012 additions and 197 deletions.
16 changes: 9 additions & 7 deletions app/react/App/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* 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 { useSetAtom } from 'jotai';
import { useAtom } from 'jotai';
import Notifications from 'app/Notifications';
import Cookiepopup from 'app/App/Cookiepopup';
import { TranslateForm, t } from 'app/I18N';
import { Icon } from 'UI';
import { socket } from 'app/socket';
import { NotificationsContainer } from 'V2/Components/UI';
import { Matomo } from 'app/V2/Components/Analitycs';
import { Matomo, CleanInsights } from 'app/V2/Components/Analitycs';
import { settingsAtom } from 'V2/atoms/settingsAtom';
import Confirm from './Confirm';
import { Menu } from './Menu';
import { AppMainContext } from './AppMainContext';
import SiteName from './SiteName';
import GoogleAnalytics from './GoogleAnalytics';
import { CleanInsights } from 'app/V2/Components/Analitycs';
import 'react-widgets/dist/css/react-widgets.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'nprogress/nprogress.css';
Expand All @@ -27,13 +27,15 @@ import 'flowbite';
const App = ({ customParams }) => {
const [showMenu, setShowMenu] = useState(false);
const [confirmOptions, setConfirmOptions] = useState({});
const setSettings = useSetAtom(settingsAtom);
const [settings, setSettings] = useAtom(settingsAtom);

const location = useLocation();
const params = useParams();
const sharedId = params.sharedId || customParams?.sharedId;

const possibleLanguages = settings.languages?.map(l => l.key) || [];
const shouldAddAppClassName =
['/', `/${params.lang}/`].includes(location.pathname) ||
['/', ...possibleLanguages.map(lang => `/${lang}/`)].includes(location.pathname) ||
location.pathname.match(/\/page\/.*\/.*/g) ||
location.pathname.match(/\/entity\/.*/g);

Expand All @@ -58,8 +60,8 @@ const App = ({ customParams }) => {

const appClassName = shouldAddAppClassName && sharedId ? `pageId_${sharedId}` : '';

socket.on('updateSettings', settings => {
setSettings(settings);
socket.on('updateSettings', _settings => {
setSettings(_settings);
});

return (
Expand Down
29 changes: 29 additions & 0 deletions app/react/App/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,13 @@ input[type="range"]::-ms-fill-lower {
margin-top: 1.5rem;
}

.line-clamp-2 {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}

.block {
display: block;
}
Expand Down Expand Up @@ -1867,6 +1874,16 @@ input[type="range"]::-ms-fill-lower {
display: none;
}

.size-\[20px\] {
width: 20px;
height: 20px;
}

.size-\[28px\] {
width: 28px;
height: 28px;
}

.h-10 {
height: 2.5rem;
}
Expand Down Expand Up @@ -2133,6 +2150,10 @@ input[type="range"]::-ms-fill-lower {
width: 75%;
}

.w-\[105px\] {
width: 105px;
}

.w-\[17px\] {
width: 17px;
}
Expand All @@ -2159,6 +2180,14 @@ input[type="range"]::-ms-fill-lower {
width: max-content;
}

.w-\[120px\] {
width: 120px;
}

.w-5\/6 {
width: 83.333333%;
}

.min-w-20 {
min-width: 5rem;
}
Expand Down
2 changes: 1 addition & 1 deletion app/react/Documents/components/DocumentSidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ DocumentSidePanel.propTypes = {
search: PropTypes.string,
}).isRequired,
navigate: PropTypes.func.isRequired,
selectedDocument: PropTypes.instanceOf(Immutable),
selectedDocument: PropTypes.instanceOf(Immutable.Map),
// relationships v2
newRelationshipsEnabled: PropTypes.bool,
};
Expand Down
33 changes: 28 additions & 5 deletions app/react/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ import {
ParagraphExtractorDashboard,
ParagraphExtractorLoader,
} from 'app/V2/Routes/Settings/ParagraphExtraction/ParagraphExtraction';
import {
PXEntityDashboard,
PXEntityLoader,
} from 'app/V2/Routes/Settings/ParagraphExtraction/PXEntities';
import {
PXParagraphDashboard,
PXParagraphLoader,
} from 'app/V2/Routes/Settings/ParagraphExtraction/PXParagraphs';
import {
loggedInUsersRoute,
adminsOnlyRoute,
Expand Down Expand Up @@ -142,12 +150,22 @@ const getRoutesLayout = (
}
/>
</Route>
<Route path="paragraph_extraction">
<Route path="paragraph-extraction">
<Route
loader={ParagraphExtractorLoader(headers)}
index
element={adminsOnlyRoute(<ParagraphExtractorDashboard />)}
/>
<Route
loader={PXEntityLoader(headers)}
path=":extractorId/entities"
element={adminsOnlyRoute(<PXEntityDashboard />)}
/>
<Route
loader={PXParagraphLoader(headers)}
path=":extractorId/entities/:entityId/paragraphs"
element={adminsOnlyRoute(<PXParagraphDashboard />)}
/>
</Route>
<Route path="relationship-types">
<Route
Expand Down Expand Up @@ -214,20 +232,25 @@ const getRoutesLayout = (
</Route>
);

const languageLayout = (langKey: string, layout: React.JSX.Element) => (
<Route key={langKey} path={langKey}>
{layout}
<Route path="*" element={<GeneralError />} />
</Route>
);

const getRoutes = (
settings: ClientSettings | undefined,
userId: string | undefined,
headers?: IncomingHttpHeaders
) => {
const { element, parameters } = getIndexElement(settings, userId);
const layout = getRoutesLayout(settings, element, headers);
const languageKeys = settings?.languages?.map(lang => lang.key) || [];
return createRoutesFromElements(
<Route path="/" element={<App customParams={parameters} />}>
{layout}
<Route path="/:lang">
{layout}
<Route path="*" element={<GeneralError />} />
</Route>
{languageKeys.map(langKey => languageLayout(langKey, layout))}
<Route path="*" element={<GeneralError />} />
</Route>
);
Expand Down
2 changes: 1 addition & 1 deletion app/react/Settings/components/SettingsNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const SettingsNavigationComponent = ({ allowcustomJS }: { allowcustomJS: boolean
<FeatureToggle feature="paragraphExtraction">
<NeedAuthorization roles={['admin', 'editor']}>
<I18NLink
to="settings/paragraph_extraction"
to="settings/paragraph-extraction"
activeclassname="active"
className="list-group-item"
>
Expand Down
1 change: 0 additions & 1 deletion app/react/V2/Components/Forms/specs/MultiselectList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ describe('MultiselectList.cy.tsx', () => {
});
});

// add blank state test
describe('blank state property', () => {
it('should show blank state property if there is no items passed to the component', () => {
cy.viewport(450, 650);
Expand Down
18 changes: 9 additions & 9 deletions app/react/V2/Routes/Settings/Pages/PageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const pageEditorLoader =
(headers?: IncomingHttpHeaders): LoaderFunction =>
async ({ params }) => {
if (params.sharedId) {
const page = await pagesAPI.getBySharedId(params.sharedId, params.lang || 'en', headers);
const page = await pagesAPI.getBySharedId(params.sharedId, headers);

return page;
}
Expand Down Expand Up @@ -136,8 +136,8 @@ const PageEditor = () => {
<Tabs.Tab id="Basic" label={<Translate>Basic</Translate>}>
<form>
<input className="hidden" {...register('sharedId')} />
<div className="flex flex-col gap-4 max-w-2xl">
<div className="flex gap-4 items-center">
<div className="flex flex-col max-w-2xl gap-4">
<div className="flex items-center gap-4">
<Translate className="font-bold">
Enable this page to be used as an entity view page:
</Translate>
Expand All @@ -162,7 +162,7 @@ const PageEditor = () => {
: ''
}
label={<Translate>URL</Translate>}
className="mb-4 w-full"
className="w-full mb-4"
id="page-url"
/>

Expand All @@ -184,9 +184,9 @@ const PageEditor = () => {
</Tabs.Tab>

<Tabs.Tab id="Code" key="html" label={<Translate>Markdown</Translate>}>
<div className="flex flex-col gap-2 h-full">
<div className="flex flex-col h-full gap-2">
<HTMLNotification />
<div className="pt-2 h-full">
<div className="h-full pt-2">
<CodeEditor
language="html"
intialValue={page.metadata?.content}
Expand All @@ -206,9 +206,9 @@ const PageEditor = () => {
</Tabs.Tab>

<Tabs.Tab id="Advanced" label={<Translate>Javascript</Translate>}>
<div className="flex flex-col gap-2 h-full">
<div className="flex flex-col h-full gap-2">
<JSNotification />
<div className="pt-2 h-full">
<div className="h-full pt-2">
<CodeEditor
language="javascript"
intialValue={page.metadata?.script}
Expand All @@ -230,7 +230,7 @@ const PageEditor = () => {
</SettingsContent.Body>

<SettingsContent.Footer>
<div className="flex gap-2 justify-end">
<div className="flex justify-end gap-2">
<Link to="/settings/pages">
<Button styling="light" disabled={isSubmitting}>
<Translate>Cancel</Translate>
Expand Down
11 changes: 5 additions & 6 deletions app/react/V2/Routes/Settings/Pages/PagesList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/no-multi-comp */
import React, { useState } from 'react';
import { Link, LoaderFunction, useLoaderData, useParams, useRevalidator } from 'react-router-dom';
import { Link, LoaderFunction, useLoaderData, useRevalidator } from 'react-router-dom';
import { createColumnHelper } from '@tanstack/react-table';
import { IncomingHttpHeaders } from 'http';
import { useSetAtom } from 'jotai';
Expand All @@ -26,8 +26,8 @@ type TablePage = Page & { rowId: string };

const pagesListLoader =
(headers?: IncomingHttpHeaders): LoaderFunction =>
async ({ params }) =>
(await pagesAPI.get(params.lang || 'en', headers)).map(page => ({ ...page, rowId: page._id }));
async () =>
(await pagesAPI.get(headers)).map(page => ({ ...page, rowId: page._id }));

const deletionNotification: (hasErrors: boolean) => notificationAtomType = hasErrors => ({
type: !hasErrors ? 'success' : 'error',
Expand All @@ -45,7 +45,6 @@ const PagesList = () => {
const [showModal, setShowModal] = useState(false);
const pages = useLoaderData() as TablePage[];
const revalidator = useRevalidator();
const params = useParams();
const setNotifications = useSetAtom(notificationAtom);

const deleteSelected = async () => {
Expand Down Expand Up @@ -112,7 +111,7 @@ const PagesList = () => {
</SettingsContent.Body>
<SettingsContent.Footer className={selectedPages.length ? 'bg-primary-50' : ''}>
{selectedPages.length > 0 && (
<div className="flex gap-2 items-center">
<div className="flex items-center gap-2">
<Button
type="button"
onClick={confirmDeletion}
Expand All @@ -128,7 +127,7 @@ const PagesList = () => {
{selectedPages.length === 0 && (
<div className="flex justify-between w-full">
<div className="flex gap-2">
<Link to={`/${params.lang || 'en'}/settings/pages/page`}>
<Link to="/settings/pages/page">
<Button styling="solid" color="primary" type="button">
<Translate>Add page</Translate>
</Button>
Expand Down
12 changes: 4 additions & 8 deletions app/react/V2/Routes/Settings/Pages/components/PageListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ const ActionCell = ({ cell }: CellContext<TablePage, string>) => {
const isEntityView = cell.row.original.entityView;

return (
<div className="flex gap-2 justify-end">
<Link
to={`/${cell.row.original.language}/${pageUrl}`}
target="_blank"
aria-disabled={isEntityView}
>
<div className="flex justify-end gap-2">
<Link to={`/${pageUrl}`} target="_blank" aria-disabled={isEntityView}>
<Button styling="light" disabled={isEntityView}>
<Translate>View</Translate>
</Button>
</Link>
<Link to={`/${cell.row.original.language}/settings/pages/page/${cell.getValue()}`}>
<Link to={`/settings/pages/page/${cell.getValue()}`}>
<Button styling="light">
<Translate>Edit</Translate>
</Button>
Expand All @@ -54,7 +50,7 @@ const UrlCell = ({ cell }: CellContext<TablePage, string>) => {
};

const List = ({ items }: { items: TablePage[] }) => (
<ul className="flex flex-wrap gap-8 max-w-md list-disc list-inside">
<ul className="flex flex-wrap max-w-md gap-8 list-disc list-inside">
{items.map(item => (
<li key={item._id}>{item.title}</li>
))}
Expand Down
Loading

0 comments on commit 29750d0

Please sign in to comment.