Skip to content

Commit

Permalink
v1.157.0
Browse files Browse the repository at this point in the history
  • Loading branch information
varovaro committed Mar 11, 2024
2 parents ec6eca7 + 82daa32 commit 45b5f8d
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 143 deletions.
1 change: 1 addition & 0 deletions app/api/activitylog/activitylogMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const BODY_REQUIRED_ENDPOINTS = [
'/api/files/upload/custom',
'/api/attachments/upload',
'/api/public',
'/api/entities',
];

function mustBeLogged(baseurl: string, method: string, body: { [k: string]: any }) {
Expand Down
4 changes: 4 additions & 0 deletions app/api/activitylog/activitylogParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const entryValues: { [key: string]: EntryValue } = {
method: Methods.Create,
idField: 'sharedId',
nameField: 'title',
nameFunc: data => {
const body = data.entity ? JSON.parse(data.entity) : data;
return body.sharedId ? `${body.title} (${body.sharedId})` : body.title;
},
related: helpers.loadTemplate,
extra: helpers.extraTemplate,
},
Expand Down
9 changes: 8 additions & 1 deletion app/api/activitylog/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ const loadEntityFromPublicForm = async data => {
};

const loadTemplate = async data => {
const templateData = await templates.getById(data.template || data._id);
let templateId = data.template || data._id;

if (data.entity) {
const entity = JSON.parse(data.entity);
templateId = entity.template;
}

const templateData = await templates.getById(templateId);
return { ...data, templateData };
};

Expand Down
16 changes: 16 additions & 0 deletions app/api/activitylog/specs/activitylogParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ describe('Activitylog Parser', () => {

describe('routes: /api/entities and /api/documents', () => {
describe('method: POST', () => {
it('should beautify with body when it is a multipart request', async () => {
await testBeautified(
{
method: 'POST',
url: '/api/entities',
body: `{"entity":${JSON.stringify(`{"title":"New Entity","template":"${firstTemplate.toString()}"}`)}}`,
},
{
action: 'CREATE',
description: 'Created entity',
name: 'New Entity',
extra: 'of type Existing Template',
}
);
});

it('should beautify as CREATE when no ID found', async () => {
await testBeautified(
{
Expand Down
2 changes: 2 additions & 0 deletions app/api/entities/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { search } from 'api/search';
import { uploadMiddleware } from 'api/files';
import { saveEntity } from 'api/entities/entitySavingManager';
import activitylogMiddleware from 'api/activitylog/activitylogMiddleware';
import entities from './entities';
import templates from '../templates/templates';
import thesauri from '../thesauri/thesauri';
Expand Down Expand Up @@ -76,6 +77,7 @@ export default app => {
'/api/entities',
needsAuthorization(['admin', 'editor', 'collaborator']),
uploadMiddleware.multiple(),
activitylogMiddleware,
async (req, res, next) => {
try {
const entityToSave = req.body.entity ? JSON.parse(req.body.entity) : req.body;
Expand Down
4 changes: 3 additions & 1 deletion app/react/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { MutableSnapshot, RecoilRoot } from 'recoil';
import { Provider } from 'react-redux';
import { getRoutes } from './Routes';
import CustomProvider from './App/Provider';
import { settingsAtom } from './V2/atoms/settingsAtom';
import { settingsAtom, templatesAtom } from './V2/atoms';
import { store } from './store';

const reduxState = store?.getState();

const settings = reduxState?.settings.collection.toJS() || {};
const templates = reduxState?.templates.toJS() || [];

const router = createBrowserRouter(getRoutes(settings, reduxState?.user.get('_id')));

const recoilGlobalState = ({ set }: MutableSnapshot) => {
set(settingsAtom, settings);
set(templatesAtom, templates);
};

const App = () => (
Expand Down
1 change: 0 additions & 1 deletion app/react/Auth2fa/Configure2fa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class Configure2fa extends Component<Configure2faProps, State> {
render() {
const { otpauth, secret, conflict } = this.state;
const { userUsing2fa } = this.props;
console.log('userUsing2fa', otpauth);
return (
<div className="settings-content">
<div className="configure2fa-settings">
Expand Down
3 changes: 2 additions & 1 deletion app/react/V2/Components/UI/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const Table = <T,>({
sorting: sortingState,
...applyForSelection({ rowSelection }, {}, enableSelection),
},
enableRowSelection: enableSelection,
enableRowSelection: (row: any) =>
Boolean(enableSelection && !row.original?.disableRowSelection),
enableSubRowSelection: false,
onRowSelectionChange: applyForSelection(setRowSelection, () => undefined, enableSelection),
onSortingChange: sortingFunction,
Expand Down
4 changes: 3 additions & 1 deletion app/react/V2/Components/UI/Table/TableElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const IndeterminateCheckbox = ({
indeterminate,
className = '',
id,
disabled,
...rest
}: { indeterminate?: boolean } & HTMLProps<HTMLInputElement>) => {
const ref = useRef<HTMLInputElement>(null!);
Expand All @@ -53,7 +54,8 @@ const IndeterminateCheckbox = ({
<input
type="checkbox"
ref={ref}
className={`rounded cursor-pointer ${className}`}
className={`rounded cursor-pointer ${className} ${disabled ? 'opacity-50' : ''}`}
disabled={disabled}
{...rest}
/>
</label>
Expand Down
4 changes: 3 additions & 1 deletion app/react/V2/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { notificationAtom, notificationAtomType } from './notificationAtom';
import { settingsAtom } from './settingsAtom';
import { templatesAtom } from './templatesAtom';

export type { notificationAtomType };
export { notificationAtom };
export { notificationAtom, settingsAtom, templatesAtom };
18 changes: 18 additions & 0 deletions app/react/V2/atoms/templatesAtom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { atom } from 'recoil';
import { Template } from 'app/apiResponseTypes';
import { store } from 'app/store';

const templatesAtom = atom({
key: 'templates',
default: [] as Template[],
//sync deprecated redux store
effects: [
({ onSet }) => {
onSet(newValue => {
store?.dispatch({ type: 'templates/SET', value: newValue });
});
},
],
});

export { templatesAtom };
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.156.0",
"version": "1.157.0",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down Expand Up @@ -101,10 +101,10 @@
"@hookform/error-message": "^2.0.1",
"@loadable/component": "^5.13.1",
"@popperjs/core": "^2.11.8",
"@remix-run/router": "^1.15.1",
"@sentry/node": "^7.102.1",
"@sentry/react": "7.102.1",
"@sentry/tracing": "^7.102.1",
"@remix-run/router": "^1.15.2",
"@sentry/node": "^7.103.0",
"@sentry/react": "7.103.0",
"@sentry/tracing": "^7.103.0",
"@smithy/node-http-handler": "^2.3.1",
"@socket.io/redis-adapter": "7.2.0",
"@socket.io/redis-emitter": "5.1.0",
Expand Down Expand Up @@ -240,7 +240,7 @@
"world-countries": "5.0.0",
"xml-js": "^1.6.11",
"yargs": "^17.7.2",
"yauzl": "^3.1.0",
"yauzl": "^3.1.1",
"yazl": "^2.5.1"
},
"devDependencies": {
Expand All @@ -260,7 +260,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@babel/plugin-transform-react-constant-elements": "^7.23.3",
"@babel/plugin-transform-react-inline-elements": "^7.23.3",
"@babel/preset-env": "^7.23.9",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@babel/register": "^7.23.7",
Expand Down Expand Up @@ -341,7 +341,7 @@
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-import": "v2.29.1",
"eslint-plugin-jasmine": "4.1.3",
"eslint-plugin-jest": "v27.8.0",
"eslint-plugin-jest": "v27.9.0",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "5.1.3",
Expand Down
Loading

0 comments on commit 45b5f8d

Please sign in to comment.