Skip to content

Commit

Permalink
v1.155.0
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Feb 26, 2024
2 parents 6e87258 + 10a216d commit e46fccf
Show file tree
Hide file tree
Showing 21 changed files with 628 additions and 593 deletions.
4 changes: 1 addition & 3 deletions app/api/files/specs/routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ describe('files routes', () => {

const [file]: FileType[] = await files.get({ originalname: 'test.txt' });

await request(app)
.delete('/api/files')
.query({ _id: file._id?.toString() });
await request(app).delete('/api/files').query({ _id: file._id?.toString() });

expect(await storage.fileExists(file.filename!, 'custom')).toBe(false);
});
Expand Down
4 changes: 1 addition & 3 deletions app/api/files/specs/uploadRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ describe('upload routes', () => {
originalname: 'f2082bf51b6ef839690485d7153e847a.pdf',
});

await request(app)
.delete('/api/files')
.query({ _id: file._id?.toString() });
await request(app).delete('/api/files').query({ _id: file._id?.toString() });

const [thumbnail]: FileType[] = await files.get({ filename: `${file._id}.jpg` });
expect(thumbnail).not.toBeDefined();
Expand Down
24 changes: 9 additions & 15 deletions app/api/relationships.v2/database/MongoGraphQueryCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ const compilers = {
},
...query
.getMatches()
.reduce<object[]>(
(reduced, nested, nestedIndex) =>
reduced.concat(compilers.match(nested, nestedIndex, language)),
[]
),
.reduce<
object[]
>((reduced, nested, nestedIndex) => reduced.concat(compilers.match(nested, nestedIndex, language)), []),
...projectAndArrangeTraversals(query.getProjection(), query.getMatches().length),
...unwind(query.getMatches().length),
],
Expand Down Expand Up @@ -118,11 +116,9 @@ const compilers = {
},
...query
.getTraversals()
.reduce<object[]>(
(reduced, nested, nestedIndex) =>
reduced.concat(compilers.traversal(nested, nestedIndex, language)),
[]
),
.reduce<
object[]
>((reduced, nested, nestedIndex) => reduced.concat(compilers.traversal(nested, nestedIndex, language)), []),
...projectAndArrangeTraversals({ sharedId: 1, title: 1 }, query.getTraversals().length),
...unwind(query.getTraversals().length),
],
Expand Down Expand Up @@ -154,11 +150,9 @@ const compilers = {
},
...query
.getTraversals()
.reduce<object[]>(
(reduced, nested, nestedIndex) =>
reduced.concat(compilers.traversal(nested, nestedIndex, language)),
[]
),
.reduce<
object[]
>((reduced, nested, nestedIndex) => reduced.concat(compilers.traversal(nested, nestedIndex, language)), []),
...projectAndArrangeTraversals({ sharedId: 1, title: 1 }, query.getTraversals().length),
...unwind(query.getTraversals().length),
];
Expand Down
32 changes: 19 additions & 13 deletions app/react/App/styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
*/

/*
Expand Down Expand Up @@ -32,9 +32,11 @@
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
7. Disable tap highlights on iOS
*/

html {
html,
:host {
line-height: 1.5;
/* 1 */
-webkit-text-size-adjust: 100%;
Expand All @@ -50,6 +52,8 @@ html {
/* 5 */
font-variation-settings: normal;
/* 6 */
-webkit-tap-highlight-color: transparent;
/* 7 */
}

/*
Expand Down Expand Up @@ -121,8 +125,10 @@ strong {
}

/*
1. Use the user's configured `mono` font family by default.
2. Correct the odd `em` font sizing in all browsers.
1. Use the user's configured `mono` font-family by default.
2. Use the user's configured `mono` font-feature-settings by default.
3. Use the user's configured `mono` font-variation-settings by default.
4. Correct the odd `em` font sizing in all browsers.
*/

code,
Expand All @@ -131,8 +137,12 @@ samp,
pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
/* 1 */
font-size: 1em;
font-feature-settings: normal;
/* 2 */
font-variation-settings: normal;
/* 3 */
font-size: 1em;
/* 4 */
}

/*
Expand Down Expand Up @@ -774,10 +784,8 @@ input[type=file]::file-selector-button {
padding-bottom: 0.625rem;
padding-left: 2rem;
padding-right: 1rem;
-webkit-margin-start: -1rem;
margin-inline-start: -1rem;
-webkit-margin-end: 1rem;
margin-inline-end: 1rem;
margin-inline-start: -1rem;
margin-inline-end: 1rem;
}

input[type=file]::file-selector-button:hover {
Expand Down Expand Up @@ -1915,8 +1923,7 @@ input:checked + .toggle-bg {
}

.me-4 {
-webkit-margin-end: 1rem;
margin-inline-end: 1rem;
margin-inline-end: 1rem;
}

.ml-0 {
Expand Down Expand Up @@ -3888,8 +3895,7 @@ input:checked + .toggle-bg {
}

.ps-5 {
-webkit-padding-start: 1.25rem;
padding-inline-start: 1.25rem;
padding-inline-start: 1.25rem;
}

.pt-0 {
Expand Down
21 changes: 11 additions & 10 deletions app/react/Charts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import LibraryChart from './components/LibraryChart';
import LibraryCharts from './components/LibraryCharts';
import ExtendedTooltip from './components/ExtendedTooltip';

const Bar = loadable(async () =>
import(/* webpackChunkName: "LazyLoadBar" */ './components/Bar.js')
const Bar = loadable(
async () => import(/* webpackChunkName: "LazyLoadBar" */ './components/Bar.js')
);

const ColoredBar = loadable(async () =>
import(/* webpackChunkName: "LazyLoadColoredBar" */ './components/ColoredBar.js')
const ColoredBar = loadable(
async () => import(/* webpackChunkName: "LazyLoadColoredBar" */ './components/ColoredBar.js')
);

const Pie = loadable(async () =>
import(/* webpackChunkName: "LazyLoadPie" */ './components/Pie.js')
const Pie = loadable(
async () => import(/* webpackChunkName: "LazyLoadPie" */ './components/Pie.js')
);

const StackedDualBarChart = loadable(async () =>
import(
/* webpackChunkName: "LazyLoadStackedDualBarChart" */ './components/StackedDualBarChart.js'
)
const StackedDualBarChart = loadable(
async () =>
import(
/* webpackChunkName: "LazyLoadStackedDualBarChart" */ './components/StackedDualBarChart.js'
)
);

export {
Expand Down
5 changes: 2 additions & 3 deletions app/react/Layout/TableViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ class TableViewerComponent extends Component<TableViewerProps> {
}

const getTableViewColumnsSelector = (state: EntityDisplayState) => state.ui.get('tableViewColumns');
const selectTableViewColumns = createSelector(
getTableViewColumnsSelector,
columns => columns?.toJS()
const selectTableViewColumns = createSelector(getTableViewColumnsSelector, columns =>
columns?.toJS()
);

const mapStateToProps = (state: IStore, props: TableViewerProps) => ({
Expand Down
6 changes: 5 additions & 1 deletion app/react/Library/actions/exportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export function exportDocuments(storeKey: string, captcha?: CaptchaValue) {
const { search, filters } = state;
const exportFilters = filters.toJS();

const finalSearchParams = processFilters(search, exportFilters, 10000);
const finalSearchParams = processFilters(search, exportFilters, {
limit: 10000,
encoding: false,
});

finalSearchParams.searchTerm = state.search.searchTerm;

if (state.ui.get('selectedDocuments').size) {
Expand Down
22 changes: 11 additions & 11 deletions app/react/Library/actions/libraryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,32 @@ function filterIsEmpty(value) {
return false;
}

function processFilters(readOnlySearch, filters, limit, from) {
function processFilters(readOnlySearch, filters, options = {}) {
let search = {
filters: {},
...readOnlySearch,
};

const { limit, from, encoding = true } = options;
if (search.publishedStatus) {
search = filterToQuery(search);
}

search.filters = {};

const getValue = value => (encoding ? encodeURIComponent(value) : value);
filters.properties.forEach(property => {
if (!filterIsEmpty(readOnlySearch.filters[property.name]) && !property.filters) {
if (
readOnlySearch.filters[property.name] &&
(property.type === 'text' ||
(property.type === 'relationship' && property.inherit?.type === 'text'))
) {
search.filters[encodeURIComponent(property.name)] = encodeURIComponent(
search.filters[getValue(property.name)] = getValue(
readOnlySearch.filters[property.name]
).replace(/%20/g, ' ');
} else {
search.filters[encodeURIComponent(property.name)] = readOnlySearch.filters[property.name];
search.filters[getValue(property.name)] = readOnlySearch.filters[property.name];
}
}

Expand All @@ -202,11 +204,7 @@ function processFilters(readOnlySearch, filters, limit, from) {
}
}
});

search.types = filters.documentTypes;
search.limit = limit;
search.from = from;
return search;
return { ...search, types: filters.documentTypes, limit, from };
}

function encodeSearch(_search, appendQ = true) {
Expand Down Expand Up @@ -258,8 +256,10 @@ function searchDocuments(
...processFilters(
currentSearch,
currentFilters.toJS ? currentFilters.toJS() : currentFilters,
limit,
from
{
limit,
from,
}
),
searchTerm: state.search.searchTerm,
customFilters: currentSearch.customFilters,
Expand Down Expand Up @@ -404,7 +404,7 @@ function getAggregationSuggestions(storeKey, property, searchTerm) {
const state = store.getState()[storeKey];
const { search, filters } = state;

const query = processFilters(search, filters.toJS(), 0);
const query = processFilters(search, filters.toJS(), { limit: 0 });
query.searchTerm = search.searchTerm;
if (storeKey === 'uploads') {
query.unpublished = true;
Expand Down
56 changes: 56 additions & 0 deletions app/react/Library/actions/specs/libraryActions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,60 @@ describe('libraryActions', () => {
expect(store.getActions()).toEqual(expectedActions);
});
});

describe('processFilters', () => {
const search = {
filters: {
institución_afectada: {
values: ['oxdabs9e55l'],
},
},
publishedStatus: {
values: ['restricted'],
},
};
const filters = {
properties: [
{
content: '',
_id: '65d4d8d83b2ebd680f2e133f',
label: 'Institución afectada',
type: 'relationship',
relationType: '65d4d8c63b2ebd680f2e12ba',
filter: true,
name: 'institución_afectada',
},
],
documentTypes: ['65d4d8d83b2ebd680f2e133e'],
};

it('should encode the filters by default', () => {
const processedFilters = actions.processFilters(search, filters, {
limit: 10000,
});
expect(processedFilters).toMatchObject({
filters: { 'instituci%C3%B3n_afectada': { values: ['oxdabs9e55l'] } },
from: undefined,
includeUnpublished: false,
limit: 10000,
types: ['65d4d8d83b2ebd680f2e133e'],
unpublished: true,
});
});
it('should not encode the filters as an option', () => {
const processedFilters = actions.processFilters(search, filters, {
limit: 200,
from: 100,
encoding: false,
});
expect(processedFilters).toMatchObject({
filters: { institución_afectada: { values: ['oxdabs9e55l'] } },
from: 100,
includeUnpublished: false,
limit: 200,
types: ['65d4d8d83b2ebd680f2e133e'],
unpublished: true,
});
});
});
});
24 changes: 12 additions & 12 deletions app/react/Markdown/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ import Value from './Value';
import SearchBox from './SearchBox';
import EntityInfo from './EntityInfo';

const BarChart = loadable(async () =>
import(/* webpackChunkName: "LazyLoadBarChart" */ './BarChart.js')
const BarChart = loadable(
async () => import(/* webpackChunkName: "LazyLoadBarChart" */ './BarChart.js')
);
const FreeBarChart = loadable(async () =>
import(/* webpackChunkName: "LazyLoadFreeBarChart" */ './FreeBarChart.tsx')
const FreeBarChart = loadable(
async () => import(/* webpackChunkName: "LazyLoadFreeBarChart" */ './FreeBarChart.tsx')
);

const Slideshow = loadable(async () =>
import(/* webpackChunkName: "LazyLoadSlideshow" */ './Slideshow.js')
const Slideshow = loadable(
async () => import(/* webpackChunkName: "LazyLoadSlideshow" */ './Slideshow.js')
);

const PieChart = loadable(async () =>
import(/* webpackChunkName: "LazyLoadPieChart" */ './PieChart.js')
const PieChart = loadable(
async () => import(/* webpackChunkName: "LazyLoadPieChart" */ './PieChart.js')
);

const ListChart = loadable(async () =>
import(/* webpackChunkName: "LazyLoadListChart" */ './ListChart.js')
const ListChart = loadable(
async () => import(/* webpackChunkName: "LazyLoadListChart" */ './ListChart.js')
);
const GaugeChart = loadable(async () =>
import(/* webpackChunkName: "LazyLoadGaugeChart" */ './GaugeChart.js')
const GaugeChart = loadable(
async () => import(/* webpackChunkName: "LazyLoadGaugeChart" */ './GaugeChart.js')
);

export {
Expand Down
3 changes: 2 additions & 1 deletion app/react/Metadata/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ function checkGeneratedTitle(entity, template) {

export function loadFetchedInReduxForm(form, entity, templates) {
const sortedTemplates = advancedSort(templates, { property: 'name' });
const defaultTemplate = sortedTemplates.find(sortedTemplate => sortedTemplate.default);
const defaultTemplate =
sortedTemplates.find(sortedTemplate => sortedTemplate.default) || sortedTemplates[0];
const templateId = entity.template || defaultTemplate._id;
const template =
sortedTemplates.find(sortedTemplate => sortedTemplate._id === templateId) || emptyTemplate;
Expand Down
Loading

0 comments on commit e46fccf

Please sign in to comment.